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.
21 #include <sigc++/sigc++.h>
23 #include "ardour/types.h"
24 #include "midi++/jack.h"
34 class Ticker : public sigc::trackable
37 Ticker() : _session(0) {};
41 const nframes_t& transport_frames,
42 const BBT_Time& transport_bbt,
43 const Timecode::Time& transport_timecode) = 0;
45 virtual void set_session(Session& s);
46 virtual void going_away() { _session = 0; }
52 class MidiClockTicker : public Ticker
56 MidiClockTicker() : _midi_port(0), _ppqn(24), _last_tick(0.0) {};
57 MidiClockTicker( const MidiClockTicker& );
58 MidiClockTicker& operator= (const MidiClockTicker&);
61 virtual ~MidiClockTicker() {};
63 static MidiClockTicker& instance() {
64 static MidiClockTicker _instance;
69 const nframes_t& transport_frames,
70 const BBT_Time& transport_bbt,
71 const Timecode::Time& transport_timecode);
73 void set_session(Session& s);
74 void going_away() { _midi_port = 0; Ticker::going_away(); }
76 /// slot for the signal session::MIDIClock_PortChanged
77 void update_midi_clock_port();
79 /// slot for the signal session::TransportStateChange
80 void transport_state_changed();
82 /// slot for the signal session::PositionChanged
83 void position_changed(nframes_t position);
85 /// slot for the signal session::TransportLooped
86 void transport_looped();
88 /// pulses per quarter note (default 24)
89 void set_ppqn(int ppqn) { _ppqn = ppqn; }
92 MIDI::Port* _midi_port;
96 double one_ppqn_in_frames(nframes_t transport_position);
98 void send_midi_clock_event(nframes_t offset);
99 void send_start_event(nframes_t offset);
100 void send_continue_event(nframes_t offset);
101 void send_stop_event(nframes_t offset);
106 #endif /* TICKER_H_ */