a better solution for the problem being addressed in b40513ff7
This commit is contained in:
parent
a5a1caf9fa
commit
ea02c49856
@ -4408,6 +4408,7 @@ TempoMap::midi_clock_beat_at_or_after (samplepos_t const pos, samplepos_t& clk_p
|
|||||||
TempoPoint const & tp (tempo_at (sc));
|
TempoPoint const & tp (tempo_at (sc));
|
||||||
Temporal::Beats b = (tp.quarters_at_sample (pos)).round_up_to_beat ();
|
Temporal::Beats b = (tp.quarters_at_sample (pos)).round_up_to_beat ();
|
||||||
|
|
||||||
|
again:
|
||||||
/* We cannot use
|
/* We cannot use
|
||||||
* clk_pos = sample_at (b);
|
* clk_pos = sample_at (b);
|
||||||
* because in this case we have to round up to the start
|
* because in this case we have to round up to the start
|
||||||
@ -4423,19 +4424,19 @@ TempoMap::midi_clock_beat_at_or_after (samplepos_t const pos, samplepos_t& clk_p
|
|||||||
*/
|
*/
|
||||||
clk_beat = b.get_beats () * 4 ; // 4 = 24 / 6;
|
clk_beat = b.get_beats () * 4 ; // 4 = 24 / 6;
|
||||||
|
|
||||||
/* It can happen (mostly due to odd plugin latency) that the @p pos
|
/* It can happen that the computed beat is actually slightly before
|
||||||
* argument is a few samples past the audio time of the current
|
* pos. For example, if @p pos is 441002, this is less than 1 tick
|
||||||
* beat. For example, beat 20 @ 120 bpm @ 44100Hz would be at sample
|
* beyond beat 20 (at 120bpm, 44100Hz, 4/4). The call to
|
||||||
* 441000 but the process() call that gets us here might start at
|
* quarters_at_sample(pos) will return 20:0, which does not (and
|
||||||
* 441002. Check if the error is more than 1 tick at the relevant
|
* cannot) be rounded up). But when we convert that back to a sample
|
||||||
* tempo, and if so, round up the start (@p pos)
|
* time, we get 441000, which is before the time (@p pos) that we are
|
||||||
|
* meant to be computing for. So .. advance to the next beat, and do it
|
||||||
|
* again.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (clk_pos < pos) {
|
if (clk_pos < pos) {
|
||||||
samplecnt_t one_tick_in_superclocks (tp.superclocks_per_note_type_at (timepos_t (sc))/ ((tp.note_type() * 1920) / 4));
|
b += Beats (1, 0);
|
||||||
if (abs (clk_pos - pos) < superclock_to_samples (one_tick_in_superclocks, TEMPORAL_SAMPLE_RATE)) {
|
goto again;
|
||||||
clk_pos = pos;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user