32 #include "ardour/debug.h"
42 Position() : speed(0.0
f), frame(0), midi_beats(0) { }
74 const double qnote_scale = divisor * 0.25f;
81 mb = (((bars - 1) * divisions) + beats - 1);
82 mb += (double)ticks / (
double)Position::ticks_per_beat * qnote_scale;
83 mb *= 16.0f / divisor;
85 if (mb != midi_beats) {
87 midi_clocks = midi_beats * 6.0f;
100 s <<
"frames: " << frame <<
" midi beats: " << midi_beats <<
" speed: " << speed;
109 , _send_state (false)
145 if (!
Config->get_send_midi_clock()) {
183 string_compose (
"Transport state change @ %4, speed: %1 position: %2 play loop: %3\n",
189 if (!
Config->get_send_midi_clock()) {
202 assert(loop_location);
205 string_compose (
"Transport looped, position: %1, loop start: %2, loop end: %3, play loop: %4\n",
214 if (loop_location->
start() > elapsed_since_last_tick) {
229 if (
_pos->speed == 0.0f) {
231 }
else if (
_pos->speed == 1.0f) {
234 if (
_pos->frame == 0) {
249 if (
_pos->speed == 1.0f) {
259 }
else if (
_pos->frame == 0) {
267 }
else if (
_pos->speed == 0.0f) {
285 double next_tick = iter + clock_delta;
289 string_compose (
"Tick: iter: %1, last tick time: %2, next tick time: %3, offset: %4, cycle length: %5\n",
290 iter,
_last_tick, next_tick, next_tick_offset, nframes));
292 if (next_tick_offset >= nframes) {
296 if (next_tick_offset >= 0) {
313 double quarter_notes_per_beat = 4.0 / current_tempo.
note_type();
314 double frames_per_quarter_note = frames_per_beat / quarter_notes_per_beat;
316 return frames_per_quarter_note / double (
_ppqn);
384 if (midi_beats > 0x3fff) {
391 msg[1] = midi_beats & 0x007f;
392 msg[2] = midi_beats >> 7;
boost::shared_ptr< MidiPort > _midi_port
framecnt_t nominal_frame_rate() const
#define MIDI_CMD_COMMON_CLOCK
PBD::Signal0< void > TransportStateChange
virtual void session_going_away()
Location * auto_loop_location() const
double transport_speed() const
bool get_play_loop() const
void session_located()
slot for the signal session::Located
PBD::Signal0< void > Located
PBD::Signal0< void > TransportLooped
void session_going_away()
void transport_state_changed()
slot for the signal session::TransportStateChange
#define MIDI_CMD_COMMON_SONG_POS
void update_midi_clock_port()
slot for the signal session::MIDIClock_PortChanged
void transport_looped()
slot for the signal session::TransportLooped
const Meter & meter_at(framepos_t) const
double frames_per_beat(framecnt_t sr) const
#define MIDI_CMD_COMMON_CONTINUE
void send_start_event(pframes_t offset, pframes_t nframes)
LIBARDOUR_API RCConfiguration * Config
framepos_t transport_frame() const
void send_stop_event(pframes_t offset, pframes_t nframes)
#define DEBUG_TRACE(bits, str)
void send_continue_event(pframes_t offset, pframes_t nframes)
PBD::ScopedConnectionList _session_connections
double note_divisor() const
LIBARDOUR_API uint64_t MidiClock
void tick(const framepos_t &transport_frames, pframes_t nframes)
#define MIDI_CMD_COMMON_START
double one_ppqn_in_frames(framepos_t transport_position)
bool push_back(const Evoral::MIDIEvent< TimeType > &event)
void set_session(Session *s)
double divisions_per_bar() const
void print(std::ostream &s)
virtual void set_session(ARDOUR::Session *)
#define MIDI_CMD_COMMON_STOP
void send_midi_clock_event(pframes_t offset, pframes_t nframes)
void bbt_time(framepos_t when, Timecode::BBT_Time &)
ARDOUR::Session * _session
const Tempo & tempo_at(framepos_t) const
void send_position_event(uint32_t midi_clocks, pframes_t offset, pframes_t nframes)
boost::scoped_ptr< Position > _pos
std::string string_compose(const std::string &fmt, const T1 &o1)
virtual ~MidiClockTicker()
boost::shared_ptr< MidiPort > midi_clock_output_port() const