2 Copyright (C) 2002 Paul Davis
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.
20 #ifndef __ardour_slave_h__
21 #define __ardour_slave_h__
25 #include <jack/jack.h>
27 #include <sigc++/signal.h>
28 #include <ardour/ardour.h>
29 #include <midi++/parser.h>
30 #include <midi++/types.h>
44 virtual bool speed_and_position (float&, nframes_t&) = 0;
45 virtual bool locked() const = 0;
46 virtual bool ok() const = 0;
47 virtual bool starting() const { return false; }
48 virtual nframes_t resolution() const = 0;
49 virtual bool requires_seekahead () const = 0;
50 virtual bool is_always_synced() const { return false; }
66 class MTC_Slave : public Slave, public sigc::trackable {
68 MTC_Slave (Session&, MIDI::Port&);
71 void rebind (MIDI::Port&);
72 bool speed_and_position (float&, nframes_t&);
76 void handle_locate (const MIDI::byte*);
78 nframes_t resolution() const;
79 bool requires_seekahead () const { return true; }
84 std::vector<sigc::connection> connections;
85 bool can_notify_on_unknown_rate;
88 nframes_t mtc_frame; /* current time */
89 nframes_t last_inbound_frame; /* when we got it; audio clocked */
92 nframes_t first_mtc_frame;
93 nframes_t first_mtc_time;
95 static const int32_t accumulator_size = 128;
96 float accumulator[accumulator_size];
97 int32_t accumulator_index;
98 bool have_first_accumulated_speed;
101 void update_mtc_qtr (MIDI::Parser&);
102 void update_mtc_time (const MIDI::byte *, bool);
103 void update_mtc_status (MIDI::Parser::MTC_Status);
104 void read_current (SafeTime *) const;
107 class MIDIClock_Slave : public Slave, public sigc::trackable {
109 MIDIClock_Slave (Session&, MIDI::Port&, int ppqn = 24);
112 void rebind (MIDI::Port&);
113 bool speed_and_position (float&, nframes_t&);
117 bool starting() const { return _starting; }
119 nframes_t resolution() const;
120 bool requires_seekahead () const { return true; }
125 std::vector<sigc::connection> connections;
128 double one_ppqn_in_frames;
131 nframes_t midi_clock_frame; /* current time */
132 nframes_t last_inbound_frame; /* when we got it; audio clocked */
134 float midi_clock_speed;
135 nframes_t first_midi_clock_frame;
136 nframes_t first_midi_clock_time;
138 static const int32_t accumulator_size = 128;
139 float accumulator[accumulator_size];
140 int32_t accumulator_index;
141 bool have_first_accumulated_speed;
144 void start (MIDI::Parser& parser);
145 void stop (MIDI::Parser& parser);
146 void update_midi_clock (MIDI::Parser& parser);
147 void read_current (SafeTime *) const;
152 class ADAT_Slave : public Slave
158 bool speed_and_position (float& speed, nframes_t& pos) {
164 bool locked() const { return false; }
165 bool ok() const { return false; }
166 nframes_t resolution() const { return 1; }
167 bool requires_seekahead () const { return true; }
170 class JACK_Slave : public Slave
173 JACK_Slave (jack_client_t*);
176 bool speed_and_position (float& speed, nframes_t& pos);
178 bool starting() const { return _starting; }
181 nframes_t resolution() const { return 1; }
182 bool requires_seekahead () const { return false; }
183 void reset_client (jack_client_t* jack);
184 bool is_always_synced() const { return true; }
194 #endif /* __ardour_slave_h__ */