Skip to content

Commit

Permalink
use linear time calculation when applicable in timingdata for etaner
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Jun 5, 2017
1 parent e76366b commit daf3600
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions src/TimingData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1415,8 +1415,38 @@ float TimingData::WhereUAtBroNoOffset(float beat) const {

const vector<float>& TimingData::BuildAndGetEtaner(const vector<int>& nerv) {
ElapsedTimesAtNonEmptyRows.clear();
for (size_t i = 0; i < nerv.size(); i++)
ElapsedTimesAtNonEmptyRows.emplace_back(GetElapsedTimeFromBeatNoOffset(NoteRowToBeat(nerv[i])));
const vector<TimingSegment*>* segs = m_avpTimingSegments;
const vector<TimingSegment*>& bpms = segs[SEGMENT_BPM];
const vector<TimingSegment*>& warps = segs[SEGMENT_WARP];
const vector<TimingSegment*>& stops = segs[SEGMENT_STOP];
const vector<TimingSegment*>& delays = segs[SEGMENT_DELAY];

// use linear calculations if linear time is determined -mina
if (warps.size() + stops.size() + delays.size() == 0 && nerv.size() > 0) {
float last_time = 0.f;
float bps = GetBPMAtRow(0) / 60.0f;
int lastbpmrow = 0;
size_t idx = 0;

for (auto& b : bpms) {
int event_row = b->GetRow();
float time_to_next_event = NoteRowToBeat(event_row - lastbpmrow) / bps;
float next_event_time = last_time + time_to_next_event;
while (nerv[idx] <= event_row && idx < nerv.size()) {
float perc = (nerv[idx] - lastbpmrow) / static_cast<float>(event_row - lastbpmrow);
float minatime = last_time + time_to_next_event * perc - m_fBeat0OffsetInSeconds;
ElapsedTimesAtNonEmptyRows.emplace_back(minatime);
++idx;
}
last_time = next_event_time;
bps = GetBPMAtRow(event_row) / 60.0f;
lastbpmrow = event_row;
}
return ElapsedTimesAtNonEmptyRows;
}

for(auto& n : nerv)
ElapsedTimesAtNonEmptyRows.emplace_back(GetElapsedTimeFromBeatNoOffset(NoteRowToBeat(n)));
return ElapsedTimesAtNonEmptyRows;
}

Expand Down

0 comments on commit daf3600

Please sign in to comment.