use cleaned up Temporal ::quarters*_at* API (libs edition)

This commit is contained in:
Paul Davis
2020-12-07 11:39:50 -07:00
parent 43d84620e0
commit 3ca2be321d
5 changed files with 22 additions and 23 deletions

View File

@@ -1613,7 +1613,7 @@ AUPlugin::get_beat_and_tempo_callback (Float64* outCurrentBeat,
DEBUG_TRACE (DEBUG::AudioUnitProcess, "AU calls ardour beat&tempo callback\n");
if (outCurrentBeat) {
*outCurrentBeat = tmap.quarter_note_at_sample (transport_sample);
*outCurrentBeat = tmap.quarters_at_sample (transport_sample);
}
if (outCurrentTempo) {
@@ -1642,7 +1642,7 @@ AUPlugin::get_musical_time_location_callback (UInt32* outDeltaSampleOffsetToNe
/* on the beat */
*outDeltaSampleOffsetToNextBeat = 0;
} else {
double const next_beat = ceil (tmap.quarter_note_at_sample (transport_sample));
double const next_beat = ceil (tmap.quarters_at_sample (transport_sample));
samplepos_t const next_beat_sample = tmap.sample_at_quarter_note (next_beat);
*outDeltaSampleOffsetToNextBeat = next_beat_sample - transport_sample;
@@ -1667,7 +1667,7 @@ AUPlugin::get_musical_time_location_callback (UInt32* outDeltaSampleOffsetToNe
bbt.beats = 1;
bbt.ticks = 0;
*outCurrentMeasureDownBeat = tmap.quarter_note_at_bbt (bbt);
*outCurrentMeasureDownBeat = tmap.quarters_at (bbt);
}
return noErr;
@@ -1723,11 +1723,11 @@ AUPlugin::get_transport_state_callback (Boolean* outIsPlaying,
Temporal::BBT_Time bbt;
if (outCycleStartBeat) {
*outCycleStartBeat = tmap.quarter_note_at_sample (loc->start());
*outCycleStartBeat = tmap.quarters_at_sample (loc->start());
}
if (outCycleEndBeat) {
*outCycleEndBeat = tmap.quarter_note_at_sample (loc->end());
*outCycleEndBeat = tmap.quarters_at_sample (loc->end());
}
}
}

View File

@@ -207,9 +207,9 @@ intptr_t Session::vst_callback (
bbt.beats = 1;
bbt.ticks = 0;
/* exact quarter note */
double ppqBar = tmap->quarter_note_at (bbt);
double ppqBar = tmap->quarters_at (bbt);
/* quarter note at sample position (not rounded to note subdivision) */
double ppqPos = tmap->quarter_note_at (now);
double ppqPos = tmap->quarters_at_sample (now);
if (value & (kVstPpqPosValid)) {
timeinfo->ppqPos = ppqPos;
newflags |= kVstPpqPosValid;
@@ -270,10 +270,9 @@ intptr_t Session::vst_callback (
newflags |= kVstTransportCycleActive;
Location * looploc = session->locations ()->auto_loop_location ();
if (looploc) try {
#warning NUTEMPO FIXME needs new session tempo map
//timeinfo->cycleStartPos = session->tempo_map ().quarter_note_at_sample_rt (looploc->start ());
//timeinfo->cycleEndPos = session->tempo_map ().quarter_note_at_sample_rt (looploc->end ());
// newflags |= kVstCyclePosValid;
timeinfo->cycleStartPos = tmap->quarters_at (looploc->start ());
timeinfo->cycleEndPos = tmap->quarters_at (looploc->end ());
newflags |= kVstCyclePosValid;
} catch (...) { }
}

View File

@@ -704,7 +704,7 @@ MeterSection::get_state() const
from Beats distance, or instead work in quarter-notes and/or beats and convert to samples last.
The above pointless example could instead do:
beat_at_quarter_note (quarter_note_at_beat (beat)) to avoid rounding.
beat_at_quarter_note (quarters_at (beat)) to avoid rounding.
The Shaggs - Things I Wonder
https://www.youtube.com/watch?v=9wQK6zMJOoQ

View File

@@ -73,9 +73,9 @@ TempoTest::recomputeMapTest48 ()
CPPUNIT_ASSERT_EQUAL (samplepos_t (96e3), map.sample_at_quarter_note (4.0));
/* sample - quarter note*/
CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, map.quarter_note_at_sample (288e3), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (6.0, map.quarter_note_at_sample (144e3), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (4.0, map.quarter_note_at_sample (96e3), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, map.quarters_at_sample (288e3), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (6.0, map.quarters_at_sample (144e3), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (4.0, map.quarters_at_sample (96e3), 1e-17);
/* pulse - internal minute based interface */
CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1, map.minute_at_pulse_locked (map._metrics, 3.0), 1e-17);
@@ -94,8 +94,8 @@ TempoTest::recomputeMapTest48 ()
CPPUNIT_ASSERT_DOUBLES_EQUAL (120.0, map.tempo_at_quarter_note (6.0).note_types_per_minute(), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (120.0, map.tempo_at_quarter_note (0.0).note_types_per_minute(), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, map.quarter_note_at_tempo (tempoB), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0, map.quarter_note_at_tempo (tempoA), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, map.quarters_at_tempo (tempoB), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0, map.quarters_at_tempo (tempoA), 1e-17);
/* tempo - internal minute interface */
CPPUNIT_ASSERT_DOUBLES_EQUAL (240.0, map.tempo_at_minute_locked (map._metrics, 0.1).note_types_per_minute(), 1e-17);
@@ -173,9 +173,9 @@ TempoTest::recomputeMapTest44 ()
CPPUNIT_ASSERT_EQUAL (samplepos_t (88200), map.sample_at_quarter_note (4.0));
/* sample - quarter note */
CPPUNIT_ASSERT_DOUBLES_EQUAL (3.0 * 4.0, map.quarter_note_at_sample (264600), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (1.5 * 4.0, map.quarter_note_at_sample (132300), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0 * 4.0, map.quarter_note_at_sample (88200), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (3.0 * 4.0, map.quarters_at_sample (264600), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (1.5 * 4.0, map.quarters_at_sample (132300), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0 * 4.0, map.quarters_at_sample (88200), 1e-17);
/* pulse - internal minute based interface */
CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1, map.minute_at_pulse_locked (map._metrics, 3.0), 1e-17);
@@ -194,8 +194,8 @@ TempoTest::recomputeMapTest44 ()
CPPUNIT_ASSERT_DOUBLES_EQUAL (120.0, map.tempo_at_quarter_note (6.0).note_types_per_minute(), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (120.0, map.tempo_at_quarter_note (0.0).note_types_per_minute(), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, map.quarter_note_at_tempo (tempoB), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0, map.quarter_note_at_tempo (tempoA), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, map.quarters_at_tempo (tempoB), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0, map.quarters_at_tempo (tempoA), 1e-17);
/* tempo - internal minute interface */
CPPUNIT_ASSERT_DOUBLES_EQUAL (240.0, map.tempo_at_minute_locked (map._metrics, 0.1).note_types_per_minute(), 1e-17);

View File

@@ -641,7 +641,7 @@ VST3Plugin::connect_and_run (BufferSet& bufs,
context.tempo = metric.tempo().quarter_notes_per_minute ();
context.timeSigNumerator = metric.meter().divisions_per_bar ();
context.timeSigDenominator = metric.meter().note_value ();
context.projectTimeMusic = metric.tempo().quarters_at (start);
context.projectTimeMusic = metric.tempo().quarters_at_sample (start);
context.barPositionMusic = bbt.bars * 4; // PPQN, NOT tmap.metric_at(bbt).meter().divisions_per_bar()
}