2 Copyright (C) 2000 Paul Barton-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 __midipp_mmc_h_h__
21 #define __midipp_mmc_h_h__
23 #include <jack/types.h>
24 #include "timecode/time.h"
25 #include "pbd/signals.h"
26 #include "pbd/ringbuffer.h"
27 #include "midi++/types.h"
28 #include "midi++/parser.h"
34 class MachineControlCommand;
37 /** Class to handle incoming and outgoing MIDI machine control messages */
41 typedef PBD::Signal1<void,MachineControl&> MMCSignal;
46 cmdDeferredPlay = 0x3,
49 cmdRecordStrobe = 0x6,
56 cmdCommandErrorReset = 0xC,
59 cmdIllegalMackieJogStart = 0x20,
60 cmdIllegalMackieJogStop = 0x21,
63 cmdMaskedWrite = 0x41,
67 cmdVariablePlay = 0x45,
72 cmdAssignSystemMaster = 0x49,
73 cmdGeneratorCommand = 0x4A,
79 cmdDropFrameAdjust = 0x4F,
83 cmdCommandSegment = 0x53,
84 cmdDeferredVariablePlay = 0x54,
86 cmdRecordStrobeVariable = 0x55,
92 MachineControl (Manager *, jack_client_t *);
94 Port* input_port() { return _input_port; }
95 Port* output_port() { return _output_port; }
97 void set_receive_device_id (byte id);
98 void set_send_device_id (byte id);
99 byte receive_device_id () const { return _receive_device_id; }
100 byte send_device_id () const { return _send_device_id; }
101 void enable_send (bool);
102 void send (MachineControlCommand const &);
104 static bool is_mmc (byte *sysex_buf, size_t len);
106 /* Signals to connect to if you want to run "callbacks"
107 when certain MMC commands are received.
112 MMCSignal DeferredPlay;
113 MMCSignal FastForward;
115 MMCSignal RecordStrobe;
116 MMCSignal RecordExit;
117 MMCSignal RecordPause;
121 MMCSignal CommandErrorReset;
126 MMCSignal MaskedWrite;
129 MMCSignal VariablePlay;
131 MMCSignal AssignSystemMaster;
132 MMCSignal GeneratorCommand;
133 MMCSignal MidiTimeCodeCommand;
137 MMCSignal DropFrameAdjust;
141 MMCSignal CommandSegment;
142 MMCSignal DeferredVariablePlay;
143 MMCSignal RecordStrobeVariable;
147 TimestampedSignal SPPStart;
148 TimestampedSignal SPPContinue;
149 TimestampedSignal SPPStop;
151 /* The second argument is the shuttle speed, the third is
152 true if the direction is "forwards", false for "reverse"
155 PBD::Signal3<void,MachineControl&,float,bool> Shuttle;
157 /* The second argument specifies the desired track record enabled
161 PBD::Signal3<void,MachineControl &,size_t,bool>
162 TrackRecordStatusChange;
164 /* The second argument specifies the desired track record enabled
168 PBD::Signal3<void,MachineControl &,size_t,bool>
171 /* The second argument points to a byte array containing
172 the locate target value in MMC Standard Time Code
173 format (5 bytes, roughly: hrs/mins/secs/frames/subframes)
176 PBD::Signal2<void,MachineControl &, const byte *> Locate;
178 /* The second argument is the number of steps to jump */
180 PBD::Signal2<void,MachineControl &, int> Step;
182 #define MMC_NTRACKS 48
184 /* note: these are not currently in use */
189 byte commandErrorLevel;
191 byte motionControlTally;
197 bool trackRecordStatus[MMC_NTRACKS];
198 bool trackRecordReady[MMC_NTRACKS];
201 byte trackSyncMonitor;
202 byte trackInputMonitor;
204 byte playSpeedReference;
208 byte trackMute[MMC_NTRACKS];
210 byte selectedTimeCode;
211 byte shortSelectedTimeCode;
213 byte selectedTimeCodeSource;
214 byte selectedTimeCodeUserbits;
215 byte selectedMasterCode;
216 byte requestedOffset;
219 byte shortSelectedMasterCode;
220 byte shortRequestedOffset;
221 byte shortActualOffset;
222 byte shortLockDeviation;
223 byte resolvedPlayMode;
225 byte generatorTimeCode;
226 byte shortGeneratorTimeCode;
227 byte generatorCommandTally;
229 byte generatorUserbits;
230 byte vitcInsertEnable;
231 byte midiTimeCodeInput;
232 byte shortMidiTimeCodeInput;
233 byte midiTimeCodeCommandTally;
234 byte midiTimeCodeSetUp;
251 byte procedureResponse;
253 byte responseSegment;
258 byte _receive_device_id;
259 byte _send_device_id;
262 bool _enable_send; ///< true if MMC sending is enabled
264 void process_mmc_message (Parser &p, byte *, size_t len);
265 PBD::ScopedConnectionList port_connections; ///< connections to our parser for incoming data
267 int do_masked_write (byte *, size_t len);
268 int do_locate (byte *, size_t len);
269 int do_step (byte *, size_t len);
270 int do_shuttle (byte *, size_t len);
272 void write_track_status (byte *, size_t len, byte reg);
273 void spp_start (Parser&, framecnt_t);
274 void spp_continue (Parser&, framecnt_t);
275 void spp_stop (Parser&, framecnt_t);
278 /** Class to describe a MIDI machine control command to be sent.
279 * In an ideal world we might use a class hierarchy for this, but objects of this type
280 * have to be allocated off the stack for RT safety.
282 class MachineControlCommand
285 MachineControlCommand () : _command (MachineControl::Command (0)) {}
286 MachineControlCommand (MachineControl::Command);
287 MachineControlCommand (Timecode::Time);
289 MIDI::byte* fill_buffer (MachineControl *mmc, MIDI::byte *) const;
292 MachineControl::Command _command;
293 Timecode::Time _time;
298 #endif /* __midipp_mmc_h_h__ */