X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fticker.cc;h=e02143e401f1764b8be388e4109e579df11e313e;hb=8882ef79d3b4a536daa00e3a20e2c50e0c49bbe8;hp=15326af88242485d28c2122098f7e7719b3aac49;hpb=3f75d7884877fddbf73e1623e3a1bc3fe7ba5643;p=ardour.git diff --git a/libs/ardour/ticker.cc b/libs/ardour/ticker.cc index 15326af882..e02143e401 100644 --- a/libs/ardour/ticker.cc +++ b/libs/ardour/ticker.cc @@ -25,6 +25,7 @@ #include "ardour/audioengine.h" #include "ardour/midi_buffer.h" #include "ardour/midi_port.h" +#include "ardour/lmath.h" #include "ardour/ticker.h" #include "ardour/session.h" #include "ardour/tempo.h" @@ -40,18 +41,18 @@ public: Position() : speed(0.0f), frame(0), midi_beats(0) { } ~Position() { } - + /** Sync timing information taken from the given Session - * @return True if timings differed + * @return True if timings differed */ bool sync (Session* s) { bool changed = false; - + double sp = s->transport_speed(); framecnt_t fr = s->transport_frame(); - + if (speed != sp) { speed = sp; changed = true; @@ -74,7 +75,7 @@ public: double mb; /** Midi Beats in terms of Song Position Pointer is equivalent to total - * sixteenth notes at 'time' + * sixteenth notes at 'time' */ mb = (((bars - 1) * divisions) + beats - 1); @@ -94,7 +95,7 @@ public: framecnt_t frame; double midi_beats; double midi_clocks; - + void print (std::ostream& s) { s << "frames: " << frame << " midi beats: " << midi_beats << " speed: " << speed; } @@ -119,7 +120,7 @@ void MidiClockTicker::set_session (Session* s) { SessionHandlePtr::set_session (s); - + if (_session) { _session->TransportStateChange.connect_same_thread (_session_connections, boost::bind (&MidiClockTicker::transport_state_changed, this)); _session->TransportLooped.connect_same_thread (_session_connections, boost::bind (&MidiClockTicker::transport_looped, this)); @@ -229,7 +230,7 @@ MidiClockTicker::tick (const framepos_t& /* transport_frame */, pframes_t nframe send_position_event (llrint (_pos->midi_beats), 0, nframes); } else if (_pos->speed == 1.0f) { send_stop_event (0, nframes); - + if (_pos->frame == 0) { send_start_event (0, nframes); } else { @@ -248,21 +249,21 @@ MidiClockTicker::tick (const framepos_t& /* transport_frame */, pframes_t nframe if (_pos->speed == 1.0f) { if (_session->get_play_loop()) { assert(_session->locations()->auto_loop_location()); - + if (_pos->frame == _session->locations()->auto_loop_location()->start()) { send_start_event (0, nframes); } else { send_continue_event (0, nframes); } - + } else if (_pos->frame == 0) { send_start_event (0, nframes); } else { send_continue_event (0, nframes); } - + // send_midi_clock_event (0); - + } else if (_pos->speed == 0.0f) { send_stop_event (0, nframes); send_position_event (llrint (_pos->midi_beats), 0, nframes);