Ardour  9.0-pre0-386-g96ef4d20f2
mmc.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2000-2017 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
4  * Copyright (C) 2009-2010 David Robillard <d@drobilla.net>
5  * Copyright (C) 2010-2012 Carl Hetherington <carl@carlh.net>
6  * Copyright (C) 2015-2019 Robin Gareus <robin@gareus.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #pragma once
24 
25 #include "temporal/time.h"
26 
27 #include "pbd/signals.h"
28 #include "pbd/ringbuffer.h"
29 
31 #include "midi++/types.h"
32 #include "midi++/parser.h"
33 
34 namespace ARDOUR {
35  class PortEngine;
36 }
37 
38 namespace MIDI {
39 
40 class Port;
41 class Parser;
42 class MachineControlCommand;
43 
46 {
47  public:
49 
50  enum Command {
51  cmdStop = 0x1,
52  cmdPlay = 0x2,
53  cmdDeferredPlay = 0x3,
54  cmdFastForward = 0x4,
55  cmdRewind = 0x5,
56  cmdRecordStrobe = 0x6,
57 
58  cmdRecordExit = 0x7,
59  cmdRecordPause = 0x8,
60  cmdPause = 0x9,
61  cmdEject = 0xA,
62  cmdChase = 0xB,
63  cmdCommandErrorReset = 0xC,
64  cmdMmcReset = 0xD,
65 
66  cmdIllegalMackieJogStart = 0x20,
67  cmdIllegalMackieJogStop = 0x21,
68 
69  cmdWrite = 0x40,
70  cmdMaskedWrite = 0x41,
71  cmdRead = 0x42,
72  cmdUpdate = 0x43,
73  cmdLocate = 0x44,
74  cmdVariablePlay = 0x45,
75  cmdSearch = 0x46,
76 
77  cmdShuttle = 0x47,
78  cmdStep = 0x48,
79  cmdAssignSystemMaster = 0x49,
80  cmdGeneratorCommand = 0x4A,
81  cmdMtcCommand = 0x4B,
82  cmdMove = 0x4C,
83  cmdAdd = 0x4D,
84 
85  cmdSubtract = 0x4E,
86  cmdDropFrameAdjust = 0x4F,
87  cmdProcedure = 0x50,
88  cmdEvent = 0x51,
89  cmdGroup = 0x52,
90  cmdCommandSegment = 0x53,
91  cmdDeferredVariablePlay = 0x54,
92 
93  cmdRecordStrobeVariable = 0x55,
94 
95  cmdWait = 0x7C,
96  cmdResume = 0x7F
97  };
98 
100 
101  void set_ports (MIDI::Port* input, MIDI::Port* output);
102 
103  Port* input_port() { return _input_port; }
104  Port* output_port() { return _output_port; }
105 
106  void set_receive_device_id (byte id);
107  void set_send_device_id (byte id);
108  byte receive_device_id () const { return _receive_device_id; }
109  byte send_device_id () const { return _send_device_id; }
110  void enable_send (bool);
111  bool send_enabled () const { return _enable_send; }
112  void send (MachineControlCommand const &, timestamp_t when);
113 
114  static bool is_mmc (byte *sysex_buf, size_t len);
115 
116  /* Signals to connect to if you want to run "callbacks"
117  when certain MMC commands are received.
118  */
119 
156 
160 
161  /* The second argument is the shuttle speed, the third is
162  true if the direction is "forwards", false for "reverse"
163  */
164 
165  PBD::Signal<void(MachineControl&,float,bool)> Shuttle;
166 
167  /* The second argument specifies the desired track record enabled
168  status.
169  */
170 
171  PBD::Signal<void(MachineControl &,size_t,bool)>
173 
174  /* The second argument specifies the desired track record enabled
175  status.
176  */
177 
178  PBD::Signal<void(MachineControl &,size_t,bool)>
180 
181  /* The second argument points to a byte array containing
182  the locate target value in MMC Standard Time Code
183  format (5 bytes, roughly: hrs/mins/secs/frames/subframes)
184  */
185 
186  PBD::Signal<void(MachineControl &, const byte *)> Locate;
187 
188  /* The second argument is the number of steps to jump */
189 
191 
192 #define MMC_NTRACKS 48
193 
194  /* note: these are not currently in use */
195 
200 
203  byte stopMode;
204  byte fastMode;
207  bool trackRecordStatus[MMC_NTRACKS];
208  bool trackRecordReady[MMC_NTRACKS];
218  byte trackMute[MMC_NTRACKS];
219  byte failure;
234  byte chaseMode;
245  byte gp0;
246  byte gp1;
247  byte gp2;
248  byte gp3;
249  byte gp4;
250  byte gp5;
251  byte gp6;
252  byte gp7;
253  byte shortGp0;
254  byte shortGp1;
255  byte shortGp2;
256  byte shortGp3;
257  byte shortGp4;
258  byte shortGp5;
259  byte shortGp6;
260  byte shortGp7;
264  byte wait;
265  byte resume;
266 
267  private:
273 
274  void process_mmc_message (Parser &p, byte *, size_t len);
276 
277  int do_masked_write (byte *, size_t len);
278  int do_locate (byte *, size_t len);
279  int do_step (byte *, size_t len);
280  int do_shuttle (byte *, size_t len);
281 
282  void write_track_status (byte *, size_t len, byte reg);
283  void spp_start ();
284  void spp_continue ();
285  void spp_stop ();
286 };
287 
293 {
294 public:
295  MachineControlCommand () : _command (MachineControl::Command (0)) {}
298 
300 
301 private:
304 };
305 
306 } // namespace MIDI
307 
MIDI::byte * fill_buffer(MachineControl *mmc, MIDI::byte *) const
MachineControlCommand(MachineControl::Command)
Timecode::Time _time
Definition: mmc.h:303
MachineControl::Command _command
Definition: mmc.h:302
MachineControlCommand(Timecode::Time)
byte selectedTimeCode
Definition: mmc.h:220
int do_shuttle(byte *, size_t len)
byte send_device_id() const
Definition: mmc.h:109
byte eventResponse
Definition: mmc.h:262
MMCSignal Search
Definition: mmc.h:140
byte responseError
Definition: mmc.h:197
PBD::Signal< void()> SPPStop
Definition: mmc.h:159
MMCSignal Pause
Definition: mmc.h:128
byte shortSelectedMasterCode
Definition: mmc.h:229
MMCSignal AssignSystemMaster
Definition: mmc.h:141
MMCSignal DropFrameAdjust
Definition: mmc.h:147
void write_track_status(byte *, size_t len, byte reg)
MMCSignal CommandErrorReset
Definition: mmc.h:131
byte generatorUserbits
Definition: mmc.h:239
byte commandError
Definition: mmc.h:198
byte trackSyncMonitor
Definition: mmc.h:211
bool send_enabled() const
Definition: mmc.h:111
byte shortMidiTimeCodeInput
Definition: mmc.h:242
MMCSignal Rewind
Definition: mmc.h:124
int do_locate(byte *, size_t len)
MMCSignal Update
Definition: mmc.h:138
void enable_send(bool)
MMCSignal MmcReset
Definition: mmc.h:132
byte trackInputMonitor
Definition: mmc.h:212
bool _enable_send
true if MMC sending is enabled
Definition: mmc.h:272
byte velocityTally
Definition: mmc.h:202
MMCSignal MidiTimeCodeCommand
Definition: mmc.h:143
byte recordStatus
Definition: mmc.h:206
PBD::Signal< void()> SPPContinue
Definition: mmc.h:158
MMCSignal Subtract
Definition: mmc.h:146
MMCSignal FastForward
Definition: mmc.h:123
PBD::Signal< void()> SPPStart
Definition: mmc.h:157
byte commandErrorLevel
Definition: mmc.h:199
PBD::Signal< void(MachineControl &)> MMCSignal
Definition: mmc.h:48
byte procedureResponse
Definition: mmc.h:261
PBD::Signal< void(MachineControl &, int)> Step
Definition: mmc.h:190
MMCSignal VariablePlay
Definition: mmc.h:139
byte selectedTimeCodeUserbits
Definition: mmc.h:224
byte selectedMasterCode
Definition: mmc.h:225
byte actualOffset
Definition: mmc.h:227
void set_ports(MIDI::Port *input, MIDI::Port *output)
Port * input_port()
Definition: mmc.h:103
MMCSignal CommandSegment
Definition: mmc.h:151
byte _receive_device_id
Definition: mmc.h:268
byte globalMonitor
Definition: mmc.h:209
PBD::Signal< void(MachineControl &, const byte *)> Locate
Definition: mmc.h:186
MMCSignal MaskedWrite
Definition: mmc.h:136
byte generatorTimeCode
Definition: mmc.h:235
byte playSpeedReference
Definition: mmc.h:214
PBD::Signal< void(MachineControl &, size_t, bool)> TrackMuteChange
Definition: mmc.h:179
byte recordMonitor
Definition: mmc.h:210
byte shortSelectedTimeCode
Definition: mmc.h:221
MMCSignal RecordStrobe
Definition: mmc.h:125
MMCSignal Eject
Definition: mmc.h:129
byte requestedOffset
Definition: mmc.h:226
MMCSignal Write
Definition: mmc.h:135
byte motionControlTally
Definition: mmc.h:201
MMCSignal Chase
Definition: mmc.h:130
static bool is_mmc(byte *sysex_buf, size_t len)
byte timeStandard
Definition: mmc.h:222
byte _send_device_id
Definition: mmc.h:269
MMCSignal RecordPause
Definition: mmc.h:127
MMCSignal GeneratorCommand
Definition: mmc.h:142
byte shortGeneratorTimeCode
Definition: mmc.h:236
byte receive_device_id() const
Definition: mmc.h:108
MMCSignal Play
Definition: mmc.h:121
Port * _output_port
Definition: mmc.h:271
void set_send_device_id(byte id)
byte lifterDefeat
Definition: mmc.h:216
byte shortLockDeviation
Definition: mmc.h:232
PBD::ScopedConnectionList port_connections
connections to our parser for incoming data
Definition: mmc.h:275
byte controlDisable
Definition: mmc.h:217
byte responseSegment
Definition: mmc.h:263
Port * output_port()
Definition: mmc.h:104
int do_masked_write(byte *, size_t len)
byte midiTimeCodeInput
Definition: mmc.h:241
MMCSignal Event
Definition: mmc.h:149
void process_mmc_message(Parser &p, byte *, size_t len)
MMCSignal Add
Definition: mmc.h:145
byte vitcInsertEnable
Definition: mmc.h:240
MMCSignal Wait
Definition: mmc.h:154
MMCSignal RecordExit
Definition: mmc.h:126
byte lockDeviation
Definition: mmc.h:228
byte shortActualOffset
Definition: mmc.h:231
byte resolvedPlayMode
Definition: mmc.h:233
byte midiTimeCodeCommandTally
Definition: mmc.h:243
byte selectedTimeCodeSource
Definition: mmc.h:223
Port * _input_port
Definition: mmc.h:270
MMCSignal Group
Definition: mmc.h:150
byte shortRequestedOffset
Definition: mmc.h:230
PBD::Signal< void(MachineControl &, float, bool)> Shuttle
Definition: mmc.h:165
MMCSignal DeferredVariablePlay
Definition: mmc.h:152
MMCSignal DeferredPlay
Definition: mmc.h:122
void send(MachineControlCommand const &, timestamp_t when)
MMCSignal Resume
Definition: mmc.h:155
byte generatorSetUp
Definition: mmc.h:238
MMCSignal JogStart
Definition: mmc.h:133
MMCSignal Move
Definition: mmc.h:144
MMCSignal RecordStrobeVariable
Definition: mmc.h:153
byte midiTimeCodeSetUp
Definition: mmc.h:244
MMCSignal JogStop
Definition: mmc.h:134
byte generatorCommandTally
Definition: mmc.h:237
MMCSignal Read
Definition: mmc.h:137
PBD::Signal< void(MachineControl &, size_t, bool)> TrackRecordStatusChange
Definition: mmc.h:172
int do_step(byte *, size_t len)
MMCSignal Procedure
Definition: mmc.h:148
MMCSignal Stop
Definition: mmc.h:120
void set_receive_device_id(byte id)
#define LIBMIDIPP_API
#define MMC_NTRACKS
Definition: mmc.h:192
uint32_t timestamp_t