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 "control_protocol/timecode.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* output_port() { return _output_port; }
96 void set_receive_device_id (byte id);
97 void set_send_device_id (byte id);
98 byte receive_device_id () const { return _receive_device_id; }
99 byte send_device_id () const { return _send_device_id; }
100 void enable_send (bool);
101 void send (MachineControlCommand const &);
103 static bool is_mmc (byte *sysex_buf, size_t len);
105 /* Signals to connect to if you want to run "callbacks"
106 when certain MMC commands are received.
111 MMCSignal DeferredPlay;
112 MMCSignal FastForward;
114 MMCSignal RecordStrobe;
115 MMCSignal RecordExit;
116 MMCSignal RecordPause;
120 MMCSignal CommandErrorReset;
125 MMCSignal MaskedWrite;
128 MMCSignal VariablePlay;
130 MMCSignal AssignSystemMaster;
131 MMCSignal GeneratorCommand;
132 MMCSignal MidiTimeCodeCommand;
136 MMCSignal DropFrameAdjust;
140 MMCSignal CommandSegment;
141 MMCSignal DeferredVariablePlay;
142 MMCSignal RecordStrobeVariable;
146 TimestampedSignal SPPStart;
147 TimestampedSignal SPPContinue;
148 TimestampedSignal SPPStop;
150 /* The second argument is the shuttle speed, the third is
151 true if the direction is "forwards", false for "reverse"
154 PBD::Signal3<void,MachineControl&,float,bool> Shuttle;
156 /* The second argument specifies the desired track record enabled
160 PBD::Signal3<void,MachineControl &,size_t,bool>
161 TrackRecordStatusChange;
163 /* The second argument specifies the desired track record enabled
167 PBD::Signal3<void,MachineControl &,size_t,bool>
170 /* The second argument points to a byte array containing
171 the locate target value in MMC Standard Time Code
172 format (5 bytes, roughly: hrs/mins/secs/frames/subframes)
175 PBD::Signal2<void,MachineControl &, const byte *> Locate;
177 /* The second argument is the number of steps to jump */
179 PBD::Signal2<void,MachineControl &, int> Step;
181 #define MMC_NTRACKS 48
183 /* note: these are not currently in use */
188 byte commandErrorLevel;
190 byte motionControlTally;
196 bool trackRecordStatus[MMC_NTRACKS];
197 bool trackRecordReady[MMC_NTRACKS];
200 byte trackSyncMonitor;
201 byte trackInputMonitor;
203 byte playSpeedReference;
207 byte trackMute[MMC_NTRACKS];
209 byte selectedTimeCode;
210 byte shortSelectedTimeCode;
212 byte selectedTimeCodeSource;
213 byte selectedTimeCodeUserbits;
214 byte selectedMasterCode;
215 byte requestedOffset;
218 byte shortSelectedMasterCode;
219 byte shortRequestedOffset;
220 byte shortActualOffset;
221 byte shortLockDeviation;
222 byte resolvedPlayMode;
224 byte generatorTimeCode;
225 byte shortGeneratorTimeCode;
226 byte generatorCommandTally;
228 byte generatorUserbits;
229 byte vitcInsertEnable;
230 byte midiTimeCodeInput;
231 byte shortMidiTimeCodeInput;
232 byte midiTimeCodeCommandTally;
233 byte midiTimeCodeSetUp;
250 byte procedureResponse;
252 byte responseSegment;
257 byte _receive_device_id;
258 byte _send_device_id;
261 bool _enable_send; ///< true if MMC sending is enabled
263 void process_mmc_message (Parser &p, byte *, size_t len);
264 PBD::ScopedConnectionList port_connections; ///< connections to our parser for incoming data
266 int do_masked_write (byte *, size_t len);
267 int do_locate (byte *, size_t len);
268 int do_step (byte *, size_t len);
269 int do_shuttle (byte *, size_t len);
271 void write_track_status (byte *, size_t len, byte reg);
272 void spp_start (Parser&, nframes_t);
273 void spp_continue (Parser&, nframes_t);
274 void spp_stop (Parser&, nframes_t);
277 /** Class to describe a MIDI machine control command to be sent.
278 * In an ideal world we might use a class hierarchy for this, but objects of this type
279 * have to be allocated off the stack for RT safety.
281 class MachineControlCommand
284 MachineControlCommand () : _command (MachineControl::Command (0)) {}
285 MachineControlCommand (MachineControl::Command);
286 MachineControlCommand (Timecode::Time);
288 MIDI::byte* fill_buffer (MachineControl *mmc, MIDI::byte *) const;
291 MachineControl::Command _command;
292 Timecode::Time _time;
297 #endif /* __midipp_mmc_h_h__ */