using namespace MIDI;
using namespace PBD;
+#define DEBUG_MIDI_CLOCK 1
+
MIDIClock_Slave::MIDIClock_Slave (Session& s, MIDI::Port& p, int ppqn)
: ppqn (ppqn)
- , bandwidth (30.0 / 60.0) // 1 BpM = 1 / 60 Hz
+ , bandwidth (1.0 / 60.0) // 1 BpM = 1 / 60 Hz
{
session = (ISlaveSessionProxy *) new SlaveSessionProxy(s);
rebind (p);
MIDIClock_Slave::MIDIClock_Slave (ISlaveSessionProxy* session_proxy, int ppqn)
: session(session_proxy)
, ppqn (ppqn)
- , bandwidth (30.0 / 60.0) // 1 BpM = 1 / 60 Hz
+ , bandwidth (1.0 / 60.0) // 1 BpM = 1 / 60 Hz
{
- session = session_proxy;
reset ();
}
<< " frame-rate: " << session->frame_rate()
<< endl;
- cerr << "frames since cycle start: " << session->frames_since_cycle_start() << endl;
+ //cerr << "frames since cycle start: " << session->frames_since_cycle_start() << endl;
#endif // DEBUG_MIDI_CLOCK
last_timestamp = timestamp;
}
void
-MIDIClock_Slave::start (Parser& /*parser*/, nframes64_t /*timestamp*/)
+MIDIClock_Slave::start (Parser& /*parser*/, nframes64_t timestamp)
{
#ifdef DEBUG_MIDI_CLOCK
cerr << "MIDIClock_Slave got start message at time " << timestamp << " engine time: " << session->frame_time() << endl;
_starting = false;
_started = false;
- session->request_locate(0, false);
+ if (session) session->request_locate(0, false);
}
void
// calculate speed
speed = ((t1 - t0) * session->frame_rate()) / one_ppqn_in_frames;
+
+ // provide a 3% deadzone to lock the speed
+ if (fabs(speed - 1.0) <= 0.03)
+ speed = 1.0;
// calculate position
if (engine_now > last_timestamp) {