1 2 /* 3 * Diverse SLab Include Files 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 #ifndef SLAB_CBUF 22 #define SLAB_CBUF 23 24 typedef struct TrackDesk { 25 int trackCount; 26 int resolution; 27 int sampleRate; 28 int writeSampleRate; 29 int trackLength; /* in samples */ 30 enum DiskStatus diskstatus; 31 } trackdesc; 32 33 /* 34 * This is a rather large structure, but carries all information for 35 * daemon synchronisation. 36 * MARK: put the mixiod data into structures, add arrays for multiple disk 37 * support. 38 * Want to add more "version" integers, one per daemon. 39 */ 40 typedef struct cBuff { 41 int structVersion; 42 int releaseVersion; 43 #ifdef DAEMON_VERS 44 int engineVersion; 45 int mixengineVersion; 46 int mixiodVersion; 47 int adiodVersion; 48 #ifdef MIDI 49 int midiEngineVersion; 50 #endif 51 #endif 52 #ifdef NEW_DBG 53 int debugLevel; 54 #endif 55 int mixdPID; /* PID of mother process - responsible for CLI */ 56 int mixiodPID; /* Mixer disk IO daemon */ 57 int mixEnginePID; /* the actual workhorse */ 58 59 char *diskBuffer; /* disk buffer */ 60 int diskBufferSize; /* disk buffer size */ 61 int diskBufferFD; 62 63 int loadSegSize; /* size of data to fetch per reqest */ 64 int preLoadSize; /* amount of buffer to maintain filled */ 65 int preMixSize; /* amount of output buffer to initialise before start */ 66 int EndOfFile; 67 68 int mixAlgo; 69 int subMixAlgo; 70 int outputMixAlgo; 71 int inputAlgo; 72 int outputAlgo; 73 int subRecordAlgo; 74 int filterAlgo; 75 #ifdef SB_ONR 76 int sbONrAlgo; 77 #endif 78 #ifdef SB_NR 79 int sbNrAlgo; 80 #endif 81 int compressionClass; 82 int decompressionMethod; 83 char *compressionBuffer; 84 85 /* 86 * This is a performance tuning issue. It controls the number of windows 87 * we build into the output buffer. Default should be 4, or 88 * OUTPUT_BUFFER_WINDOW, but we should allow lower configurations. 89 */ 90 int audioWindowSize; 91 92 int conversionFlags; 93 94 mixAlgo mixAlgorithm[ALGO_COUNT]; 95 mixAlgo subMixAlgorithm[ALGO_COUNT]; 96 /* Added the next two for eventual speed/sample conversions 97 * although the function will probably be left to the IO daemons */ 98 mixAlgo subRecordAlgorithm[ALGO_COUNT]; /* Demultiplexes inputs */ 99 mixAlgo outputMixAlgorithm[ALGO_COUNT]; 100 #ifdef FLOAT_PROC 101 mixAlgo busFloatAlgo[FB_ALGO_COUNT]; 102 int fbDepth; 103 float *floatBuffer; 104 #endif 105 106 int cindex; 107 cAlgo compression[COMP_CLASS_SIZE][COMP_INDEX_SIZE]; 108 cAlgo decompression[COMP_CLASS_SIZE][COMP_INDEX_SIZE][DECOMP_METHOD_SIZE]; 109 110 mixAlgo dynamicsAlgorithm[ALGO_COUNT]; 111 mixAlgo filterAlgorithm[ALGO_COUNT]; 112 113 int startOffset; /* begin reading from disk at this location in file */ 114 int currentROffset; /* begin reading from disk at this location in file */ 115 int currentWOffset; /* begin write to disk at this location in file */ 116 int endOffset; /* stop reading from disk at this location in file */ 117 int lseeked; 118 119 char * dioPRead; /* where the engine process is mixing from */ 120 char * dioPWrite; /* where the engine is currently reocrding to */ 121 char * dioCRead; /* where the mixiod process is loading to = from disk */ 122 char * dioCWrite; /* where the mixiod is currently read from = to disk */ 123 124 int dioPReadBytes; /* amount of data read from buffer by parent */ 125 int dioPWriteBytes; /* amount of data written to buffer by parent */ 126 int dioCReadBytes; /* amount of data read to buffer by child */ 127 int dioCWriteBytes; /* amount of data written from buffer by child */ 128 129 duplexDev adiod[MAX_DEVICES + 1]; 130 131 int *busBuffer; 132 int busBufferSize; 133 busparams busParams[BUS_TRACK_COUNT]; 134 #ifdef FX_CHAINS 135 #ifdef FLOAT_PROC 136 /* 137 * If we are going to use FLOATs, then we need to have indeces for each 138 * track, rather than for each bus. 139 */ 140 char trackStart[MAX_TRACK_COUNT]; /* index of first busParamPtr in chain */ 141 char trackNext[MAX_TRACK_COUNT]; /* index of next busParamPtr to chain */ 142 int trackCount[MAX_TRACK_COUNT]; /* Ensure termination of this loop */ 143 #endif 144 char busStart[BUS_REAL_COUNT]; /* index of first busParamPtr in chain */ 145 char busNext[BUS_REAL_COUNT]; /* index of next busParamPtr to chain */ 146 int busCount[BUS_REAL_COUNT]; /* Ensure termination of this loop */ 147 int *fxBuffer[BUS_REAL_COUNT]; /* Ensure termination of this loop */ 148 #endif 149 150 int mixEngineCommand; /* mix operation to be executed */ 151 int mixiodCommand; /* disk operation to be executed */ 152 153 /* 154 * Record offsets are used since we only expect to be able to record 155 * one or two track simultaniously. To save disk write operations 156 * we only write the data for the recording tracks, not all tracks. 157 * These are specified as two offsets of recordSegSize, 3 and 4 are not 158 * yet supported. 159 * DEPRECATED recordOffset moved to DuplexDev. 160 */ 161 int blockSampleSize;/* Number of samples in a given recorded segment */ 162 int recordSegSize; /* size of segment to be moved per track, in bytes */ 163 164 /* 165 * COMPRESSION: Added for compression code. 166 */ 167 int dioRealReadBytes; /* Before decompression */ 168 int dioRealWriteBytes; /* After compression */ 169 int dioReadSegSize; /* After comdec algorithm */ 170 int dioWriteSegSize; /* size of segment to be synchronised to disk */ 171 int factor; /* current expected compression ratio */ 172 173 int diskBufferWindow; /* amount of buffer to maintain filled */ 174 enum mixIOstatus mixEngineStatus; /* mixiod operational status */ 175 enum mixIOstatus mixiodStatus; /* mixiod operational status */ 176 177 /* 178 * These take values of 100K (usleep). 179 * These MUST be calculated: if the BSS is 8192, we can reasonably sleep 180 * for about 100ms when sampling rate is 44100. However, if BSS is 4096, 181 * the delay should be half that. There are similar issues with sample 182 * rate. Calculation should be something like: 183 * (blockSampleSize * 1000000 / sampleRate) us. FFS. 184 * In addition, the sleep period should be self tuning - if we wake up, 185 * and there is a window, reduce the sleep period. If we wake up and there 186 * is still no window (whilst running) increase the sleep period. Need to 187 * be careful with idle situations. FFS. 188 */ 189 unsigned long mixiodSleepPeriod; 190 unsigned long mixEngineSleepPeriod; 191 192 /* 193 * These are saved in the controlBuffer, and should only be set once. 194 * diskBufferID will eventually move into arrays. 195 */ 196 int controlSegID; 197 int diskBufferID; 198 int busBufferID; 199 /* 200 * This is for track descriptions. 201 * Used for track naming, sample frequency, track counts, bit 202 * resolution etc.etc. 203 * 204 * NOTES:MARK: Not sure where this is supposed to be saved yet..... 205 */ 206 trackdesc trackDesc; 207 #ifdef SLAB_SEPARATE 208 int mixerSize; 209 #endif 210 /* 211 * Assign 3 extra trackparams for the Master and master LR 212 */ 213 trackparams trackParams[ALL_TRACKS]; 214 #ifdef I_NR 215 /* 216 * For input gating and NR we need seperate algo pointers (handled in 217 * mixiod, rather than mixengined, and some record parameters. 218 * This stuff should be moved to the DuplexDev structure. 219 */ 220 mixAlgo inputDynamics[ALGO_COUNT]; 221 mixAlgo inputFilter[ALGO_COUNT]; 222 #endif 223 char trackName[DEV_NAME_LEN]; 224 #ifdef MASTERING 225 char masteringFileName[DEV_NAME_LEN]; 226 int masteringFD; 227 #endif 228 229 int XTalk; 230 int wowFlutter; 231 int scratchLevel; /* The volume of the scratchs */ 232 int scratchDensity; /* Number of scratches applied per sampleBlockSize */ 233 int scratchAlgo; /* Stereo, mono or hybrid scratch */ 234 int scratchInited; 235 236 /* 237 * The following are used for merge, normalisation, reverse, operations etc. 238 * As per 1.0 and pre release, these edit operations are handled by the 239 * frontend. 240 */ 241 int srcTrack; 242 int srcStart; 243 int srcVolume; 244 int dstTrack; 245 int dstStart; 246 int dstVolume; 247 int count; 248 int editStat; 249 int editCommand; 250 251 /* 252 * Fixed VU Meter counters. These should be moved into respective 253 * device structures. 254 * THESE HAVE BEEN MOVED TO THE DUPLEX DEV STRUCTURE. 255 int inputLMax; 256 int inputLAve; 257 int inputRMax; 258 int inputRAve; 259 int inputLMax2; 260 int inputLAve2; 261 int inputRMax2; 262 int inputRAve2; 263 int outputLMax; 264 int outputLAve; 265 int outputRMax; 266 int outputRAve; 267 int outputLMax2; 268 int outputLAve2; 269 int outputRMax2; 270 int outputRAve2; 271 */ 272 #ifdef MIDI 273 MidiMain midiMain; 274 MidiTrack midiTrack[MIDI_TRACK_COUNT]; 275 MidiDev midiiod[MAX_DEVICES]; 276 #endif 277 #ifdef METRONOME 278 int metroInsertStrong; /* Insert metronome bar pulse on this interval. */ 279 int metroInsertWeak; /* Insert metronome beat pulse on this interval. */ 280 int metroInsertLevel; /* Signal "blip" to insert */ 281 int metroMajor; /* beats per bar */ 282 int metroMinor; /* bar count */ 283 int metroBpm; /* beats per minute */ 284 int metroAdjust; /* beats per minute */ 285 #endif 286 #ifdef MICROADJUST 287 /* 288 * These are used for microTape speed adjustments, which are global. 289 */ 290 int microAdjust; 291 int microCurrentOut; 292 int microCurrentIn; 293 #endif 294 #ifdef CONTROL_API 295 int remoteSocketDescriptor; 296 char *interp; /* This should be Tcl_Interp, but this will hold it */ 297 #endif 298 #ifdef CONTROL_FLOAT 299 fbop fullBusAlgo[32]; 300 #endif 301 } controlbuffer; 302 303 #endif /* SLAB_CBUF */ 304