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 "timecode/time.h"
25 #include "pbd/signals.h"
26 #include "pbd/ringbuffer.h"
28 #include "midi++/types.h"
29 #include "midi++/parser.h"
39 class MachineControlCommand;
41 /** Class to handle incoming and outgoing MIDI machine control messages */
45 typedef PBD::Signal1<void,MachineControl&> MMCSignal;
50 cmdDeferredPlay = 0x3,
53 cmdRecordStrobe = 0x6,
60 cmdCommandErrorReset = 0xC,
63 cmdIllegalMackieJogStart = 0x20,
64 cmdIllegalMackieJogStop = 0x21,
67 cmdMaskedWrite = 0x41,
71 cmdVariablePlay = 0x45,
76 cmdAssignSystemMaster = 0x49,
77 cmdGeneratorCommand = 0x4A,
83 cmdDropFrameAdjust = 0x4F,
87 cmdCommandSegment = 0x53,
88 cmdDeferredVariablePlay = 0x54,
90 cmdRecordStrobeVariable = 0x55,
98 void set_ports (MIDI::Port* input, MIDI::Port* output);
100 Port* input_port() { return _input_port; }
101 Port* output_port() { return _output_port; }
103 void set_receive_device_id (byte id);
104 void set_send_device_id (byte id);
105 byte receive_device_id () const { return _receive_device_id; }
106 byte send_device_id () const { return _send_device_id; }
107 void enable_send (bool);
108 bool send_enabled () const { return _enable_send; }
109 void send (MachineControlCommand const &);
111 static bool is_mmc (byte *sysex_buf, size_t len);
113 /* Signals to connect to if you want to run "callbacks"
114 when certain MMC commands are received.
119 MMCSignal DeferredPlay;
120 MMCSignal FastForward;
122 MMCSignal RecordStrobe;
123 MMCSignal RecordExit;
124 MMCSignal RecordPause;
128 MMCSignal CommandErrorReset;
133 MMCSignal MaskedWrite;
136 MMCSignal VariablePlay;
138 MMCSignal AssignSystemMaster;
139 MMCSignal GeneratorCommand;
140 MMCSignal MidiTimeCodeCommand;
144 MMCSignal DropFrameAdjust;
148 MMCSignal CommandSegment;
149 MMCSignal DeferredVariablePlay;
150 MMCSignal RecordStrobeVariable;
154 PBD::Signal0<void> SPPStart;
155 PBD::Signal0<void> SPPContinue;
156 PBD::Signal0<void> SPPStop;
158 /* The second argument is the shuttle speed, the third is
159 true if the direction is "forwards", false for "reverse"
162 PBD::Signal3<void,MachineControl&,float,bool> Shuttle;
164 /* The second argument specifies the desired track record enabled
168 PBD::Signal3<void,MachineControl &,size_t,bool>
169 TrackRecordStatusChange;
171 /* The second argument specifies the desired track record enabled
175 PBD::Signal3<void,MachineControl &,size_t,bool>
178 /* The second argument points to a byte array containing
179 the locate target value in MMC Standard Time Code
180 format (5 bytes, roughly: hrs/mins/secs/frames/subframes)
183 PBD::Signal2<void,MachineControl &, const byte *> Locate;
185 /* The second argument is the number of steps to jump */
187 PBD::Signal2<void,MachineControl &, int> Step;
189 #define MMC_NTRACKS 48
191 /* note: these are not currently in use */
196 byte commandErrorLevel;
198 byte motionControlTally;
204 bool trackRecordStatus[MMC_NTRACKS];
205 bool trackRecordReady[MMC_NTRACKS];
208 byte trackSyncMonitor;
209 byte trackInputMonitor;
211 byte playSpeedReference;
215 byte trackMute[MMC_NTRACKS];
217 byte selectedTimeCode;
218 byte shortSelectedTimeCode;
220 byte selectedTimeCodeSource;
221 byte selectedTimeCodeUserbits;
222 byte selectedMasterCode;
223 byte requestedOffset;
226 byte shortSelectedMasterCode;
227 byte shortRequestedOffset;
228 byte shortActualOffset;
229 byte shortLockDeviation;
230 byte resolvedPlayMode;
232 byte generatorTimeCode;
233 byte shortGeneratorTimeCode;
234 byte generatorCommandTally;
236 byte generatorUserbits;
237 byte vitcInsertEnable;
238 byte midiTimeCodeInput;
239 byte shortMidiTimeCodeInput;
240 byte midiTimeCodeCommandTally;
241 byte midiTimeCodeSetUp;
258 byte procedureResponse;
260 byte responseSegment;
265 byte _receive_device_id;
266 byte _send_device_id;
269 bool _enable_send; ///< true if MMC sending is enabled
271 void process_mmc_message (Parser &p, byte *, size_t len);
272 PBD::ScopedConnectionList port_connections; ///< connections to our parser for incoming data
274 int do_masked_write (byte *, size_t len);
275 int do_locate (byte *, size_t len);
276 int do_step (byte *, size_t len);
277 int do_shuttle (byte *, size_t len);
279 void write_track_status (byte *, size_t len, byte reg);
281 void spp_continue ();
285 /** Class to describe a MIDI machine control command to be sent.
286 * In an ideal world we might use a class hierarchy for this, but objects of this type
287 * have to be allocated off the stack for RT safety.
289 class MachineControlCommand
292 MachineControlCommand () : _command (MachineControl::Command (0)) {}
293 MachineControlCommand (MachineControl::Command);
294 MachineControlCommand (Timecode::Time);
296 MIDI::byte* fill_buffer (MachineControl *mmc, MIDI::byte *) const;
299 MachineControl::Command _command;
300 Timecode::Time _time;
305 #endif /* __midipp_mmc_h_h__ */