reimplement TempoMap::midi_clock_beat_at_or_after()

This commit is contained in:
Paul Davis 2021-03-17 13:03:56 -06:00
parent 6effcc7723
commit 0ab2308523
3 changed files with 21 additions and 2 deletions

View File

@ -167,8 +167,7 @@ MidiClockTicker::tick (samplepos_t start_sample, samplepos_t end_sample, pframes
uint32_t beat_pos;
samplepos_t clk_pos;
#warning NUTEMPO need to reimplement this in TempoMap
// _session->tempo_map ().midi_clock_beat_at_of_after (start_sample + _mclk_out_latency.max, clk_pos, beat_pos);
Temporal::TempoMap::use()->midi_clock_beat_at_or_after (start_sample + _mclk_out_latency.max, clk_pos, beat_pos);
_beat_pos = beat_pos;
_next_tick = clk_pos - _mclk_out_latency.max;

View File

@ -3077,3 +3077,21 @@ TempoMap::abort_update ()
*/
TempoMap::fetch ();
}
void
TempoMap::midi_clock_beat_at_or_after (samplepos_t const pos, samplepos_t& clk_pos, uint32_t& clk_beat)
{
/* Sequences are always assumed to start on a MIDI Beat of 0 (ie, the downbeat).
*
* There are 24 MIDI clock per quarter note (1 Temporal::Beat)
*
* from http://midi.teragonaudio.com/tech/midispec/seq.htm
*/
Temporal::Beats b = (quarters_at_sample (pos)).round_up_to_beat ();
clk_pos = sample_at (b, TEMPORAL_SAMPLE_RATE);
clk_beat = b.get_beats () * 24;
assert (clk_pos >= pos);
}

View File

@ -820,6 +820,8 @@ class LIBTEMPORAL_API TempoMap : public PBD::StatefulDestructible
Beats quarters_at_sample (samplepos_t sc) const { return quarters_at_superclock (samples_to_superclock (sc, TEMPORAL_SAMPLE_RATE)); }
Beats quarters_at_superclock (superclock_t sc) const;
void midi_clock_beat_at_or_after (samplepos_t const pos, samplepos_t& clk_pos, uint32_t& clk_beat);
private:
Tempos _tempos;
Meters _meters;