diff --git a/libs/ardour/ardour/rc_configuration_vars.h b/libs/ardour/ardour/rc_configuration_vars.h index 0930ab3165..f56c521240 100644 --- a/libs/ardour/ardour/rc_configuration_vars.h +++ b/libs/ardour/ardour/rc_configuration_vars.h @@ -64,6 +64,7 @@ CONFIG_VARIABLE (bool, trace_midi_output, "trace-midi-output", false) CONFIG_VARIABLE (bool, send_mtc, "send-mtc", false) CONFIG_VARIABLE (bool, send_mmc, "send-mmc", false) CONFIG_VARIABLE (bool, send_midi_clock, "send-midi-clock", false) +CONFIG_VARIABLE (double, midi_clock_resolution, "midi-clock-resolution", 1.) /* 0 implies do not round, 1 implies round to integer, non-zero is the smallest fractional resolution, in bpm */ CONFIG_VARIABLE (bool, mmc_control, "mmc-control", true) CONFIG_VARIABLE (bool, midi_feedback, "midi-feedback", false) CONFIG_VARIABLE (int32_t, mmc_receive_device_id, "mmc-receive-device-id", 0x7f) diff --git a/libs/ardour/midi_clock_slave.cc b/libs/ardour/midi_clock_slave.cc index 7178543acc..8aefe47d3e 100644 --- a/libs/ardour/midi_clock_slave.cc +++ b/libs/ardour/midi_clock_slave.cc @@ -249,11 +249,20 @@ MIDIClock_TransportMaster::update_midi_clock (Parser& /*parser*/, samplepos_t ti _bpm = (ENGINE->sample_rate() * 60.0) / samples_per_quarter; + double mr = Config->get_midi_clock_resolution(); + + if (mr == 1.) { + _bpm = round (_bpm); + } else if (mr != 0.) { + _bpm -= fmod (_bpm, mr); + } + /* when rolling speed is always 1.0. The transport moves at wall-clock * speed. What changes is the music-time (BPM), not the speed. */ if (TransportMasterManager::instance().current().get() == this) { /* TODO always set tempo, even when there is a map */ + _session->maybe_update_tempo_from_midiclock_tempo (_bpm); } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 2e9ced7b22..295e8ad94a 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -7554,6 +7554,7 @@ Session::maybe_update_tempo_from_midiclock_tempo (float bpm) if (tmap->n_tempos() == 1) { 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())) { + 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"; tmap->change_tempo (metric.get_editable_tempo(), Tempo (bpm, 4.0, bpm)); TempoMap::update (tmap); return;