midi clock: allow user to "quantize" MIDI clock resolution
This commit is contained in:
parent
866876c903
commit
e430d13d53
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user