Call this function to manipulate the underlying sequence data. This is NOT the function that handles horizontal dragging.
| 527 | // Call this function to manipulate the underlying sequence data. This is |
| 528 | // NOT the function that handles horizontal dragging. |
| 529 | bool NoteTrack::Shift(double t) // t is always seconds |
| 530 | { |
| 531 | if (t > 0) { |
| 532 | auto &seq = GetSeq(); |
| 533 | // insert an even number of measures |
| 534 | seq.convert_to_beats(); |
| 535 | // get initial tempo |
| 536 | double tempo = seq.get_tempo(0.0); |
| 537 | double beats_per_measure = seq.get_bar_len(0.0); |
| 538 | int m = ROUND(t * tempo / beats_per_measure); |
| 539 | // need at least 1 measure, so if we rounded down to zero, fix it |
| 540 | if (m == 0) m = 1; |
| 541 | // compute NEW tempo so that m measures at NEW tempo take t seconds |
| 542 | tempo = beats_per_measure * m / t; // in beats per second |
| 543 | seq.insert_silence(0.0, beats_per_measure * m); |
| 544 | seq.set_tempo(tempo * 60.0 /* bpm */, 0.0, beats_per_measure * m); |
| 545 | seq.write("afterShift.gro"); |
| 546 | } else if (t < 0) { |
| 547 | auto &seq = GetSeq(); |
| 548 | seq.convert_to_seconds(); |
| 549 | seq.clear(0, t, true); |
| 550 | } else { // offset is zero, no modifications |
| 551 | return false; |
| 552 | } |
| 553 | return true; |
| 554 | } |
| 555 | |
| 556 | QuantizedTimeAndBeat NoteTrack::NearestBeatTime( double time ) const |
| 557 | { |
no test coverage detected