midi clock: provide option to quantize incoming BPM values

This commit is contained in:
Paul Davis 2023-02-23 12:15:26 -07:00
parent dbd779bf85
commit 27205c7639
2 changed files with 5 additions and 3 deletions

View file

@ -7553,13 +7553,14 @@ Session::maybe_update_tempo_from_midiclock_tempo (float bpm)
if (tmap->n_tempos() == 1) { if (tmap->n_tempos() == 1) {
Temporal::TempoMetric const & metric (tmap->metric_at (0)); Temporal::TempoMetric const & metric (tmap->metric_at (0));
if (fabs (metric.tempo().note_types_per_minute() - bpm) > (0.01 * metric.tempo().note_types_per_minute())) { if (fabs (metric.tempo().note_types_per_minute() - bpm) >= Config->get_midi_clock_resolution()) {
std::cerr << "\n\ntempo from " << metric.tempo().note_types_per_minute() << " to " << bpm << " delta of " << metric.tempo().note_types_per_minute() - bpm << " @ " << metric.tempo().note_types_per_minute() << " justifies map change\n"; /* fix note type as quarters, because that's how MIDI clock works */
tmap->change_tempo (metric.get_editable_tempo(), Tempo (bpm, 4.0, bpm)); tmap->change_tempo (metric.get_editable_tempo(), Tempo (bpm, bpm, 4.0));
TempoMap::update (tmap); TempoMap::update (tmap);
return; return;
} }
} }
TempoMap::abort_update (); TempoMap::abort_update ();
} }

View file

@ -843,6 +843,7 @@ TempoMap::add_meter (MeterPoint* mp)
void void
TempoMap::change_tempo (TempoPoint & p, Tempo const & t) TempoMap::change_tempo (TempoPoint & p, Tempo const & t)
{ {
std::cerr << "overwrite " << ((Tempo*)&p)->note_types_per_minute() << " with " << t.note_types_per_minute() << std::endl;
*((Tempo*)&p) = t; *((Tempo*)&p) = t;
reset_starting_at (p.sclock()); reset_starting_at (p.sclock());
} }