diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2018-10-08 12:59:51 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2018-10-08 12:59:51 -0400 |
commit | 970c8939d4db7683ad294f9fb7ae0db39fc696fd (patch) | |
tree | 0dc0c3bd7385e8e19618e388678a66e56f3cf2d0 /libs/ardour/midi_clock_slave.cc | |
parent | 8b1c8bb51137c13fb052b685b02b6e8130d6a668 (diff) |
some rather simple code to allow MIDI Clock to set the tempo of the session.
This is only allowed if the session has only 1 tempo marker
Diffstat (limited to 'libs/ardour/midi_clock_slave.cc')
-rw-r--r-- | libs/ardour/midi_clock_slave.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libs/ardour/midi_clock_slave.cc b/libs/ardour/midi_clock_slave.cc index d714eecac1..706032887d 100644 --- a/libs/ardour/midi_clock_slave.cc +++ b/libs/ardour/midi_clock_slave.cc @@ -36,6 +36,7 @@ #include "ardour/session.h" #include "ardour/tempo.h" #include "ardour/transport_master.h" +#include "ardour/transport_master_manager.h" #include "pbd/i18n.h" @@ -219,7 +220,6 @@ MIDIClock_TransportMaster::update_midi_clock (Parser& /*parser*/, samplepos_t ti const double samples_per_quarter = (timestamp - current.timestamp) * 24.0; const double instantaneous_bpm = (ENGINE->sample_rate() * 60.0) / samples_per_quarter; - const double lpf_coeff = 0.05; const double predicted_clock_interval_in_samples = (t1 - t0); @@ -233,6 +233,8 @@ MIDIClock_TransportMaster::update_midi_clock (Parser& /*parser*/, samplepos_t ti * change of more than 20% of the current tempo. */ + const double lpf_coeff = 0.063; + if (fabs (instantaneous_bpm - _bpm) > (0.20 * _bpm)) { _bpm = instantaneous_bpm; } else { @@ -250,6 +252,10 @@ MIDIClock_TransportMaster::update_midi_clock (Parser& /*parser*/, samplepos_t ti midi_clock_count++; current.update (current.position + one_ppqn_in_samples, timestamp, speed); + + if (TransportMasterManager::instance().current().get() == this) { + _session->maybe_update_tempo_from_midiclock_tempo (_bpm); + } } DEBUG_TRACE (DEBUG::MidiClock, string_compose ("clock #%1 @ %2 should-be %3 transport %4 error %5 appspeed %6 " |