1 2 /* 3 * Diverse Bristol audio routines. 4 * Copyright (c) by Nick Copeland <nickycopeland@hotmail.com> 1996,2012 5 * 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, see <http://www.gnu.org/licenses/>. 19 * 20 */ 21 22 /* 23 * This defines the format of messages sent to the SLab GUI. 24 * 25 * All the messages, for no real purpose, carry the text "SLab" in the first 26 * four bytes of the message. It is intended to prevent spurious reception of 27 * UDP messages, since the receiving socket is not actually connec()ed. 28 * 29 30 TRACK OPERATIONS: 31 "S L a b " 32 vers comm length length 33 track op cont value 34 value 35 36 * Not really thought much about these, but I want some consideration for 37 * MIDI Time Code, or MIDI Clock to sync output to MTC. May be a big deal? 38 39 MIDI OPERATIONS: 40 "S L a b " 41 vers comm length length 42 channel op data data 43 44 * 45 * Tracks are up to 64, operators are reasonably unlimited, but there is a total 46 * pool of 256. Controllers are up to 8, they are the number of controllers for 47 * an operator. 48 */ 49 50 /* 51 * Define the current version. Will allow for interoperability later. 52 */ 53 #define SLAB_CONTROL_VERSION 1 54 55 #define SLAB_CONTROL_SET 0x40 56 #define SLAB_CONTROL_ACK 0x80 /* Used to request acknowledgement */ 57 58 #define SLAB_MAX_SWING 32767 59 60 /* 61 * Commands are get or set for track/bus/tape, etc: 62 * NOTES: as of version 1 there is only support for set operations, no GETs. 63 * 64 * Gets will be implemented at a later date, will require monitoring of the 65 * 0x40 flag. 66 * 67 */ 68 #define SLAB_T_SET TRACK_EVENT 69 #define SLAB_T_GET (TRACK_EVENT | SLAB_CONTROL_SET) 70 #define SLAB_M_SET MASTER_EVENT 71 #define SLAB_M_GET (MASTER_EVENT | SLAB_CONTROL_SET) 72 #define SLAB_B_SET BUS_EVENT /* FX send return busses */ 73 #define SLAB_B_GET (BUS_EVENT | SLAB_CONTROL_SET) 74 #define SLAB_SB_SET SBUS_EVENT /* Stereo bus group operations */ 75 #define SLAB_SB_GET (SBUS_EVENT | SLAB_CONTROL_SET) 76 #define SLAB_FX_SET EFFECT_EVENT 77 #define SLAB_FX_GET (EFFECT_EVENT | SLAB_CONTROL_SET) 78 #define SLAB_FB_SET FB_EVENT 79 #define SLAB_FB_GET (FB_EVENT | SLAB_CONTROL_SET) 80 #define SLAB_TAPE_GET TAPE_EVENT 81 #define SLAB_TAPE_SET (TAPE_EVENT | SLAB_CONTROL_SET) 82 #define SLAB_DEV_GET DEV_EVENT 83 #define SLAB_DEV_SET (DEV_EVENT | SLAB_DEV_SET) 84 #define SLAB_CTL_GET CONTROL_EVENT 85 #define SLAB_CTL_SET (CONTROL_EVENT | SLAB_CONTROL_SET) 86 #define SLAB_MIDI_OP MIDI_EVENT 87 #define SLAB_OP_MAX 12 88 89 #ifndef GUI_DEBUG_EXT 90 #define GUI_DEBUG_EXT (0x2 << 20) 91 #endif 92 93 /* 94 * Define the commands that can be executed. 95 * At the moment, only TRACK, MASTER, SBUS and BUS are implemented, although 96 * FX params should also work. In short, this relates to the components of the 97 * GUI that can be automated with session recording. 98 */ 99 #include "messageOps.h" 100 101 #define NAME_LEN 256 102 #define SLAB_MIN_MSG_SIZE 12 103 #define SLAB_MAX_MSG_SIZE 512 104 105 typedef struct songmessage { 106 int length; /* length of the songname datafield */ 107 } songMessage; 108 109 typedef struct devicemessage { 110 int deviceID; 111 int devNameLength; /* length of the device name datafield */ 112 int mixerNameLength; /* length of the mixer name datafield */ 113 int flags; 114 } deviceMessage; 115 116 typedef struct trackmessage { 117 unsigned char track; 118 unsigned char operator; 119 unsigned char controller; 120 unsigned short int value; 121 } trackMessage; 122 123 /* 124 * This is intended primarily for MTC and Song Pointer support. 125 */ 126 typedef struct midiMessage { 127 unsigned char channel; 128 unsigned char operation; 129 unsigned char key; 130 unsigned char param; 131 unsigned int time; 132 } midiMessage; 133 134 typedef struct slabMessage { 135 char S; 136 char L; 137 char a; 138 char b; 139 char version; 140 char command; 141 short length; 142 union { 143 trackMessage trkMsg; 144 songMessage songMsg; 145 deviceMessage devMsg; 146 midiMessage midiMsg; 147 } message; 148 char data; 149 } slabmessage; 150 151 /* 152 * The interpreters is an array of routines for encoding and decoding messages. 153 */ 154 typedef int (*interpret)(); 155 156 typedef struct Interpreter { 157 interpret encode; 158 interpret decode; 159 } interpreter; 160 161 interpreter interpreters[SLAB_OP_MAX]; 162 163 extern slabmessage *getSLabBuffer(); 164 extern int extracSLabMessage(); 165 extern int extractV1Message(); 166 167