MIDI Clock - Shuffling locate code (not actually used yet)
[ardour.git] / libs / ardour / ardour / ticker.h
1 /*
2     Copyright (C) 2008 Hans Baier
3
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.
8
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.
13
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.
17
18     $Id$
19 */
20
21 #include <boost/noncopyable.hpp>
22
23 #include "pbd/signals.h"
24
25 #include "ardour/types.h"
26 #include "ardour/session_handle.h"
27
28
29 #ifndef TICKER_H_
30 #define TICKER_H_
31
32 namespace MIDI {
33         class Port;
34 }
35
36 namespace ARDOUR
37 {
38
39 class Session;
40
41 class MidiClockTicker : public SessionHandlePtr, boost::noncopyable
42 {
43 public:
44         MidiClockTicker ();
45         virtual ~MidiClockTicker();
46
47         void tick (const framepos_t& transport_frames);
48
49         bool has_midi_port() const { return _midi_port != 0; }
50
51         void set_session (Session* s);
52         void session_going_away();
53
54         /// slot for the signal session::MIDIClock_PortChanged
55         void update_midi_clock_port();
56
57         /// slot for the signal session::TransportStateChange
58         void transport_state_changed();
59
60         /// slot for the signal session::PositionChanged
61         void position_changed (framepos_t position);
62
63         /// slot for the signal session::TransportLooped
64         void transport_looped();
65
66         /// slot for the signal session::Located
67         void session_located();
68
69         /// pulses per quarter note (default 24)
70         void set_ppqn(int ppqn) { _ppqn = ppqn; }
71
72 private:
73         MIDI::Port*  _midi_port;
74         int          _ppqn;
75         double       _last_tick;
76
77         class Position;
78         Position* _pos;
79
80         double one_ppqn_in_frames (framepos_t transport_position);
81
82         void send_midi_clock_event (pframes_t offset);
83         void send_start_event (pframes_t offset);
84         void send_continue_event (pframes_t offset);
85         void send_stop_event (pframes_t offset);
86         void send_position_event (framepos_t transport_position, pframes_t offset);
87 };
88
89 }
90
91 #endif /* TICKER_H_ */