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 bool send_enabled () const { return _enable_send; }
103 void send (MachineControlCommand const &);
105 static bool is_mmc (byte *sysex_buf, size_t len);
107 /* Signals to connect to if you want to run "callbacks"
108 when certain MMC commands are received.
113 MMCSignal DeferredPlay;
114 MMCSignal FastForward;
116 MMCSignal RecordStrobe;
117 MMCSignal RecordExit;
118 MMCSignal RecordPause;
122 MMCSignal CommandErrorReset;
127 MMCSignal MaskedWrite;
130 MMCSignal VariablePlay;
132 MMCSignal AssignSystemMaster;
133 MMCSignal GeneratorCommand;
134 MMCSignal MidiTimeCodeCommand;
138 MMCSignal DropFrameAdjust;
142 MMCSignal CommandSegment;
143 MMCSignal DeferredVariablePlay;
144 MMCSignal RecordStrobeVariable;
148 PBD::Signal0<void> SPPStart;
149 PBD::Signal0<void> SPPContinue;
150 PBD::Signal0<void> SPPStop;
152 /* The second argument is the shuttle speed, the third is
153 true if the direction is "forwards", false for "reverse"
156 PBD::Signal3<void,MachineControl&,float,bool> Shuttle;
158 /* The second argument specifies the desired track record enabled
162 PBD::Signal3<void,MachineControl &,size_t,bool>
163 TrackRecordStatusChange;
165 /* The second argument specifies the desired track record enabled
169 PBD::Signal3<void,MachineControl &,size_t,bool>
172 /* The second argument points to a byte array containing
173 the locate target value in MMC Standard Time Code
174 format (5 bytes, roughly: hrs/mins/secs/frames/subframes)
177 PBD::Signal2<void,MachineControl &, const byte *> Locate;
179 /* The second argument is the number of steps to jump */
181 PBD::Signal2<void,MachineControl &, int> Step;
183 #define MMC_NTRACKS 48
185 /* note: these are not currently in use */
190 byte commandErrorLevel;
192 byte motionControlTally;
198 bool trackRecordStatus[MMC_NTRACKS];
199 bool trackRecordReady[MMC_NTRACKS];
202 byte trackSyncMonitor;
203 byte trackInputMonitor;
205 byte playSpeedReference;
209 byte trackMute[MMC_NTRACKS];
211 byte selectedTimeCode;
212 byte shortSelectedTimeCode;
214 byte selectedTimeCodeSource;
215 byte selectedTimeCodeUserbits;
216 byte selectedMasterCode;
217 byte requestedOffset;
220 byte shortSelectedMasterCode;
221 byte shortRequestedOffset;
222 byte shortActualOffset;
223 byte shortLockDeviation;
224 byte resolvedPlayMode;
226 byte generatorTimeCode;
227 byte shortGeneratorTimeCode;
228 byte generatorCommandTally;
230 byte generatorUserbits;
231 byte vitcInsertEnable;
232 byte midiTimeCodeInput;
233 byte shortMidiTimeCodeInput;
234 byte midiTimeCodeCommandTally;
235 byte midiTimeCodeSetUp;
252 byte procedureResponse;
254 byte responseSegment;
259 byte _receive_device_id;
260 byte _send_device_id;
263 bool _enable_send; ///< true if MMC sending is enabled
265 void process_mmc_message (Parser &p, byte *, size_t len);
266 PBD::ScopedConnectionList port_connections; ///< connections to our parser for incoming data
268 int do_masked_write (byte *, size_t len);
269 int do_locate (byte *, size_t len);
270 int do_step (byte *, size_t len);
271 int do_shuttle (byte *, size_t len);
273 void write_track_status (byte *, size_t len, byte reg);
275 void spp_continue ();
279 /** Class to describe a MIDI machine control command to be sent.
280 * In an ideal world we might use a class hierarchy for this, but objects of this type
281 * have to be allocated off the stack for RT safety.
283 class MachineControlCommand
286 MachineControlCommand () : _command (MachineControl::Command (0)) {}
287 MachineControlCommand (MachineControl::Command);
288 MachineControlCommand (Timecode::Time);
290 MIDI::byte* fill_buffer (MachineControl *mmc, MIDI::byte *) const;
293 MachineControl::Command _command;
294 Timecode::Time _time;
299 #endif /* __midipp_mmc_h_h__ */