2 Copyright (C) 2008 Hans Baier
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "midi++/jack.h"
23 #include "pbd/signals.h"
25 #include "ardour/types.h"
26 #include "ardour/session_handle.h"
37 class Ticker : public SessionHandlePtr
44 const nframes_t& transport_frames,
45 const BBT_Time& transport_bbt,
46 const Timecode::Time& transport_timecode) = 0;
48 void set_session (Session* s);
51 class MidiClockTicker : public Ticker
55 MidiClockTicker() : _midi_port(0), _ppqn(24), _last_tick(0.0) {};
56 MidiClockTicker( const MidiClockTicker& );
57 MidiClockTicker& operator= (const MidiClockTicker&);
60 virtual ~MidiClockTicker() {};
62 static MidiClockTicker& instance() {
63 static MidiClockTicker _instance;
68 const nframes_t& transport_frames,
69 const BBT_Time& transport_bbt,
70 const Timecode::Time& transport_timecode);
72 void set_session (Session* s);
73 void session_going_away();
75 /// slot for the signal session::MIDIClock_PortChanged
76 void update_midi_clock_port();
78 /// slot for the signal session::TransportStateChange
79 void transport_state_changed();
81 /// slot for the signal session::PositionChanged
82 void position_changed(nframes_t position);
84 /// slot for the signal session::TransportLooped
85 void transport_looped();
87 /// pulses per quarter note (default 24)
88 void set_ppqn(int ppqn) { _ppqn = ppqn; }
91 MIDI::Port* _midi_port;
95 double one_ppqn_in_frames(nframes_t transport_position);
97 void send_midi_clock_event(nframes_t offset);
98 void send_start_event(nframes_t offset);
99 void send_continue_event(nframes_t offset);
100 void send_stop_event(nframes_t offset);
105 #endif /* TICKER_H_ */