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 * 24 * Define a structure that will represent any given IO of an operator. 25 * Will require a name, buffer memory, flags (IO, Active, next, etc), 26 * 27 * These definitions declare the control structures for operator an IO control. 28 * We need a separate set of structures that define the IO required by each 29 * operator, which will be used by the GUI to understand what parameters need 30 (*operator)->destroy = destroy; 31 * to be represented to apply parameter changes to the operator. 32 */ 33 34 #ifndef _BRISTOL_H 35 #define _BRISTOL_H 36 37 /*#define BRISTOL_DBG */ 38 39 #include <stdio.h> 40 #include <string.h> 41 #include <strings.h> 42 #include <unistd.h> 43 #ifdef BRISTOL_SEMAPHORE 44 #include <semaphore.h> 45 #endif 46 #include <time.h> 47 #include <pthread.h> 48 49 #include <config.h> 50 51 /* #include "bristolvers.h" */ 52 #include "bristoldebug.h" 53 #include "ringbuffer.h" 54 55 #include "bristolaudio.h" 56 #include "bristolmidiapi.h" 57 #include "bristolarpeggiation.h" 58 #include "bristolactivesense.h" 59 60 #include <sys/types.h> 61 62 #if (BRISTOL_HAS_ALSA == 1) 63 #define bAMD "hw:0,0" 64 #define bAAD "plughw:0,0" 65 #endif /* BRISTOL_HAS_ALSA */ 66 67 #define bOMD "/dev/midi" 68 #define bOAD "/dev/audio" 69 70 #define BUFSZE 1024 71 72 #define BRISTOL_IO_COUNT 16 73 #define BRISTOL_PARAM_COUNT 16 74 75 #define BRISTOL_BUFSIZE BUFSZE 76 77 #define BRISTOL_ENGINE "bristolengine" 78 79 #define BRISTOL_JACK_MULTI 16 /* 2 legacy plus 16 multiIO */ 80 #define BRISTOL_JACK_UUID_SIZE 32 81 82 /* 83 * The following are channels and flags. They are applied to bristol system 84 * messages, and to the baudio.midiflags 85 * 86 * We should define a controller map for bristol: 87 * 0..63 Emulator operators (osc/env/filt, etc) 88 * 64-95 Engine processes: 89 * 64 Arpeggiator 90 * 65 LADI 91 * 96-126 Emulator effects except: 92 * 127 SYSTEM commands: start/stop/init, etc. 93 */ 94 #define BRISTOL_LADI 65 95 #define BRISTOL_SYSTEM 127 /* 127/0 */ 96 #define BRISTOL_HELLO 0x00002000 97 #define BRISTOL_COMMASK 0x00001f00 98 #define BRISTOL_PARAMMASK 0x000000ff 99 #define BRISTOL_REQSTART 0x00000100 100 #define BRISTOL_REQSTOP 0x00000200 101 #define BRISTOL_DEBUGON 0x00000300 102 #define BRISTOL_DEBUGOF 0x00000400 103 #define BRISTOL_VOICES 0x00000500 104 #define BRISTOL_INIT_ALGO 0x00000600 105 #define BRISTOL_MIDICHANNEL 0x00000700 106 #define BRISTOL_ALL_NOTES_OFF 0x00000800 107 #define BRISTOL_LOWKEY 0x00000900 108 #define BRISTOL_HIGHKEY 0x00000a00 109 #define BRISTOL_TRANSPOSE 0x00000b18 /* This include 2 octave up. */ 110 #define BRISTOL_HOLD 0x00000c00 111 #define BRISTOL_EVENT_KEYON 0x00000d00 /* NOT SENT AS BRISTOL_SYSTEM */ 112 #define BRISTOL_EVENT_KEYOFF 0x00000e00 /* NOT SENT AS BRISTOL_SYSTEM */ 113 #define BRISTOL_EVENT_PITCH 0x00000f00 /* NOT SENT AS BRISTOL_SYSTEM */ 114 /*#define BRISTOL_FREE 0x00000f00 */ 115 #define BRISTOL_EXIT_ALGO 0x00001000 116 #define BRISTOL_UNISON 0x00001100 117 #define BRISTOL_REQ_FORWARD 0x00001200 /* Disable event forwarding on chan*/ 118 #define BRISTOL_REQ_DEBUG 0x00001300 /* Debug level */ 119 #define BRISTOL_MIDI_DEBUG1 0x00008000 /* Just messages */ 120 #define BRISTOL_MIDI_DEBUG2 0x00010000 /* And internal functions() */ 121 #define BRISTOL_MIDI_NRP_ENABLE 0x00020000 122 123 /* LADI are BRISTOL_SYSTEM 1278/1 */ 124 #define BRISTOL_LADI_SAVE_REQ 0x00000001 125 #define BRISTOL_LADI_LOAD_REQ 0x00000002 126 127 #define BRISTOL_CC_HOLD1 64 128 129 #define SYSTEM_CHANNEL 0x07f /* used for initialisation requests. */ 130 131 #define BRISTOL_CHAN_OMNI 127 /* Denotes any midi channel. */ 132 133 //#define BRISTOL_VOICECOUNT 32 /* Was 16, now increased for GM-2 24/32 */ 134 #define BRISTOL_MAXVOICECOUNT 128 135 #define BRISTOL_SYNTHCOUNT 64 136 137 /* Not sure why these are in hex, they should be decimal, minor issue */ 138 #define BRISTOL_MINI 0x0000 139 #define BRISTOL_HAMMOND 0x0001 140 #define BRISTOL_PROPHET 0x0002 141 #define BRISTOL_DX 0x0003 142 #define BRISTOL_JUNO 0x0004 143 #define BRISTOL_EXPLORER 0x0005 144 #define BRISTOL_HAMMONDB3 0x0006 145 #define BRISTOL_VOX 0x0007 146 #define BRISTOL_RHODES 0x0008 147 #define BRISTOL_PROPHET10 0x0009 148 #define BRISTOL_MIXER 0x000a /* THIS SHOULD BE MOVED TO END!!! */ 149 #define BRISTOL_SAMPLER 0x000b 150 #define BRISTOL_BRISTOL 0x000c 151 #define BRISTOL_DDD 0x000d 152 #define BRISTOL_PRO52 0x000e 153 #define BRISTOL_OBX 0x000f 154 #define BRISTOL_OBXA 0x0010 155 #define BRISTOL_RHODES_BASS 0x0011 /* Actually a DX or Rhodes */ 156 #define BRISTOL_POLY 0x0012 /* Korg MonoPoly */ 157 #define BRISTOL_POLY6 0x0013 /* Korg Poly-6 */ 158 #define BRISTOL_AXXE 0x0014 /* ARP Axxe */ 159 #define BRISTOL_ODYSSEY 0x0015 /* ARP Odyssey */ 160 #define BRISTOL_MEMMOOG 0x0016 /* Memory Moog */ 161 #define BRISTOL_2600 0x0017 /* Arp 2600 */ 162 #define BRISTOL_SAKS 0x0018 /* EMS S Aks */ 163 #define BRISTOL_MS20 0x0019 /* Korg MS20 */ 164 #define BRISTOL_SOLINA 0x001a /* ARP Solina String Machine */ 165 #define BRISTOL_ROADRUNNER 0x001b /* Crumar electric piano */ 166 #define BRISTOL_GRANULAR 0x001c /* Granular sound generator */ 167 #define BRISTOL_REALISTIC 0x001d /* Mood MG-1 sound generator */ 168 #define BRISTOL_VOXM2 0x001e 169 #define BRISTOL_JUPITER8 0x001f /* Time to extend the table size to 64 */ 170 #define BRISTOL_BIT_ONE 0x0020 /* Crumar Bit One, Bit99. */ 171 #define BRISTOL_MASTER 0x0021 /* MIDI Master Controller */ 172 #define BRISTOL_CS80 0x0022 173 #define BRISTOL_PRO1 0x0023 174 #define BRISTOL_VOYAGER 0x0024 175 #define BRISTOL_SONIC6 0x0025 176 #define BRISTOL_TRILOGY 0x0026 /* This is the synth circuit */ 177 #define BRISTOL_TRILOGY_ODC 0x0027 /* This is the organ divider circuit */ 178 #define BRISTOL_STRATUS 0x0028 /* Holder for the smaller brother */ 179 #define BRISTOL_POLY800 0x0029 180 #define BRISTOL_BME700 0x002a 181 #define BRISTOL_BASSMAKER 0x002b 182 #define BRISTOL_SID_M1 0x002c /* 2 SID, audio and mod - sidney */ 183 #define BRISTOL_SID_M2 0x002d /* 6 SID, 5 audio, 1 mod - canberra */ 184 185 /* 186 * Operators 187 */ 188 #define B_DCO 0 189 #define B_ENV 1 190 #define B_DCA 2 191 #define B_FILTER 3 192 #define B_NOISE 4 193 #define B_HAMMOND 5 194 #define B_RESONATOR 6 195 #define B_LESLIE 7 196 #define B_PRODCO 8 197 #define B_FMOSC 9 198 #define B_HPF 10 199 #define B_JUNODCO 11 200 #define B_CHORUS 12 201 #define B_VIBRACRHORUS 13 202 #define B_FILTER2 14 203 #define B_EXPDCO 15 204 #define B_LFO 16 205 #define B_VOXDCO 17 206 #define B_SDCO 18 207 #define B_ARPDCO 19 208 #define B_RINGMOD 20 209 #define B_ELECTRO_SW 21 210 #define B_REVERB 22 211 #define B_FOLLOWER 23 212 #define B_AKSDCO 24 213 #define B_AKSENV 25 214 #define B_AKSREVERB 26 215 #define B_AKSFILTER 27 216 #define B_HCHORUS 28 217 #define B_QUANTUM 29 218 #define B_B1OSC 30 219 #define B_CS80OSC 31 220 #define B_CS80ENV 32 221 #define B_TRILOGYOSC 33 222 #define B_ENV5S 34 223 #define B_NRO 35 224 225 /* 226 * Audio interface types. The loest bytes is resevered. 227 * 228 * These are for audiomain.flags, there are 8 drivers available of which are 229 * defined, one is deprecated leaving six. The Pulse has two interfaces one of 230 * which may eventually be discarded. They are pulse simple and pulse, the 231 * latter is a full callback interface, multithreaded and rather heavy on CPU. 232 */ 233 #define BRISTOL_AUDIOMASK 0xff000000 234 #define BRISTOL_ALSA 0x01000000 235 #define BRISTOL_OSS 0x02000000 236 #define BRISTOL_PULSE 0x04000000 237 #define BRISTOL_JACK 0x08000000 238 #define BRISTOL_PULSE_T 0x10000000 /* Threaded */ 239 #define BRISTOL_PULSE_S 0x20000000 /* Simple - lots of latency */ 240 #define BRISTOL_DUMMY 0x40000000 241 /* This appears to collide */ 242 #define BRISTOL_AUDIOWAIT 0x00002000 243 244 /* 245 * MIDI interface types, may interact with audio drivers. 246 */ 247 #define BRISTOL_MIDIMASK 0x007f0000 248 #define BRISTOL_MIDI_ALSA 0x00010000 249 #define BRISTOL_MIDI_OSS 0x00020000 250 #define BRISTOL_MIDI_SLAB 0x00040000 /* this should be deprecated */ 251 #define BRISTOL_MIDI_JACK 0x00080000 252 #define BRISTOL_MIDI_LADSP 0x00100000 253 #define BRISTOL_MIDI_SEQ 0x00200000 254 #define BRISTOL_MIDI_OSC 0x00400000 255 256 #define BRISTOL_MIDI_WAIT 0x00800000 257 258 /* Audio connection to Jack ports */ 259 #define BRISTOL_AUTO_CONN 0x00008000 260 /* Separate registration for audio and midi */ 261 #define BRISTOL_JACK_DUAL 0x00004000 262 263 #define BRISTOL_TERM -3 264 #define BRISTOL_FAIL -2 265 #define BRISTOL_EXIT -1 266 #define BRISTOL_OK 0 267 #define BRISTOL_WAIT 1 268 #define BRISTOL_INIT 2 269 270 /* 271 * Global size management. 272 */ 273 #define BRISTOL_VPO 12.0 274 #define BRISTOL_VPO_DIV 10.5833333 /* 127 / this gives us our 12 per octave */ 275 276 /* 277 * Flags for IO management 278 */ 279 #define BRISTOL_DONE 4 /* Is this channel ready for use */ 280 #define BRISTOL_GAIN 8 /* Do we have an active gain control on this channel */ 281 282 /* 283 * Parameter description structures. 284 */ 285 typedef struct BristolParamSpec { 286 int int_val; 287 float float_val; 288 void *mem; 289 float config_val; 290 int midi_adj_algo; 291 int midi_param; 292 float config_amount; 293 float midi_amount; 294 } bristolParamSpec; 295 296 /* 297 * Modifier description structures. 298 * 299 * Define some modifier identifier flags: 300 */ 301 #define BRISTOL_PMOD_KEY 0 /* Apply a key (poly) index modifier */ 302 #define BRISTOL_PMOD_PRESS 1 /* Apply a polypressure (poly) modifier */ 303 /* 304 * The rest are channel mods, and apply to all voices on bristolSound 305 */ 306 #define BRISTOL_CMOD_CONT_0 0 307 #define BRISTOL_CMOD_CONT_1 1 308 #define BRISTOL_CMOD_CONT_2 2 309 /* ... up to 32 controllers */ 310 #define BRISTOL_CMOD_CONT_30 30 311 #define BRISTOL_CMOD_CONT_31 31 312 #define BRISTOL_CMOD_PITCHWHEEL 32 313 #define BRISTOL_CMOD_CHANPRESS 33 314 /* 315 * And some control flags to define what is applied where. 316 */ 317 #define BRISTOL_CHANMOD 1 /* Apply a channel mod: chanpress, controller, etc */ 318 #define BRISTOL_POLYMOD 2 /* Apply a polyphonic modifier: key or polypress */ 319 #define BRISTOL_CHANMOD_INV 4 /* Invert value (ie, max - value) */ 320 #define BRISTOL_POLYMOD_INV 8 321 #define BRISTOL_CHANMOD_CORRECT 0x10 /* Apply max / 2 - value */ 322 #define BRISTOL_POLYMOD_CORRECT x020 323 #define BRISTOL_CHANMOD_UNIQUE 0x40 /* Apply uniquely, or adjust configured */ 324 #define BRISTOL_POLYMOD_UNIQUE 0x80 325 typedef union BristolModSpec { 326 unsigned int flags; /* type of modifiers to apply */ 327 int channelMod; /* index into CHANMOD table */ 328 int polyMod; /* index into PolyMod table */ 329 float cmGain; 330 float pmGain; 331 } bristolModSpec; 332 333 typedef struct BristolOPParams { 334 bristolParamSpec param[BRISTOL_PARAM_COUNT]; 335 } bristolOPParams; 336 337 /* 338 * Parameter management structures. 339 */ 340 typedef struct BristolParam { 341 int type; 342 int index; 343 bristolParamSpec value; 344 bristolModSpec modifiers; 345 } bristolParam; 346 347 /* 348 * Voice structures 349 */ 350 #define BRISTOL_KEYON 0x0001 351 #define BRISTOL_KEYOFF 0x0002 352 #define BRISTOL_KEYDONE 0x0004 353 #define BRISTOL_KEYNEW 0x0008 354 #define BRISTOL_KEYREON 0x0010 355 #define BRISTOL_KEYOFFING 0x0020 356 #define BRISTOL_KEYSUSTAIN 0x0040 357 #define BRISTOL_KEYREOFF 0x0080 358 /* 359 * There are Korg Mono/Poly specifics for VCO assignment. 360 */ 361 #define BRISTOL_K_VCO4 0x10000000 362 #define BRISTOL_K_VCO3 0x20000000 363 #define BRISTOL_K_VCO2 0x40000000 364 #define BRISTOL_K_VCO1 0x80000000 365 #define BRISTOL_VCO_MASK 0xf0000000 366 /* 367 * Actually configured into baudio->mixflags 368 */ 369 #define BRISTOL_MULTITRIG 0x00800000 370 typedef struct BristolVoice { 371 struct BristolVoice *next; 372 struct BristolVoice *last; 373 struct BAudio *baudio; 374 int index; 375 unsigned int flags; 376 int offset; 377 char ***locals; 378 /* 379 * We need an event structure for each possible poly event. These will be 380 * fead to the voice operators for mods, etc. This should be views as the 381 * PolyMod table, ie, there are only two polyphonic modifiers, the key id 382 * and any polypressure generated. 383 */ 384 keyMsg key; 385 keyMsg keyoff; 386 int keyid; 387 float velocity; 388 pressureMsg pressure; 389 float press; 390 /* 391 * For polyponic portamento 392 */ 393 unsigned char lastkey; /* This should not be voice, but Audio parameter. */ 394 /* These are for the tendency generators */ 395 float dfreq; /* Desired frequency index */ 396 float cfreq; /* Current frequency index */ 397 float cfreqmult; /* rate of change from c to d */ 398 /* These are for the wavetable stepping rates */ 399 float dFreq; /* Desired step frequency index */ 400 float cFreq; /* Current step frequency index */ 401 float cFreqstep; /* rate of change from C to D */ 402 float cFreqmult; /* rate of change from C to D */ 403 float oFreq; /* Used to return pitchbend to original value */ 404 float chanpressure; /* Need a copy here */ 405 int transpose; 406 float detune; 407 } bristolVoice; 408 409 /* 410 * IO Channel structures 411 */ 412 #define BRISTOL_AC 1 413 #define BRISTOL_DC 2 414 #define BRISTOL_INPUT 4 415 #define BRISTOL_OUTPUT 8 416 typedef struct BristolIO { 417 char *IOname; /* Name of this IO function */ 418 struct BristolOP *owner; /* Pointer to the operator that owns this IO */ 419 int index; /* Index of this IO */ 420 unsigned int flags; /* diverse bits */ 421 struct BristolIO *last; /* Previous operator on list */ 422 struct BristolIO *next; /* Next operator on list */ 423 float *bufmem; /* buffer memory for this IO */ 424 int samplecnt; /* number of samples in buffer */ 425 int samplerate; /* on this IO */ 426 bristolModSpec modifiers; /* Midi modifiers to streamed input */ 427 } bristolIO; 428 429 typedef int (*bristolAlgo)(); 430 431 /* 432 * These are used for templating, not for operational control. We could change 433 * the naming, since it is rather close to bristolOPParams, which pass the run- 434 * time parameters to the operating code. 435 */ 436 #define BRISTOL_INT 1 437 #define BRISTOL_FLOAT 2 438 #define BRISTOL_ENUM 3 439 #define BRISTOL_TOGGLE 4 440 441 #define BRISTOL_ROTARY 1 442 #define BRISTOL_SLIDER 2 443 #define BRISTOL_BUTTON 4 444 #define BRISTOL_HIDE 8 445 typedef struct BristolOPParam { 446 char *pname; 447 char *description; 448 int type; /* need method of defining enumerations "Square, sine" etc, FFS */ 449 int low; 450 int high; 451 unsigned int flags; 452 } bristolOPParam; 453 454 typedef struct BristolOPIO { 455 char *ioname; 456 char *description; 457 int samplerate; 458 int samplecount; 459 unsigned int flags; /* AC/DC, Hide op, others */ 460 float *buf; 461 } bristolOPIO; 462 463 typedef struct BristolOPSpec { 464 char *opname; 465 char *description; 466 int pcount; 467 bristolOPParam param[BRISTOL_PARAM_COUNT]; 468 int iocount; 469 bristolOPIO io[BRISTOL_IO_COUNT]; 470 int localsize; /* size of table require for runtime locals */ 471 } bristolOPSpec; 472 473 #define BRISTOL_SOUND_START 1 474 #define BRISTOL_SOUND_END 2 475 #define BRISTOL_FX_STEREO 4 476 typedef struct BristolSound { 477 char *name; 478 int index; /* into operator list */ 479 int (*operate)(struct BristolOP *, bristolVoice *, 480 bristolOPParams *, void *); 481 /*unsigned char *param; Param structure for that op. */ 482 bristolOPParams *param; /* Param structure for that op. */ 483 int next; 484 unsigned int flags; 485 } bristolSound; 486 487 /* 488 * Bristol Operator control structure. 489 */ 490 typedef struct BristolOP { 491 int index; /* Index of this OP */ 492 unsigned int flags; /* diverse bits */ 493 struct BristolOP *next; /* Next operator on list */ 494 struct BristolOP *last; /* Previous operator on list */ 495 /* 496 * These are used for any information that is managed internally 497 */ 498 bristolOPSpec *specs; /* any parameter specs for this OP */ 499 int size; /* Size of specs memory */ 500 /* 501 * A number of routines called to manage the operator 502 */ 503 bristolAlgo init; 504 bristolAlgo destroy; 505 bristolAlgo reset; 506 int (*param)(struct BristolOP *, bristolOPParams *, unsigned char, float); 507 int (*operate)(struct BristolOP *, bristolVoice *, bristolOPParams *, 508 void *); 509 } bristolOP; 510 511 extern bristolOP *bristolOPinit(); 512 extern bristolIO *bristolIOinit(); 513 514 /* 515 * This are mixflags: the system reserves the space 0xffff0000.00000000, and 516 * a poly algorithm can use the rest. 517 #define BRISTOL_SUSTAIN 0x0040000000000000ULL 518 */ 519 #define bfiltertype(x) ((x&(BRISTOL_LW_FILTER|BRISTOL_LW_FILTER2)) >> 48) 520 #define BRISTOL_LW_FILTER 0x0001000000000000ULL 521 #define BRISTOL_LW_FILTER2 0x0002000000000000ULL 522 #define BRISTOL_LW_FILTERS (BRISTOL_LW_FILTER|BRISTOL_LW_FILTER2) 523 #define BRISTOL_GLIDE_AUTO 0x0004000000000000ULL 524 #define BRISTOL_SENSE 0x0008000000000000ULL 525 #define BRISTOL_SEQUENCE 0x0010000000000000ULL 526 #define BRISTOL_CHORD 0x0020000000000000ULL 527 #define BRISTOL_ARPEGGIATE 0x0040000000000000ULL 528 #define BRISTOL_V_UNISON 0x0080000000000000ULL 529 #define BRISTOL_MUST_PRE 0x0100000000000000ULL 530 #define BRISTOL_HAVE_OPED 0x0200000000000000ULL 531 #define BRISTOL_HOLDDOWN 0x0400000000000000ULL 532 #define BRISTOL_REMOVE 0x0800000000000000ULL 533 #define A_440 0x1000000000000000ULL 534 #define MASTER_ONOFF 0x2000000000000000ULL 535 #define BRISTOL_STEREO 0x4000000000000000ULL 536 #define BRISTOL_KEYHOLD 0x8000000000000000ULL 537 538 /* Monophonic note logic */ 539 #define BRISTOL_MNL_LNP 0x0001 540 #define BRISTOL_MNL_HNP 0x0002 541 #define BRISTOL_MNL_TRIG 0x0010 542 #define BRISTOL_MNL_VELOC 0x0020 543 544 /* 545 * Audio globals structure. 546 */ 547 typedef struct BAudio { 548 struct BAudio *next; 549 struct BAudio *last; 550 int soundCount; 551 bristolSound **sound; /* operator instance sequences */ 552 bristolSound **effect; 553 int (*param)(struct BAudio *, u_char, u_char, float); /* param change */ 554 bristolAlgo preops; /* Pre polyphonic (ie, monophonic) voicing routine */ 555 bristolAlgo operate; /* Polyphonic voice mixing routine */ 556 bristolAlgo postops; /* Post polyphonic voicing routine: FX, etc. */ 557 bristolAlgo destroy; /* Voice destruction routine */ 558 bristolVoice *firstVoice; 559 int debuglevel; 560 /* 561 * This should become a generic midi modifier table. 562 */ 563 float contcontroller[MIDI_CONTROLLER_COUNT]; 564 int GM2values[MIDI_CONTROLLER_COUNT]; 565 /* We should put in a callback function here. */ 566 int (*midi)(struct BAudio *, int, float); /* param change */ 567 chanPressMsg chanPress; 568 float chanpressure; 569 int sid; 570 int controlid; 571 int midichannel; 572 char ***locals; /* Unique locals per voice, a basic necessity. */ 573 void ***params; /* Unique params per voice, for midi poly support, etc. */ 574 char ***FXlocals; 575 u_int64_t mixflags; 576 unsigned int midiflags; 577 /* 578 * These need to remain to the baudio structure 579 */ 580 float extgain; 581 float glide; 582 float glidemax; 583 float gtune; 584 float note_diff; 585 float gain_diff; 586 int transpose; 587 arpeggiator arpeggio; 588 float pitchwheel; 589 int midi_pitch; 590 float midi_pitchfreq; 591 int cvoices; 592 int lvoices; 593 float *leftbuf; 594 float *rightbuf; 595 fTab ctab[DEF_TAB_SIZE]; 596 float *mixlocals; 597 int voicecount; 598 char lowkey; 599 char highkey; 600 unsigned char lastkey; 601 float detune; 602 float finetune; 603 float coarsetune; 604 float gain; 605 fTab microtonalmap[128]; 606 float velocitymap[128]; 607 int midimap[128]; 608 u_char valuemap[128][128]; 609 int sensecount; 610 int samplerate; 611 int samplecount; 612 int oversampling; 613 /* For the corrected monophonic note logic */ 614 struct { 615 int key[128]; 616 int velocity[128]; 617 int count; 618 int flags; 619 int low; 620 int high; 621 int extreme; 622 } notemap; 623 } Baudio; 624 625 typedef struct AudioMain { 626 Baudio *audiolist; 627 bristolVoice *playlist; 628 bristolVoice *playlast; 629 bristolVoice *freelist; 630 bristolVoice *freelast; 631 bristolVoice *newlist; 632 bristolVoice *newlast; 633 bristolOP **palette; /* operator templates */ 634 bristolOP **effects; /* operator templates */ 635 #ifdef BRISTOL_SEMAPHORE 636 sem_t *sem_long; 637 sem_t *sem_short; 638 #else 639 void *unused1; 640 void *unused2; 641 #endif 642 struct timespec abstime; 643 int voiceCount; 644 int opCount; 645 int debuglevel; 646 unsigned int flags; 647 int iosize; 648 int preload; 649 int samplecount; 650 int segmentsize; 651 int samplerate; 652 int priority; 653 struct sched_param asp; 654 struct sched_param msp; 655 int atReq; 656 int atStatus; 657 int mtReq; 658 int mtStatus; 659 int controlHandle; /* Sysex MIDI handle */ 660 int midiHandle; /* MIDI handle */ 661 unsigned int midiflags; 662 int s440holder; /* not used? */ 663 char *audiodev; /* both of these really need to become multiheaded? */ 664 char *mididev; 665 int port; /* for tcp connecctions */ 666 float ingain; 667 float outgain; 668 char *microTonalMappingFile; 669 unsigned int SysID; 670 jack_ringbuffer_t *rb; /* MIDI thread to audio threadd */ 671 jack_ringbuffer_t *rbfp; /* MIDI/Audio thread to forwarding thread */ 672 char jackUUID[BRISTOL_JACK_UUID_SIZE]; 673 int iocount; 674 float *io_i[BRISTOL_JACK_MULTI]; 675 float *io_o[BRISTOL_JACK_MULTI]; 676 float m_io_ogc; 677 float m_io_igc; 678 char *cmdline; 679 char *sessionfile; 680 char *controldev; 681 } audioMain; 682 683 extern int cleanup(); 684 685 extern Baudio *findBristolAudio(Baudio *, int, int); 686 extern Baudio *findBristolAudioByChan(Baudio *, int); 687 extern int bufmerge(float *, float, float *, float, int); 688 extern int bufadd(float *, float, int); 689 extern int bufset(float *, float, int); 690 691 extern void * bristolmalloc(); 692 extern void * bristolmalloc0(); 693 extern void bristolfree(); 694 extern void bristolbzero(); 695 696 extern void alterAllNotes(); 697 extern int fillFreqTable(); 698 extern int fillFreqBuf(); 699 700 extern void initSoundAlgo(); 701 702 #ifndef NULL 703 #define NULL 0 704 #endif 705 706 int bristolArpegReVoice(Baudio *, bristolVoice *, float); 707 int bristolArpegReAudio(audioMain *, Baudio *); 708 void bristolArpeggiatorInit(Baudio *); 709 void bristolArpeggiator(audioMain *, bristolMidiMsg *); 710 void bristolArpeggiatorNoteEvent(Baudio *, bristolMidiMsg *); 711 712 #endif /* _BRISTOL_H */ 713 714