1 /* 2 csoundCore.h: 3 4 Copyright (C) 1991-2006 Barry Vercoe, John ffitch, Istvan Varga 5 6 This file is part of Csound. 7 8 The Csound Library is free software; you can redistribute it 9 and/or modify it under the terms of the GNU Lesser General Public 10 License as published by the Free Software Foundation; either 11 version 2.1 of the License, or (at your option) any later version. 12 13 Csound 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 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with Csound; if not, write to the Free Software 20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 21 02110-1301 USA 22 */ 23 24 #if !defined(__BUILDING_LIBCSOUND) && !defined(CSOUND_CSDL_H) 25 # error "Csound plugins and host applications should not include csoundCore.h" 26 #endif 27 28 #ifndef CSOUNDCORE_H 29 #define CSOUNDCORE_H 30 31 #if defined(__EMSCRIPTEN__) && !defined(EMSCRIPTEN) 32 #define EMSCRIPTEN 33 #endif 34 35 #include "sysdep.h" 36 #if !defined(EMSCRIPTEN) && !defined(CABBAGE) 37 #if defined(HAVE_PTHREAD) 38 #include <pthread.h> 39 #endif 40 #endif 41 #include "cs_par_structs.h" 42 #include <stdarg.h> 43 #include <setjmp.h> 44 #include "csound_type_system.h" 45 #include "csound.h" 46 #include "cscore.h" 47 #include "csound_data_structures.h" 48 #include "csound_standard_types.h" 49 #include "pools.h" 50 51 #ifndef CSOUND_CSDL_H 52 /* VL not sure if we need to check for SSE */ 53 #if defined(__SSE__) && !defined(EMSCRIPTEN) 54 #include <xmmintrin.h> 55 #ifndef _MM_DENORMALS_ZERO_ON 56 #define _MM_DENORMALS_ZERO_MASK 0x0040 57 #define _MM_DENORMALS_ZERO_ON 0x0040 58 #define _MM_DENORMALS_ZERO_OFF 0x0000 59 #define _MM_SET_DENORMALS_ZERO_MODE(mode) \ 60 _mm_setcsr((_mm_getcsr() & ~_MM_DENORMALS_ZERO_MASK) | (mode)) 61 #define _MM_GET_DENORMALS_ZERO_MODE() \ 62 (_mm_getcsr() & _MM_DENORMALS_ZERO_MASK) 63 #endif 64 #else 65 #ifndef _MM_DENORMALS_ZERO_ON 66 #define _MM_DENORMALS_ZERO_MASK 0 67 #define _MM_DENORMALS_ZERO_ON 0 68 #define _MM_DENORMALS_ZERO_OFF 0 69 #define _MM_SET_DENORMALS_ZERO_MODE(mode) 70 #endif 71 #endif 72 #endif 73 74 #ifdef __cplusplus 75 extern "C" { 76 #endif /* __cplusplus */ 77 78 #if defined(__MACH__) || defined(__FreeBSD__) || defined(__DragonFly__) 79 #include <xlocale.h> 80 #endif 81 82 #if (defined(__MACH__) || defined(ANDROID) || defined(NACL) || defined(__CYGWIN__) || defined(__HAIKU__)) 83 #include <pthread.h> 84 #define BARRIER_SERIAL_THREAD (-1) 85 typedef struct { 86 pthread_mutex_t mut; 87 pthread_cond_t cond; 88 unsigned int count, max, iteration; 89 } barrier_t; 90 91 #ifndef PTHREAD_BARRIER_SERIAL_THREAD 92 #define pthread_barrier_t barrier_t 93 #endif /* PTHREAD_BARRIER_SERIAL_THREAd */ 94 #endif /* __MACH__ */ 95 96 #define OK (0) 97 #define NOTOK (-1) 98 99 #define CSFILE_FD_R 1 100 #define CSFILE_FD_W 2 101 #define CSFILE_STD 3 102 #define CSFILE_SND_R 4 103 #define CSFILE_SND_W 5 104 105 #define MAXINSNO (200) 106 #define PMAX (1998) 107 #define VARGMAX (1999) 108 #define NOT_AN_INSTRUMENT INT32_MAX 109 110 #define ORTXT h.optext->t 111 #define INCOUNT ORTXT.inlist->count 112 #define OUTCOUNT ORTXT.outlist->count /* Not used */ 113 //#define INOCOUNT ORTXT.inoffs->count 114 //#define OUTOCOUNT ORTXT.outoffs->count 115 #define INOCOUNT ORTXT.inArgCount 116 #define OUTOCOUNT ORTXT.outArgCount 117 #define IS_ASIG_ARG(x) (csoundGetTypeForArg(x) == &CS_VAR_TYPE_A) 118 #define IS_STR_ARG(x) (csoundGetTypeForArg(x) == &CS_VAR_TYPE_S) 119 120 #define CURTIME (((double)csound->icurTime)/((double)csound->esr)) 121 #define CURTIME_inc (((double)csound->ksmps)/((double)csound->esr)) 122 123 #ifdef B64BIT 124 #define MAXLEN 0x40000000 125 #define FMAXLEN ((MYFLT)(MAXLEN)) 126 #define PHMASK 0x3fffffff 127 #else 128 #define MAXLEN 0x1000000L 129 #define FMAXLEN ((MYFLT)(MAXLEN)) 130 #define PHMASK 0x0FFFFFFL 131 #endif 132 133 #define MAX_STRING_CHANNEL_DATASIZE 16384 134 135 #define PFRAC(x) ((MYFLT)((x) & ftp->lomask) * ftp->lodiv) 136 #define MAXPOS 0x7FFFFFFFL 137 138 #define BYTREVS(n) ((n>>8 & 0xFF) | (n<<8 & 0xFF00)) 139 #define BYTREVL(n) ((n>>24 & 0xFF) | (n>>8 & 0xFF00L) | \ 140 (n<<8 & 0xFF0000L) | (n<<24 & 0xFF000000L)) 141 142 #define OCTRES 8192 143 #define CPSOCTL(n) ((MYFLT)(1<<((int)(n)>>13))*csound->cpsocfrc[(int)(n)&8191]) 144 145 #define LOBITS 10 146 #define LOFACT 1024 147 /* LOSCAL is 1/LOFACT as MYFLT */ 148 #define LOSCAL FL(0.0009765625) 149 150 #define LOMASK 1023 151 152 #ifdef USE_DOUBLE 153 extern int64_t MYNAN; 154 //#define SSTRCOD (nan("0")) 155 #define SSTRCOD (double)NAN 156 #else 157 extern int32 MYNAN; 158 #define SSTRCOD (float)NAN 159 //#define SSTRCOD (nanf("0")) 160 #endif 161 //#define ISSTRCOD(X) isnan(X) 162 //#ifndef __MACH__ 163 extern int ISSTRCOD(MYFLT); 164 //#else 165 //#define ISSTRCOD(X) isnan(X) 166 //#endif 167 168 #define SSTRSIZ 1024 169 #define ALLCHNLS 0x7fff 170 #define DFLT_SR FL(44100.0) 171 #define DFLT_KR FL(4410.0) 172 #define DFLT_KSMPS 10 173 #define DFLT_NCHNLS 1 174 #define MAXCHNLS 256 175 176 #define MAXNAME (256) 177 178 #define DFLT_DBFS (FL(32768.0)) 179 180 #define MAXOCTS 8 181 #define MAXCHAN 16 /* 16 MIDI channels; only one port for now */ 182 183 /* A440 tuning factor */ 184 #define ONEPT (csound->A4/430.5389646099018460319362438314060262605) 185 #define LOG10D20 0.11512925 /* for db to ampfac */ 186 #define DV32768 FL(0.000030517578125) 187 188 #ifndef PI 189 #define PI (3.141592653589793238462643383279502884197) 190 #endif /* pi */ 191 #define TWOPI (6.283185307179586476925286766559005768394) 192 #define HALFPI (1.570796326794896619231321691639751442099) 193 #define PI_F ((MYFLT) PI) 194 #define TWOPI_F ((MYFLT) TWOPI) 195 #define HALFPI_F ((MYFLT) HALFPI) 196 #define INF (2147483647.0) 197 #define ROOT2 (1.414213562373095048801688724209698078569) 198 199 #define AMPLMSG 01 200 #define RNGEMSG 02 201 #define WARNMSG 04 202 #define RAWMSG 0x40 203 #define TIMEMSG 0x80 204 #define NOQQ 0x400 205 #define IGN(X) (void) X 206 207 #define ARG_CONSTANT 0 208 #define ARG_STRING 1 209 #define ARG_PFIELD 2 210 #define ARG_GLOBAL 3 211 #define ARG_LOCAL 4 212 #define ARG_LABEL 5 213 214 #define ASYNC_GLOBAL 1 215 #define ASYNC_LOCAL 2 216 217 enum {FFT_LIB=0, PFFT_LIB, VDSP_LIB}; 218 enum {FFT_FWD=0, FFT_INV}; 219 220 /* advance declaration for 221 API message queue struct 222 */ 223 struct _message_queue; 224 225 typedef struct CORFIL { 226 char *body; 227 unsigned int len; 228 unsigned int p; 229 } CORFIL; 230 231 typedef struct { 232 int odebug; 233 int sfread, sfwrite, sfheader, filetyp; 234 int inbufsamps, outbufsamps; 235 int informat, outformat; 236 int sfsampsize; 237 int displays, graphsoff, postscript, msglevel; 238 int Beatmode, oMaxLag; 239 int usingcscore, Linein; 240 int RTevents, Midiin, FMidiin, RMidiin; 241 int ringbell, termifend; 242 int rewrt_hdr, heartbeat, gen01defer; 243 double cmdTempo; 244 float sr_override, kr_override; 245 int nchnls_override, nchnls_i_override; 246 char *infilename, *outfilename; 247 CORFIL *playscore; 248 char *Linename, *Midiname, *FMidiname; 249 char *Midioutname; /* jjk 09252000 - MIDI output device, -Q option */ 250 char *FMidioutname; 251 int midiKey, midiKeyCps, midiKeyOct, midiKeyPch; 252 int midiVelocity, midiVelocityAmp; 253 int noDefaultPaths; /* syy - Oct 25, 2006: for disabling relative paths 254 from files */ 255 int numThreads; 256 int syntaxCheckOnly; 257 int useCsdLineCounts; 258 int sampleAccurate; /* switch for score events sample accuracy */ 259 int realtime; /* realtime priority mode */ 260 MYFLT e0dbfs_override; 261 int daemon; 262 double quality; /* for ogg encoding */ 263 int ksmps_override; 264 int fft_lib; 265 int echo; 266 } OPARMS; 267 268 typedef struct arglst { 269 int count; 270 char *arg[1]; 271 } ARGLST; 272 273 typedef struct arg { 274 int type; 275 void* argPtr; 276 int index; 277 struct arg* next; 278 } ARG; 279 // typedef struct argoffs { 280 // int count; 281 // int indx[1]; 282 // } ARGOFFS; 283 284 typedef struct oentry { 285 char *opname; 286 uint16 dsblksiz; 287 uint16 flags; 288 uint8_t thread; 289 char *outypes; 290 char *intypes; 291 int (*iopadr)(CSOUND *, void *p); 292 int (*kopadr)(CSOUND *, void *p); 293 int (*aopadr)(CSOUND *, void *p); 294 void *useropinfo; /* user opcode parameters */ 295 } OENTRY; 296 297 /** 298 * Storage for parsed orchestra code, for each opcode in an INSTRTXT. 299 */ 300 typedef struct text { 301 uint16_t linenum; /* Line num in orch file (currently buggy!) */ 302 uint64_t locn; /* and location */ 303 OENTRY *oentry; 304 char *opcod; /* Pointer to opcode name in global pool */ 305 ARGLST *inlist; /* Input args (pointer to item in name list) */ 306 ARGLST *outlist; 307 ARG *inArgs; /* Input args (index into list of values) */ 308 unsigned int inArgCount; 309 ARG *outArgs; 310 unsigned int outArgCount; 311 char intype; /* Type of first input argument (g,k,a,w etc) */ 312 char pftype; /* Type of output argument (k,a etc) */ 313 } TEXT; 314 315 316 /** 317 * This struct is filled out by otran() at orch parse time. 318 * It is used as a template for instrument events. 319 */ 320 typedef struct instr { 321 struct op * nxtop; /* Linked list of instr opcodes */ 322 TEXT t; /* Text of instrument (same in nxtop) */ 323 int pmax, vmax, pextrab; /* Arg count, size of data for all 324 opcodes in instr */ 325 //int mdepends; /* Opcode type (i/k/a) */ 326 CS_VAR_POOL* varPool; 327 328 // int optxtcount; 329 int16 muted; 330 // int32 localen; 331 int32 opdstot; /* Total size of opds structs in instr */ 332 // int32 *inslist; /* Only used in parsing (?) */ 333 MYFLT *psetdata; /* Used for pset opcode */ 334 struct insds * instance; /* Chain of allocated instances of 335 this instrument */ 336 struct insds * lst_instance; /* last allocated instance */ 337 struct insds * act_instance; /* Chain of free (inactive) instances */ 338 /* (pointer to next one is INSDS.nxtact) */ 339 struct instr * nxtinstxt; /* Next instrument in orch (num order) */ 340 int active; /* To count activations for control */ 341 int pending_release; /* To count instruments in release phase */ 342 int maxalloc; 343 MYFLT cpuload; /* % load this instrumemnt makes */ 344 struct opcodinfo *opcode_info; /* UDO info (when instrs are UDOs) */ 345 char *insname; /* instrument name */ 346 int instcnt; /* Count number of instances ever */ 347 int isNew; /* is this a new definition */ 348 int nocheckpcnt; /* Control checks on pcnt */ 349 } INSTRTXT; 350 351 typedef struct namedInstr { 352 int32 instno; 353 char *name; 354 INSTRTXT *ip; 355 struct namedInstr *next; 356 } INSTRNAME; 357 358 /** 359 * A chain of TEXT structs. Note that this is identical with the first two 360 * members of struct INSTRTEXT, and is so typecast at various points in code. 361 */ 362 typedef struct op { 363 struct op *nxtop; 364 TEXT t; 365 } OPTXT; 366 367 typedef struct fdch { 368 struct fdch *nxtchp; 369 /** handle returned by csound->FileOpen() */ 370 void *fd; 371 } FDCH; 372 373 typedef struct auxch { 374 struct auxch *nxtchp; 375 size_t size; 376 void *auxp, *endp; 377 } AUXCH; 378 379 /** this callback is used to notify the 380 availability of new storage in AUXCH *. 381 It can be used to swap the old storage 382 for the new one and return it for deallocation. 383 */ 384 typedef AUXCH* (*aux_cb)(CSOUND *, void *, AUXCH *); 385 386 /** 387 * AuxAllocAsync data 388 */ 389 typedef struct { 390 CSOUND *csound; 391 size_t nbytes; 392 AUXCH *auxchp; 393 void *userData; 394 aux_cb notify; 395 } AUXASYNC; 396 397 typedef struct { 398 int dimensions; 399 int* sizes; /* size of each dimensions */ 400 int arrayMemberSize; 401 CS_TYPE* arrayType; 402 MYFLT* data; 403 size_t allocated; 404 // AUXCH aux; 405 } ARRAYDAT; 406 407 typedef struct { 408 int size; /* 0...size-1 */ 409 MYFLT *data; 410 AUXCH aux; 411 } TABDAT; 412 413 typedef struct { 414 char *data; 415 int size; 416 } STRINGDAT; 417 418 typedef struct monblk { 419 int16 pch; 420 struct monblk *prv; 421 } MONPCH; 422 423 typedef struct { 424 int notnum[4]; 425 } DPEXCL; 426 427 typedef struct { 428 DPEXCL dpexcl[8]; 429 /** for keys 25-99 */ 430 int exclset[75]; 431 } DPARM; 432 433 typedef struct dklst { 434 struct dklst *nxtlst; 435 int32 pgmno; 436 /** cnt + keynos */ 437 MYFLT keylst[1]; 438 } DKLST; 439 440 typedef struct mchnblk { 441 /** most recently received program change */ 442 int16 pgmno; 443 /** instrument number assigned to this channel */ 444 int16 insno; 445 int16 RegParNo; 446 int16 mono; 447 MONPCH *monobas; 448 MONPCH *monocur; 449 /** list of active notes (NULL: not active) */ 450 struct insds *kinsptr[128]; 451 /** polyphonic pressure indexed by note number */ 452 MYFLT polyaft[128]; 453 /** ... with GS vib_rate, stored in c128-c135 */ 454 MYFLT ctl_val[136]; 455 /** program change to instr number (<=0: ignore) */ 456 int16 pgm2ins[128]; 457 /** channel pressure (0-127) */ 458 MYFLT aftouch; 459 /** pitch bend (-1 to 1) */ 460 MYFLT pchbend; 461 /** pitch bend sensitivity in semitones */ 462 MYFLT pbensens; 463 /** number of held (sustaining) notes */ 464 int16 ksuscnt; 465 /** current state of sustain pedal (0: off) */ 466 int16 sustaining; 467 int dpmsb; 468 int dplsb; 469 int datenabl; 470 /** chain of dpgm keylists */ 471 DKLST *klists; 472 /** drumset params */ 473 DPARM *dparms; 474 } MCHNBLK; 475 476 /** 477 * This struct holds the data for one score event. 478 */ 479 typedef struct event { 480 /** String argument(s) (NULL if none) */ 481 int scnt; 482 char *strarg; 483 /* instance pointer */ 484 void *pinstance; /* used in nstance opcode */ 485 /** Event type */ 486 char opcod; 487 /** Number of p-fields */ 488 int16 pcnt; 489 /** Event start time */ 490 MYFLT p2orig; 491 /** Length */ 492 MYFLT p3orig; 493 /** All p-fields for this event (SSTRCOD: string argument) */ 494 MYFLT p[PMAX + 1]; 495 union { /* To ensure size is same as earlier */ 496 MYFLT *extra; 497 MYFLT p[2]; 498 } c; 499 } EVTBLK; 500 /** 501 * This struct holds the info for a concrete instrument event 502 * instance in performance. 503 */ 504 typedef struct insds { 505 /* Chain of init-time opcodes */ 506 struct opds * nxti; 507 /* Chain of performance-time opcodes */ 508 struct opds * nxtp; 509 /* Next allocated instance */ 510 struct insds * nxtinstance; 511 /* Previous allocated instance */ 512 struct insds * prvinstance; 513 /* Next in list of active instruments */ 514 struct insds * nxtact; 515 /* Previous in list of active instruments */ 516 struct insds * prvact; 517 /* Next instrument to terminate */ 518 struct insds * nxtoff; 519 /* Chain of files used by opcodes in this instr */ 520 FDCH *fdchp; 521 /* Extra memory used by opcodes in this instr */ 522 AUXCH *auxchp; 523 /* Extra release time requested with xtratim opcode */ 524 int xtratim; 525 /* MIDI note info block if event started from MIDI */ 526 MCHNBLK *m_chnbp; 527 /* ptr to next overlapping MIDI voice */ 528 struct insds * nxtolap; 529 /* Instrument number */ 530 int16 insno; 531 /* Instrument def address */ 532 INSTRTXT *instr; 533 /* non-zero for sustaining MIDI note */ 534 int16 m_sust; 535 /* MIDI pitch, for simple access */ 536 unsigned char m_pitch; 537 /* ...ditto velocity */ 538 unsigned char m_veloc; 539 /* Flag to indicate we are releasing, test with release opcode */ 540 char relesing; 541 /* Set if instr instance is active (perfing) */ 542 char actflg; 543 /* Time to turn off event, in score beats */ 544 double offbet; 545 /* Time to turn off event, in seconds (negative on indef/tie) */ 546 double offtim; 547 /* Python namespace for just this instance. */ 548 void *pylocal; 549 /* pointer to Csound engine and API for externals */ 550 CSOUND *csound; 551 uint64_t kcounter; 552 unsigned int ksmps; /* Instrument copy of ksmps */ 553 MYFLT ekr; /* and of rates */ 554 MYFLT onedksmps, onedkr, kicvt; 555 struct opds *pds; /* Used for jumping */ 556 MYFLT scratchpad[4]; /* Persistent data */ 557 558 /* user defined opcode I/O buffers */ 559 void *opcod_iobufs; 560 void *opcod_deact, *subins_deact; 561 /* opcodes to be run at note deactivation */ 562 void *nxtd; 563 uint32_t ksmps_offset; /* ksmps offset for sample accuracy */ 564 uint32_t no_end; /* samps left at the end for sample accuracy 565 (calculated) */ 566 uint32_t ksmps_no_end; /* samps left at the end for sample accuracy 567 (used by opcodes) */ 568 MYFLT *spin; /* offset into csound->spin */ 569 MYFLT *spout; /* offset into csound->spout, or local spout */ 570 int init_done; 571 int tieflag; 572 int reinitflag; 573 MYFLT retval; 574 MYFLT *lclbas; /* base for variable memory pool */ 575 char *strarg; /* string argument */ 576 /* Copy of required p-field values for quick access */ 577 CS_VAR_MEM p0; 578 CS_VAR_MEM p1; 579 CS_VAR_MEM p2; 580 CS_VAR_MEM p3; 581 } INSDS; 582 583 #define CS_KSMPS (p->h.insdshead->ksmps) 584 #define CS_KCNT (p->h.insdshead->kcounter) 585 #define CS_EKR (p->h.insdshead->ekr) 586 #define CS_ONEDKSMPS (p->h.insdshead->onedksmps) 587 #define CS_ONEDKR (p->h.insdshead->onedkr) 588 #define CS_KICVT (p->h.insdshead->kicvt) 589 #define CS_ESR (csound->esr) 590 #define CS_PDS (p->h.insdshead->pds) 591 #define CS_SPIN (p->h.insdshead->spin) 592 #define CS_SPOUT (p->h.insdshead->spout) 593 typedef int (*SUBR)(CSOUND *, void *); 594 595 /** 596 * This struct holds the info for one opcode in a concrete 597 * instrument instance in performance. 598 */ 599 typedef struct opds { 600 /** Next opcode in init-time chain */ 601 struct opds * nxti; 602 /** Next opcode in perf-time chain */ 603 struct opds * nxtp; 604 /** Initialization (i-time) function pointer */ 605 SUBR iopadr; 606 /** Perf-time (k- or a-rate) function pointer */ 607 SUBR opadr; 608 /** Orch file template part for this opcode */ 609 OPTXT *optext; 610 /** Owner instrument instance data structure */ 611 INSDS *insdshead; 612 } OPDS; 613 614 typedef struct lblblk { 615 OPDS h; 616 OPDS *prvi; 617 OPDS *prvp; 618 } LBLBLK; 619 620 typedef struct { 621 MYFLT *begp, *curp, *endp, feedback[6]; 622 int32 scount; 623 } OCTDAT; 624 625 typedef struct { 626 int32 npts, nocts, nsamps; 627 MYFLT lofrq, hifrq, looct, srate; 628 OCTDAT octdata[MAXOCTS]; 629 AUXCH auxch; 630 } DOWNDAT; 631 632 typedef struct { 633 uint32_t ktimstamp, ktimprd; 634 int32 npts, nfreqs, dbout; 635 DOWNDAT *downsrcp; 636 AUXCH auxch; 637 } SPECDAT; 638 639 640 641 typedef struct { 642 MYFLT gen01; 643 MYFLT ifilno; 644 MYFLT iskptim; 645 MYFLT iformat; 646 MYFLT channel; 647 MYFLT sample_rate; 648 char strarg[SSTRSIZ]; 649 } GEN01ARGS; 650 651 typedef struct { 652 /** table length, not including the guard point */ 653 uint32_t flen; 654 /** length mask ( = flen - 1) for power of two table size, 0 otherwise */ 655 int32 lenmask; 656 /** log2(MAXLEN / flen) for power of two table size, 0 otherwise */ 657 int32 lobits; 658 /** 2^lobits - 1 */ 659 int32 lomask; 660 /** 1 / 2^lobits */ 661 MYFLT lodiv; 662 /** LOFACT * (table_sr / orch_sr), cpscvt = cvtbas / base_freq */ 663 MYFLT cvtbas, cpscvt; 664 /** sustain loop mode (0: none, 1: forward, 2: forward and backward) */ 665 int16 loopmode1; 666 /** release loop mode (0: none, 1: forward, 2: forward and backward) */ 667 int16 loopmode2; 668 /** sustain loop start and end in sample frames */ 669 int32 begin1, end1; 670 /** release loop start and end in sample frames */ 671 int32 begin2, end2; 672 /** sound file length in sample frames (flenfrms = soundend - 1) */ 673 int32 soundend, flenfrms; 674 /** number of channels */ 675 int32 nchanls; 676 /** table number */ 677 int32 fno; 678 /** args */ 679 MYFLT args[PMAX - 4]; 680 /** arg count */ 681 int argcnt; 682 /** GEN01 parameters */ 683 GEN01ARGS gen01args; 684 /** table data (flen + 1 MYFLT values) */ 685 MYFLT *ftable; 686 } FUNC; 687 688 typedef struct { 689 CSOUND *csound; 690 int32 flen; 691 int fno, guardreq; 692 EVTBLK e; 693 } FGDATA; 694 695 typedef struct { 696 char *name; 697 int (*fn)(FGDATA *, FUNC *); 698 } NGFENS; 699 700 typedef int (*GEN)(FGDATA *, FUNC *); 701 702 typedef struct MEMFIL { 703 char filename[256]; /* Made larger RWD */ 704 char *beginp; 705 char *endp; 706 int32 length; 707 struct MEMFIL *next; 708 } MEMFIL; 709 710 typedef struct { 711 int16 type; 712 int16 chan; 713 int16 dat1; 714 int16 dat2; 715 } MEVENT; 716 717 typedef struct SNDMEMFILE_ { 718 /** file ID (short name) */ 719 char *name; 720 struct SNDMEMFILE_ *nxt; 721 /** full path filename */ 722 char *fullName; 723 /** file length in sample frames */ 724 size_t nFrames; 725 /** sample rate in Hz */ 726 double sampleRate; 727 /** number of channels */ 728 int nChannels; 729 /** AE_SHORT, AE_FLOAT, etc. */ 730 int sampleFormat; 731 /** TYP_WAV, TYP_AIFF, etc. */ 732 int fileType; 733 /** 734 * loop mode: 735 * 0: no loop information 736 * 1: off 737 * 2: forward 738 * 3: backward 739 * 4: bidirectional 740 */ 741 int loopMode; 742 /** playback start offset frames */ 743 double startOffs; 744 /** loop start (sample frames) */ 745 double loopStart; 746 /** loop end (sample frames) */ 747 double loopEnd; 748 /** base frequency (in Hz) */ 749 double baseFreq; 750 /** amplitude scale factor */ 751 double scaleFac; 752 /** interleaved sample data */ 753 float data[1]; 754 } SNDMEMFILE; 755 756 typedef struct pvx_memfile_ { 757 char *filename; 758 struct pvx_memfile_ *nxt; 759 float *data; 760 uint32 nframes; 761 int format; 762 int fftsize; 763 int overlap; 764 int winsize; 765 int wintype; 766 int chans; 767 MYFLT srate; 768 } PVOCEX_MEMFILE; 769 770 #ifdef __BUILDING_LIBCSOUND 771 772 #define INSTR 1 773 #define ENDIN 2 774 #define OPCODE 3 775 #define ENDOP 4 776 #define LABEL 5 777 #define SETBEG 6 778 #define PSET 6 779 #define USEROPCODE 7 780 #define SETEND 8 781 782 #define TOKMAX 50L /* Should be 50 but bust */ 783 784 /* max number of input/output args for user defined opcodes */ 785 #define OPCODENUMOUTS_LOW 16 786 #define OPCODENUMOUTS_HIGH 64 787 #define OPCODENUMOUTS_MAX 256 788 789 #define MBUFSIZ (4096) 790 #define MIDIINBUFMAX (1024) 791 #define MIDIINBUFMSK (MIDIINBUFMAX-1) 792 793 #define MIDIMAXPORTS (64) 794 795 typedef union { 796 uint32 dwData; 797 unsigned char bData[4]; 798 } MIDIMESSAGE; 799 800 /* MIDI globals */ 801 802 typedef struct midiglobals { 803 MEVENT *Midevtblk; 804 int sexp; 805 int MIDIoutDONE; 806 int MIDIINbufIndex; 807 MIDIMESSAGE MIDIINbuffer2[MIDIINBUFMAX]; 808 int (*MidiInOpenCallback)(CSOUND *, void **, const char *); 809 int (*MidiReadCallback)(CSOUND *, void *, unsigned char *, int); 810 int (*MidiInCloseCallback)(CSOUND *, void *); 811 int (*MidiOutOpenCallback)(CSOUND *, void **, const char *); 812 int (*MidiWriteCallback)(CSOUND *, void *, const unsigned char *, int); 813 int (*MidiOutCloseCallback)(CSOUND *, void *); 814 const char *(*MidiErrorStringCallback)(int); 815 void *midiInUserData; 816 void *midiOutUserData; 817 void *midiFileData; 818 void *midiOutFileData; 819 int rawControllerMode; 820 char muteTrackList[256]; 821 unsigned char mbuf[MBUFSIZ]; 822 unsigned char *bufp, *endatp; 823 int16 datreq, datcnt; 824 } MGLOBAL; 825 826 typedef struct eventnode { 827 struct eventnode *nxt; 828 uint32 start_kcnt; 829 EVTBLK evt; 830 } EVTNODE; 831 832 typedef struct { 833 OPDS h; 834 MYFLT *ktempo, *istartempo; 835 MYFLT prvtempo; 836 } TEMPO; 837 838 /* typedef struct token { */ 839 /* char *str; */ 840 /* int16 prec; */ 841 /* } TOKEN; */ 842 843 typedef struct names { 844 char *mac; 845 struct names *next; 846 } NAMES; 847 848 typedef struct threadInfo { 849 struct threadInfo *next; 850 void * threadId; 851 } THREADINFO; 852 853 #include "sort.h" 854 #include "text.h" 855 #include "prototyp.h" 856 #include "cwindow.h" 857 #include "envvar.h" 858 #include "remote.h" 859 860 #define CS_STATE_PRE (1) 861 #define CS_STATE_COMP (2) 862 #define CS_STATE_UTIL (4) 863 #define CS_STATE_CLN (8) 864 #define CS_STATE_JMP (16) 865 866 /* These are used to set/clear bits in csound->tempStatus. 867 If the bit is set, it indicates that the given file is 868 a temporary. */ 869 extern const uint32_t csOrcMask; 870 extern const uint32_t csScoInMask; 871 extern const uint32_t csScoSortMask; 872 extern const uint32_t csMidiScoMask; 873 extern const uint32_t csPlayScoMask; 874 875 /* kperf function protoypes. Used by the debugger to switch between debug 876 * and nodebug kperf functions */ 877 int kperf_nodebug(CSOUND *csound); 878 int kperf_debug(CSOUND *csound); 879 880 #endif /* __BUILDING_LIBCSOUND */ 881 882 #define MARGS (3) 883 #define MAX_INCLUDE_DEPTH 100 884 struct MACRO; 885 886 typedef struct MACRON { 887 int n; 888 unsigned int line; 889 struct MACRO *s; 890 char *path; 891 } MACRON; 892 893 typedef struct MACRO { /* To store active macros */ 894 char *name; /* Use is by name */ 895 int acnt; /* Count of arguments */ 896 char *body; /* The text of the macro */ 897 struct MACRO *next; /* Chain of active macros */ 898 int margs; /* amount of space for args */ 899 char *arg[MARGS]; /* With these arguments */ 900 } MACRO; 901 902 typedef struct in_stack_s { /* Stack of active inputs */ 903 int16 is_marked_repeat; /* 1 if this input created by 'n' stmnt */ 904 int16 args; /* Argument count for macro */ 905 //CORFIL *cf; /* In core file */ 906 //void *fd; /* for closing stream */ 907 MACRO *mac; 908 int line; 909 int32 oposit; 910 } IN_STACK; 911 912 typedef struct marked_sections { 913 char *name; 914 int32 posit; 915 int line; 916 } MARKED_SECTIONS; 917 918 typedef struct namelst { 919 char *name; 920 struct namelst *next; 921 } NAMELST; 922 923 typedef struct NAME__ { 924 char *namep; 925 struct NAME__ *nxt; 926 int type, count; 927 } NAME; 928 929 /* Holds UDO information, when an instrument is 930 defined as a UDO 931 */ 932 typedef struct opcodinfo { 933 int32 instno; 934 char *name, *intypes, *outtypes; 935 int16 inchns, outchns; 936 CS_VAR_POOL* out_arg_pool; 937 CS_VAR_POOL* in_arg_pool; 938 INSTRTXT *ip; 939 struct opcodinfo *prv; 940 } OPCODINFO; 941 942 /** 943 * This struct will hold the current engine state after compilation 944 */ 945 typedef struct engine_state { 946 CS_VAR_POOL *varPool; /* global variable pool */ 947 CS_HASH_TABLE *constantsPool; 948 CS_HASH_TABLE *stringPool; 949 int maxopcno; 950 INSTRTXT **instrtxtp; /* instrument list */ 951 INSTRTXT instxtanchor; 952 CS_HASH_TABLE *instrumentNames; /* instrument names */ 953 int maxinsno; 954 } ENGINE_STATE; 955 956 957 /** 958 * Nen FFT interface 959 */ 960 typedef struct _FFT_SETUP{ 961 int N, M; 962 void *setup; 963 MYFLT *buffer; 964 int lib; 965 int d; 966 int p2; 967 } CSOUND_FFT_SETUP; 968 969 970 /** 971 * plugin module info 972 */ 973 typedef struct { 974 char module[12]; 975 char type[12]; 976 } MODULE_INFO; 977 978 979 #define MAX_ALLOC_QUEUE 1024 980 981 typedef struct _alloc_data_ { 982 int type; 983 int insno; 984 EVTBLK blk; 985 MCHNBLK *chn; 986 MEVENT mep; 987 INSDS *ip; 988 OPDS *ids; 989 } ALLOC_DATA; 990 991 #define MAX_MESSAGE_STR 1024 992 typedef struct _message_queue_t_ { 993 int attr; 994 char str[MAX_MESSAGE_STR]; 995 } message_string_queue_t; 996 997 998 #include "find_opcode.h" 999 1000 /** 1001 * Contains all function pointers, data, and data pointers required 1002 * to run one instance of Csound. 1003 * 1004 * \b PUBLIC functions in CSOUND_ 1005 * These are used by plugins to access the 1006 * Csound library functionality without the requirement 1007 * of compile-time linkage to the csound library 1008 * New functions only need to be added here if 1009 * they are required by plugins. 1010 */ 1011 struct CSOUND_ { 1012 1013 /** @name Attributes */ 1014 /**@{ */ 1015 MYFLT (*GetSr)(CSOUND *); 1016 MYFLT (*GetKr)(CSOUND *); 1017 uint32_t (*GetKsmps)(CSOUND *); 1018 /** Get number of output channels */ 1019 uint32_t (*GetNchnls)(CSOUND *); 1020 /** Get number of input channels */ 1021 uint32_t (*GetNchnls_i)(CSOUND *); 1022 MYFLT (*Get0dBFS) (CSOUND *); 1023 /** Get number of control blocks elapsed */ 1024 uint64_t (*GetKcounter)(CSOUND *); 1025 int64_t (*GetCurrentTimeSamples)(CSOUND *); 1026 long (*GetInputBufferSize)(CSOUND *); 1027 long (*GetOutputBufferSize)(CSOUND *); 1028 MYFLT *(*GetInputBuffer)(CSOUND *); 1029 MYFLT *(*GetOutputBuffer)(CSOUND *); 1030 /** Set internal debug mode */ 1031 void (*SetDebug)(CSOUND *, int d); 1032 int (*GetDebug)(CSOUND *); 1033 int (*GetSizeOfMYFLT)(void); 1034 void (*GetOParms)(CSOUND *, OPARMS *); 1035 /** Get environment variable */ 1036 const char *(*GetEnv)(CSOUND *, const char *name); 1037 /**@}*/ 1038 /** @name Message printout */ 1039 /**@{ */ 1040 CS_PRINTF2 void (*Message)(CSOUND *, const char *fmt, ...); 1041 CS_PRINTF3 void (*MessageS)(CSOUND *, int attr, const char *fmt, ...); 1042 void (*MessageV)(CSOUND *, int attr, const char *format, va_list args); 1043 int (*GetMessageLevel)(CSOUND *); 1044 void (*SetMessageLevel)(CSOUND *, int messageLevel); 1045 void (*SetMessageCallback)(CSOUND *, 1046 void (*csoundMessageCallback)(CSOUND *, 1047 int attr, const char *format, 1048 va_list valist)); 1049 /**@}*/ 1050 /** @name Event and MIDI functionality for opcodes */ 1051 /**@{ */ 1052 int (*SetReleaseLength)(void *p, int n); 1053 MYFLT (*SetReleaseLengthSeconds)(void *p, MYFLT n); 1054 int (*GetMidiChannelNumber)(void *p); 1055 MCHNBLK *(*GetMidiChannel)(void *p); 1056 int (*GetMidiNoteNumber)(void *p); 1057 int (*GetMidiVelocity)(void *p); 1058 int (*GetReleaseFlag)(void *p); 1059 double (*GetOffTime)(void *p); 1060 MYFLT *(*GetPFields)(void *p); 1061 int (*GetInstrumentNumber)(void *p); 1062 int (*GetZakBounds)(CSOUND *, MYFLT **); 1063 int (*GetTieFlag)(CSOUND *); 1064 int (*GetReinitFlag)(CSOUND *); 1065 /** Current maximum number of strings, accessible through the strset 1066 and strget opcodes */ 1067 int (*GetStrsmax)(CSOUND *); 1068 char *(*GetStrsets)(CSOUND *, long); 1069 /* Fast power of two function from a precomputed table */ 1070 MYFLT (*Pow2)(CSOUND *, MYFLT a); 1071 /* Fast power function for positive integers */ 1072 MYFLT (*intpow)(MYFLT, int32); 1073 /* Returns a string name for the file type */ 1074 char *(*type2string)(int type); 1075 /**@}*/ 1076 /** @name Arguments to opcodes */ 1077 /**@{ */ 1078 CS_TYPE *(*GetTypeForArg)(void *p); 1079 int (*GetInputArgCnt)(void *p); 1080 char *(*GetInputArgName)(void *p, int n); 1081 int (*GetOutputArgCnt)(void *p); 1082 char *(*GetOutputArgName)(void *p, int n); 1083 char *(*GetString)(CSOUND *, MYFLT); 1084 int32 (*strarg2insno)(CSOUND *, void *p, int is_string); 1085 char *(*strarg2name)(CSOUND *, char *, void *, const char *, int); 1086 1087 /**@}*/ 1088 /** @name Memory allocation */ 1089 /**@{ */ 1090 void (*AuxAlloc)(CSOUND *, size_t nbytes, AUXCH *auxchp); 1091 void *(*Malloc)(CSOUND *, size_t nbytes); 1092 void *(*Calloc)(CSOUND *, size_t nbytes); 1093 void *(*ReAlloc)(CSOUND *, void *oldp, size_t nbytes); 1094 char *(*Strdup)(CSOUND *, char*); 1095 void (*Free)(CSOUND *, void *ptr); 1096 1097 /**@}*/ 1098 /** @name Function tables */ 1099 /**@{ */ 1100 int (*hfgens)(CSOUND *, FUNC **, const EVTBLK *, int); 1101 int (*FTAlloc)(CSOUND *, int tableNum, int len); 1102 int (*FTDelete)(CSOUND *, int tableNum); 1103 /** Find tables with power of two size. If table exists but is 1104 not a power of 2, NULL is returned. */ 1105 FUNC *(*FTFind)(CSOUND *, MYFLT *argp); 1106 /** Find any table, except deferred load tables. */ 1107 FUNC *(*FTFindP)(CSOUND *, MYFLT *argp); 1108 /** Find any table. */ 1109 FUNC *(*FTnp2Find)(CSOUND *, MYFLT *argp); 1110 int (*GetTable)(CSOUND *, MYFLT **tablePtr, int tableNum); 1111 int (*TableLength)(CSOUND *, int table); 1112 MYFLT (*TableGet)(CSOUND *, int table, int index); 1113 void (*TableSet)(CSOUND *, int table, int index, MYFLT value); 1114 void *(*GetNamedGens)(CSOUND *); 1115 1116 /**@}*/ 1117 /** @name Global and config variable manipulation */ 1118 /**@{ */ 1119 int (*CreateGlobalVariable)(CSOUND *, const char *name, size_t nbytes); 1120 void *(*QueryGlobalVariable)(CSOUND *, const char *name); 1121 void *(*QueryGlobalVariableNoCheck)(CSOUND *, const char *name); 1122 int (*DestroyGlobalVariable)(CSOUND *, const char *name); 1123 int (*CreateConfigurationVariable)(CSOUND *, const char *name, 1124 void *p, int type, int flags, 1125 void *min, void *max, 1126 const char *shortDesc, 1127 const char *longDesc); 1128 int (*SetConfigurationVariable)(CSOUND *, const char *name, void *value); 1129 int (*ParseConfigurationVariable)(CSOUND *, 1130 const char *name, const char *value); 1131 csCfgVariable_t *(*QueryConfigurationVariable)(CSOUND *, const char *name); 1132 csCfgVariable_t **(*ListConfigurationVariables)(CSOUND *); 1133 int (*DeleteConfigurationVariable)(CSOUND *, const char *name); 1134 const char *(*CfgErrorCodeToString)(int errcode); 1135 1136 /**@}*/ 1137 /** @name FFT support */ 1138 /**@{ */ 1139 MYFLT (*GetInverseComplexFFTScale)(CSOUND *, int FFTsize); 1140 MYFLT (*GetInverseRealFFTScale)(CSOUND *, int FFTsize); 1141 void (*ComplexFFT)(CSOUND *, MYFLT *buf, int FFTsize); 1142 void (*InverseComplexFFT)(CSOUND *, MYFLT *buf, int FFTsize); 1143 void (*RealFFT)(CSOUND *, MYFLT *buf, int FFTsize); 1144 void (*InverseRealFFT)(CSOUND *, MYFLT *buf, int FFTsize); 1145 void (*RealFFTMult)(CSOUND *, MYFLT *outbuf, MYFLT *buf1, MYFLT *buf2, 1146 int FFTsize, MYFLT scaleFac); 1147 void (*RealFFTnp2)(CSOUND *, MYFLT *buf, int FFTsize); 1148 void (*InverseRealFFTnp2)(CSOUND *, MYFLT *buf, int FFTsize); 1149 1150 /**@}*/ 1151 /** @name PVOC-EX system */ 1152 /**@{ */ 1153 int (*PVOC_CreateFile)(CSOUND *, const char *, 1154 uint32, uint32, uint32, 1155 uint32, int32, int, int, 1156 float, float *, uint32); 1157 int (*PVOC_OpenFile)(CSOUND *, const char *, void *, void *); 1158 int (*PVOC_CloseFile)(CSOUND *, int); 1159 int (*PVOC_PutFrames)(CSOUND *, int, const float *, int32); 1160 int (*PVOC_GetFrames)(CSOUND *, int, float *, uint32); 1161 int (*PVOC_FrameCount)(CSOUND *, int); 1162 int (*PVOC_fseek)(CSOUND *, int, int); 1163 const char *(*PVOC_ErrorString)(CSOUND *); 1164 int (*PVOCEX_LoadFile)(CSOUND *, const char *, PVOCEX_MEMFILE *); 1165 1166 /**@}*/ 1167 /** @name Error messages */ 1168 /**@{ */ 1169 CS_NORETURN CS_PRINTF2 void (*Die)(CSOUND *, const char *msg, ...); 1170 CS_PRINTF2 int (*InitError)(CSOUND *, const char *msg, ...); 1171 CS_PRINTF3 int (*PerfError)(CSOUND *, OPDS *h, const char *msg, ...); 1172 CS_PRINTF2 void (*Warning)(CSOUND *, const char *msg, ...); 1173 CS_PRINTF2 void (*DebugMsg)(CSOUND *, const char *msg, ...); 1174 CS_NORETURN void (*LongJmp)(CSOUND *, int); 1175 CS_PRINTF2 void (*ErrorMsg)(CSOUND *, const char *fmt, ...); 1176 void (*ErrMsgV)(CSOUND *, const char *hdr, const char *fmt, va_list); 1177 1178 /**@}*/ 1179 /** @name Random numbers */ 1180 /**@{ */ 1181 uint32_t (*GetRandomSeedFromTime)(void); 1182 void (*SeedRandMT)(CsoundRandMTState *p, 1183 const uint32_t *initKey, uint32_t keyLength); 1184 uint32_t (*RandMT)(CsoundRandMTState *p); 1185 int (*Rand31)(int *seedVal); 1186 int (*GetRandSeed)(CSOUND *, int which); 1187 1188 /**@}*/ 1189 /** @name Threads and locks */ 1190 /**@{ */ 1191 void *(*CreateThread)(uintptr_t (*threadRoutine)(void *), void *userdata); 1192 uintptr_t (*JoinThread)(void *thread); 1193 void *(*CreateThreadLock)(void); 1194 void (*DestroyThreadLock)(void *lock); 1195 int (*WaitThreadLock)(void *lock, size_t milliseconds); 1196 void (*NotifyThreadLock)(void *lock); 1197 void (*WaitThreadLockNoTimeout)(void *lock); 1198 void *(*Create_Mutex)(int isRecursive); 1199 int (*LockMutexNoWait)(void *mutex_); 1200 void (*LockMutex)(void *mutex_); 1201 void (*UnlockMutex)(void *mutex_); 1202 void (*DestroyMutex)(void *mutex_); 1203 void *(*CreateBarrier)(unsigned int max); 1204 int (*DestroyBarrier)(void *); 1205 int (*WaitBarrier)(void *); 1206 void *(*GetCurrentThreadID)(void); 1207 void (*Sleep)(size_t milliseconds); 1208 void (*InitTimerStruct)(RTCLOCK *); 1209 double (*GetRealTime)(RTCLOCK *); 1210 double (*GetCPUTime)(RTCLOCK *); 1211 1212 /**@}*/ 1213 /** @name Circular lock-free buffer */ 1214 /**@{ */ 1215 void *(*CreateCircularBuffer)(CSOUND *, int, int); 1216 int (*ReadCircularBuffer)(CSOUND *, void *, void *, int); 1217 int (*WriteCircularBuffer)(CSOUND *, void *, const void *, int); 1218 void (*FlushCircularBuffer)(CSOUND *, void *); 1219 void (*DestroyCircularBuffer)(CSOUND *, void *); 1220 1221 /**@}*/ 1222 /** @name File access */ 1223 /**@{ */ 1224 char *(*FindInputFile)(CSOUND *, const char *filename, const char *envList); 1225 char *(*FindOutputFile)(CSOUND *, 1226 const char *filename, const char *envList); 1227 void *(*SAsndgetset)(CSOUND *, 1228 char *, void *, MYFLT *, MYFLT *, MYFLT *, int); 1229 void *(*sndgetset)(CSOUND *, void *); 1230 int (*getsndin)(CSOUND *, void *, MYFLT *, int, void *); 1231 void (*rewriteheader)(void *ofd); 1232 SNDMEMFILE *(*LoadSoundFile)(CSOUND *, const char *, void *); 1233 void (*FDRecord)(CSOUND *, FDCH *fdchp); 1234 void (*FDClose)(CSOUND *, FDCH *fdchp); 1235 void *(*CreateFileHandle)(CSOUND *, void *, int, const char *); 1236 char *(*GetFileName)(void *); 1237 int (*FileClose)(CSOUND *, void *); 1238 void *(*FileOpen2)(CSOUND *, void *, int, const char *, void *, 1239 const char *, int, int); 1240 int (*type2csfiletype)(int type, int encoding); 1241 void (*NotifyFileOpened)(CSOUND*, const char*, int, int, int); 1242 int (*sftype2csfiletype)(int type); 1243 MEMFIL *(*ldmemfile2withCB)(CSOUND *, const char *, int, 1244 int (*callback)(CSOUND *, MEMFIL *)); 1245 void *(*FileOpenAsync)(CSOUND *, void *, int, const char *, void *, 1246 const char *, int, int, int); 1247 unsigned int (*ReadAsync)(CSOUND *, void *, MYFLT *, int); 1248 unsigned int (*WriteAsync)(CSOUND *, void *, MYFLT *, int); 1249 int (*FSeekAsync)(CSOUND *, void *, int, int); 1250 char *(*getstrformat)(int format); 1251 int (*sfsampsize)(int format); 1252 1253 /**@}*/ 1254 /** @name RT audio IO and callbacks */ 1255 /**@{ */ 1256 void (*SetPlayopenCallback)(CSOUND *, 1257 int (*playopen__)(CSOUND *, const csRtAudioParams *parm)); 1258 void (*SetRtplayCallback)(CSOUND *, 1259 void (*rtplay__)(CSOUND *, const MYFLT *outBuf, int nbytes)); 1260 void (*SetRecopenCallback)(CSOUND *, 1261 int (*recopen__)(CSOUND *, const csRtAudioParams *parm)); 1262 void (*SetRtrecordCallback)(CSOUND *, 1263 int (*rtrecord__)(CSOUND *, MYFLT *inBuf, int nbytes)); 1264 void (*SetRtcloseCallback)(CSOUND *, void (*rtclose__)(CSOUND *)); 1265 void (*SetAudioDeviceListCallback)(CSOUND *csound, 1266 int (*audiodevlist__)(CSOUND *, CS_AUDIODEVICE *list, int isOutput)); 1267 void **(*GetRtRecordUserData)(CSOUND *); 1268 void **(*GetRtPlayUserData)(CSOUND *); 1269 int (*GetDitherMode)(CSOUND *); 1270 /**@}*/ 1271 /** @name RT MIDI and callbacks */ 1272 /**@{ */ 1273 void (*SetExternalMidiInOpenCallback)(CSOUND *, 1274 int (*func)(CSOUND *, void **, const char *)); 1275 void (*SetExternalMidiReadCallback)(CSOUND *, 1276 int (*func)(CSOUND *, void *, unsigned char *, int)); 1277 void (*SetExternalMidiInCloseCallback)(CSOUND *, 1278 int (*func)(CSOUND *, void *)); 1279 void (*SetExternalMidiOutOpenCallback)(CSOUND *, 1280 int (*func)(CSOUND *, void **, const char *)); 1281 void (*SetExternalMidiWriteCallback)(CSOUND *, 1282 int (*func)(CSOUND *, void *, const unsigned char *, int)); 1283 void (*SetExternalMidiOutCloseCallback)(CSOUND *, 1284 int (*func)(CSOUND *, void *)); 1285 void (*SetExternalMidiErrorStringCallback)(CSOUND *, 1286 const char *(*func)(int)); 1287 void (*SetMIDIDeviceListCallback)(CSOUND *csound, 1288 int (*audiodevlist__)(CSOUND *, CS_MIDIDEVICE *list, int isOutput)); 1289 void (*module_list_add)(CSOUND *, char *, char *); 1290 /**@}*/ 1291 /** @name Displays & graphs */ 1292 /**@{ */ 1293 void (*dispset)(CSOUND *, WINDAT *, MYFLT *, int32, char *, int, char *); 1294 void (*display)(CSOUND *, WINDAT *); 1295 int (*dispexit)(CSOUND *); 1296 void (*dispinit)(CSOUND *); 1297 int (*SetIsGraphable)(CSOUND *, int isGraphable); 1298 void (*SetMakeGraphCallback)(CSOUND *, 1299 void (*makeGraphCallback)(CSOUND *, WINDAT *p, 1300 const char *name)); 1301 void (*SetDrawGraphCallback)(CSOUND *, 1302 void (*drawGraphCallback)(CSOUND *, WINDAT *p)); 1303 void (*SetKillGraphCallback)(CSOUND *, 1304 void (*killGraphCallback)(CSOUND *, WINDAT *p)); 1305 void (*SetExitGraphCallback)(CSOUND *, int (*exitGraphCallback)(CSOUND *)); 1306 /**@}*/ 1307 /** @name Generic callbacks */ 1308 /**@{ */ 1309 void (*SetYieldCallback)(CSOUND *, int (*yieldCallback)(CSOUND *)); 1310 int (*Set_KeyCallback)(CSOUND *, int (*func)(void *, void *, unsigned int), 1311 void *userData, unsigned int typeMask); 1312 void (*Remove_KeyCallback)(CSOUND *, 1313 int (*func)(void *, void *, unsigned int)); 1314 int (*RegisterSenseEventCallback)(CSOUND *, void (*func)(CSOUND *, void *), 1315 void *userData); 1316 int (*RegisterDeinitCallback)(CSOUND *, void *p, 1317 int (*func)(CSOUND *, void *)); 1318 int (*RegisterResetCallback)(CSOUND *, void *userData, 1319 int (*func)(CSOUND *, void *)); 1320 void (*SetInternalYieldCallback)(CSOUND *, 1321 int (*yieldCallback)(CSOUND *)); 1322 /**@}*/ 1323 /** @name Opcodes and instruments */ 1324 /**@{ */ 1325 int (*AppendOpcode)(CSOUND *, const char *opname, int dsblksiz, int flags, 1326 int thread, const char *outypes, const char *intypes, 1327 int (*iopadr)(CSOUND *, void *), 1328 int (*kopadr)(CSOUND *, void *), 1329 int (*aopadr)(CSOUND *, void *)); 1330 int (*AppendOpcodes)(CSOUND *, const OENTRY *opcodeList, int n); 1331 char *(*GetOpcodeName)(void *p); 1332 INSTRTXT **(*GetInstrumentList)(CSOUND *); 1333 /**@}*/ 1334 /** @name Events and performance */ 1335 /**@{ */ 1336 int (*CheckEvents)(CSOUND *); 1337 int (*insert_score_event)(CSOUND *, EVTBLK *, double); 1338 int (*insert_score_event_at_sample)(CSOUND *, EVTBLK *, int64_t); 1339 int (*PerformKsmps)(CSOUND *); 1340 /**@}*/ 1341 /** @name Utilities */ 1342 /**@{ */ 1343 int (*AddUtility)(CSOUND *, const char *name, 1344 int (*UtilFunc)(CSOUND *, int, char **)); 1345 int (*RunUtility)(CSOUND *, const char *name, int argc, char **argv); 1346 char **(*ListUtilities)(CSOUND *); 1347 int (*SetUtilityDescription)(CSOUND *, const char *utilName, 1348 const char *utilDesc); 1349 const char *(*GetUtilityDescription)(CSOUND *, const char *utilName); 1350 void (*SetUtilSr)(CSOUND *, MYFLT); 1351 void (*SetUtilNchnls)(CSOUND *, int); 1352 /**@}*/ 1353 /** @name Miscellaneous */ 1354 /**@{ */ 1355 long (*RunCommand)(const char * const *argv, int noWait); 1356 int (*OpenLibrary)(void **library, const char *libraryPath); 1357 int (*CloseLibrary)(void *library); 1358 void *(*GetLibrarySymbol)(void *library, const char *procedureName); 1359 #if defined (__CUDACC__) || defined (__MACH__) 1360 char *(*LocalizeString)(const char *); 1361 #else 1362 char *(*LocalizeString)(const char *) __attribute__ ((format_arg (1))); 1363 #endif 1364 char *(*strtok_r)(char*, char*, char**); 1365 double (*strtod)(char*, char**); 1366 int (*sprintf)(char *str, const char *format, ...); 1367 int (*sscanf)(char *str, const char *format, ...); 1368 MYFLT (*system_sr)(CSOUND *, MYFLT ); 1369 /**@}*/ 1370 /** @name Score Event s*/ 1371 /**@{ */ 1372 MYFLT (*GetScoreOffsetSeconds)(CSOUND *); 1373 void (*SetScoreOffsetSeconds)(CSOUND *, MYFLT offset); 1374 void (*RewindScore)(CSOUND *); 1375 void (*InputMessage)(CSOUND *, const char *message__); 1376 int (*ISSTRCOD)(MYFLT); 1377 void *(*RealFFT2Setup)(CSOUND *csound, 1378 int FFTsize, 1379 int d); 1380 void (*RealFFT2)(CSOUND *csound, 1381 void *p, MYFLT *sig); 1382 int (*ftError)(const FGDATA *, const char *, ...); 1383 MYFLT (*GetA4)(CSOUND *csound); 1384 int (*AuxAllocAsync)(CSOUND *, size_t, AUXCH *, 1385 AUXASYNC *, aux_cb, void *); 1386 void *(*GetHostData)(CSOUND *); 1387 char *(*strNcpy)(char *dst, const char *src, size_t siz); 1388 int (*GetZaBounds)(CSOUND *, MYFLT **); 1389 OENTRY* (*find_opcode_new)(CSOUND*, char*, 1390 char* , char*); 1391 OENTRY* (*find_opcode_exact)(CSOUND*, char*, 1392 char* , char*); 1393 int (*GetChannelPtr)(CSOUND *,MYFLT **, const char *, int); 1394 int (*ListChannels)(CSOUND *, controlChannelInfo_t **); 1395 int (*GetErrorCnt)(CSOUND *); 1396 FUNC* (*FTnp2Finde)(CSOUND*, MYFLT *); 1397 INSTRTXT *(*GetInstrument)(CSOUND*, int, const char *); 1398 MYFLT* (*AutoCorrelation)(CSOUND *, MYFLT*, MYFLT*, int); 1399 void * (*LPsetup)(CSOUND *csound, int N, int M); 1400 void (*LPfree)(CSOUND *csound, void *); 1401 MYFLT* (*LPred)(CSOUND *, void *, MYFLT *); 1402 MYFLT* (*LPCeps)(CSOUND *, MYFLT *, MYFLT *, int, int); 1403 MYFLT* (*CepsLP)(CSOUND *, MYFLT *, MYFLT *, int, int); 1404 MYFLT (*LPrms)(CSOUND *, void *); 1405 /**@}*/ 1406 /** @name Placeholders 1407 To allow the API to grow while maintining backward binary compatibility. */ 1408 /**@{ */ 1409 SUBR dummyfn_2[23]; 1410 /**@}*/ 1411 #ifdef __BUILDING_LIBCSOUND 1412 /* ------- private data (not to be used by hosts or externals) ------- */ 1413 /** @name Private Data 1414 Private Data in the CSOUND struct to be used internally by the Csound 1415 library and should be hidden from plugins. 1416 If a new variable member is needed by the library, add it below, as a 1417 private data member. If access is required solely by plugins (and not 1418 internally by the library), use the CreateGlobalVariable() etc. interface, 1419 instead of adding to CSOUND. 1420 1421 If you find that a plugin needs to access existing private data, 1422 first check above for an existing interface; if none is available, 1423 add one. Please avoid giving full access, or allowing plugins to 1424 change the values of private members, by using one of the two methods 1425 below: 1426 1427 1) To get the data member value: 1428 \code 1429 returnType (*GetVar)(CSOUND *) 1430 \endcode 1431 2) in case of pointers, data should be copied out to a supplied memory 1432 slot, rather than the pointer being obtained: 1433 \code 1434 void (*GetData)(CSOUND *, dataType *) 1435 1436 dataType var; 1437 csound->GetData(csound, &var); 1438 \endcode 1439 */ 1440 /**@{ */ 1441 SUBR first_callback_; 1442 channelCallback_t InputChannelCallback_; 1443 channelCallback_t OutputChannelCallback_; 1444 void (*csoundMessageCallback_)(CSOUND *, int attr, 1445 const char *format, va_list args); 1446 int (*csoundConfigureCallback_)(CSOUND *); 1447 void (*csoundMakeGraphCallback_)(CSOUND *, WINDAT *windat, 1448 const char *name); 1449 void (*csoundDrawGraphCallback_)(CSOUND *, WINDAT *windat); 1450 void (*csoundKillGraphCallback_)(CSOUND *, WINDAT *windat); 1451 int (*csoundExitGraphCallback_)(CSOUND *); 1452 int (*csoundYieldCallback_)(CSOUND *); 1453 void (*cscoreCallback_)(CSOUND *); 1454 void (*FileOpenCallback_)(CSOUND*, const char*, int, int, int); 1455 SUBR last_callback_; 1456 /* these are not saved on RESET */ 1457 int (*playopen_callback)(CSOUND *, const csRtAudioParams *parm); 1458 void (*rtplay_callback)(CSOUND *, const MYFLT *outBuf, int nbytes); 1459 int (*recopen_callback)(CSOUND *, const csRtAudioParams *parm); 1460 int (*rtrecord_callback)(CSOUND *, MYFLT *inBuf, int nbytes); 1461 void (*rtclose_callback)(CSOUND *); 1462 int (*audio_dev_list_callback)(CSOUND *, CS_AUDIODEVICE *, int); 1463 int (*midi_dev_list_callback)(CSOUND *, CS_MIDIDEVICE *, int); 1464 int (*doCsoundCallback)(CSOUND *, void *, unsigned int); 1465 int (*csoundInternalYieldCallback_)(CSOUND *); 1466 /* end of callbacks */ 1467 void (*spinrecv)(CSOUND *); 1468 void (*spoutran)(CSOUND *); 1469 int (*audrecv)(CSOUND *, MYFLT *, int); 1470 void (*audtran)(CSOUND *, const MYFLT *, int); 1471 void *hostdata; 1472 char *orchname, *scorename; 1473 CORFIL *orchstr, *scorestr; 1474 OPDS *ids; /* used by init loops */ 1475 ENGINE_STATE engineState; /* current Engine State merged after 1476 compilation */ 1477 INSTRTXT *instr0; /* instr0 */ 1478 INSTRTXT **dead_instr_pool; 1479 int dead_instr_no; 1480 TYPE_POOL* typePool; 1481 unsigned int ksmps; 1482 uint32_t nchnls; 1483 int inchnls; 1484 int spoutactive; 1485 uint64_t kcounter, global_kcounter; 1486 MYFLT esr; 1487 MYFLT ekr; 1488 /** current time in seconds, inc. per kprd */ 1489 int64_t icurTime; /* Current time in samples */ 1490 double curTime_inc; 1491 /** start time of current section */ 1492 double timeOffs, beatOffs; 1493 /** current time in beats, inc per kprd */ 1494 double curBeat, curBeat_inc; 1495 /** beat time = 60 / tempo */ 1496 int64_t ibeatTime; /* Beat time in samples */ 1497 EVTBLK *currevent; 1498 INSDS *curip; 1499 MYFLT cpu_power_busy; 1500 char *xfilename; 1501 int peakchunks; 1502 int keep_tmp; 1503 CS_HASH_TABLE *opcodes; 1504 int32 nrecs; 1505 FILE* Linepipe; 1506 int Linefd; 1507 void *csoundCallbacks_; 1508 FILE* scfp; 1509 CORFIL *scstr; 1510 FILE* oscfp; 1511 MYFLT maxamp[MAXCHNLS]; 1512 MYFLT smaxamp[MAXCHNLS]; 1513 MYFLT omaxamp[MAXCHNLS]; 1514 uint32 maxpos[MAXCHNLS], smaxpos[MAXCHNLS], omaxpos[MAXCHNLS]; 1515 FILE* scorein; 1516 FILE* scoreout; 1517 int *argoffspace; 1518 INSDS *frstoff; 1519 /** reserved for std opcode library */ 1520 void *stdOp_Env; 1521 int holdrand; 1522 int randSeed1; 1523 int randSeed2; 1524 CsoundRandMTState *csRandState; 1525 RTCLOCK *csRtClock; 1526 int strsmax; 1527 char **strsets; 1528 MYFLT *spin; 1529 MYFLT *spout; 1530 MYFLT *spraw; 1531 int nspin; 1532 int nspout; 1533 MYFLT *auxspin; 1534 OPARMS *oparms; 1535 /** reserve space for up to MIDIMAXPORTS MIDI devices */ 1536 MCHNBLK *m_chnbp[MIDIMAXPORTS*16]; 1537 int dither_output; 1538 MYFLT onedsr, sicvt; 1539 MYFLT tpidsr, pidsr, mpidsr, mtpdsr; 1540 MYFLT onedksmps; 1541 MYFLT onedkr; 1542 MYFLT kicvt; 1543 int reinitflag; 1544 int tieflag; 1545 MYFLT e0dbfs, dbfs_to_float; 1546 double A4; 1547 void *rtRecord_userdata; 1548 void *rtPlay_userdata; 1549 jmp_buf exitjmp; 1550 SRTBLK *frstbp; 1551 int sectcnt; 1552 int inerrcnt, synterrcnt, perferrcnt; 1553 INSDS actanchor; 1554 int32 rngcnt[MAXCHNLS]; 1555 int16 rngflg, multichan; 1556 void *evtFuncChain; 1557 EVTNODE *OrcTrigEvts; /* List of events to be started */ 1558 EVTNODE *freeEvtNodes; 1559 int csoundIsScorePending_; 1560 int64_t advanceCnt; 1561 int initonly; 1562 int evt_poll_cnt; 1563 int evt_poll_maxcnt; 1564 int Mforcdecs, Mxtroffs, MTrkend; 1565 OPCODINFO *opcodeInfo; 1566 FUNC** flist; 1567 int maxfnum; 1568 GEN *gensub; 1569 int genmax; 1570 CS_HASH_TABLE *namedGlobals; 1571 CS_HASH_TABLE *cfgVariableDB; 1572 double prvbt, curbt, nxtbt; 1573 double curp2, nxtim; 1574 int64_t cyclesRemaining; 1575 EVTBLK evt; 1576 void *memalloc_db; 1577 MGLOBAL *midiGlobals; 1578 CS_HASH_TABLE *envVarDB; 1579 MEMFIL *memfiles; 1580 PVOCEX_MEMFILE *pvx_memfiles; 1581 int FFT_max_size; 1582 void *FFT_table_1; 1583 void *FFT_table_2; 1584 /* statics from twarp.c should be TSEG* */ 1585 void *tseg, *tpsave; 1586 /* persistent macros */ 1587 MACRO *orc_macros; 1588 /* Statics from express.c */ 1589 MYFLT *gbloffbas; /* was static in oload.c */ 1590 void *file_io_thread; 1591 int file_io_start; 1592 void *file_io_threadlock; 1593 int realtime_audio_flag; 1594 void *event_insert_thread; 1595 int event_insert_loop; 1596 void *init_pass_threadlock; 1597 void *API_lock; 1598 spin_lock_t spoutlock, spinlock; 1599 spin_lock_t memlock, spinlock1; 1600 char *delayederrormessages; 1601 void *printerrormessagesflag; 1602 struct sread__ { 1603 SRTBLK *bp, *prvibp; /* current srtblk, prev w/same int(p1) */ 1604 char *sp, *nxp; /* string pntrs into srtblk text */ 1605 int op; /* opcode of current event */ 1606 int warpin; /* input format sensor */ 1607 int linpos; /* line position sensor */ 1608 int lincnt; /* count of lines/section in scorefile */ 1609 MYFLT prvp2 /* = -FL(1.0) */; /* Last event time */ 1610 MYFLT clock_base /* = FL(0.0) */; 1611 MYFLT warp_factor /* = FL(1.0) */; 1612 char *curmem; 1613 char *memend; /* end of cur memblk */ 1614 MACRO *unused_ptr2; 1615 int last_name /* = -1 */; 1616 IN_STACK *inputs, *str; 1617 int input_size, input_cnt; 1618 int unused_int3; 1619 int unused_int2; 1620 int linepos /* = -1 */; 1621 MARKED_SECTIONS names[30]; 1622 #define NAMELEN 40 /* array size of repeat macro names */ 1623 #define RPTDEPTH 40 /* size of repeat_n arrays (39 loop levels) */ 1624 char unused_char0[RPTDEPTH][NAMELEN]; 1625 int unused_int4[RPTDEPTH]; 1626 int32 unused_int7[RPTDEPTH]; 1627 int unused_int5; 1628 MACRO *unused_ptr0[RPTDEPTH]; 1629 int unused_int6; 1630 /* Variable for repeat sections */ 1631 char unused_char1[NAMELEN]; 1632 int unused_int8; 1633 int32 unused_int9; 1634 int unused_intA; 1635 MACRO *unused_ptr1; 1636 int nocarry; 1637 } sread; 1638 struct onefileStatics__ { 1639 NAMELST *toremove; 1640 char *orcname; 1641 char *sconame; 1642 char *midname; 1643 int midiSet; 1644 int csdlinecount; 1645 } onefileStatics; 1646 #define LBUFSIZ 32768 1647 struct lineventStatics__ { 1648 char *Linep, *Linebufend; 1649 int stdmode; 1650 EVTBLK prve; 1651 char *Linebuf; 1652 int linebufsiz; 1653 char *orchestra, *orchestrab; 1654 int oflag; 1655 } lineventStatics; 1656 struct musmonStatics__ { 1657 int32 srngcnt[MAXCHNLS], orngcnt[MAXCHNLS]; 1658 int16 srngflg; 1659 int16 sectno; 1660 int lplayed; 1661 int segamps, sormsg; 1662 EVENT **ep, **epend; /* pointers for stepping through lplay list */ 1663 EVENT *lsect; 1664 } musmonStatics; 1665 struct libsndStatics__ { 1666 SNDFILE *outfile; 1667 SNDFILE *infile; 1668 char *sfoutname; /* soundout filename */ 1669 MYFLT *inbuf; 1670 MYFLT *outbuf; /* contin sndio buffers */ 1671 MYFLT *outbufp; /* MYFLT pntr */ 1672 uint32 inbufrem; 1673 uint32 outbufrem; /* in monosamps */ 1674 /* (see openin, iotranset) */ 1675 unsigned int inbufsiz, outbufsiz; /* alloc in sfopenin/out */ 1676 int isfopen; /* (real set in sfopenin) */ 1677 int osfopen; /* (real set in sfopenout) */ 1678 int pipdevin, pipdevout; /* 0: file, 1: pipe, 2: rtaudio */ 1679 uint32 nframes /* = 1UL */; 1680 FILE *pin, *pout; 1681 int dither; 1682 } libsndStatics; 1683 1684 int warped; /* rdscor.c */ 1685 int sstrlen; 1686 char *sstrbuf; 1687 int enableMsgAttr; /* csound.c */ 1688 int sampsNeeded; 1689 MYFLT csoundScoreOffsetSeconds_; 1690 int inChar_; 1691 int isGraphable_; 1692 int delayr_stack_depth; /* ugens6.c */ 1693 void *first_delayr; 1694 void *last_delayr; 1695 int32 revlpsiz[6]; 1696 int32 revlpsum; 1697 double rndfrac; /* aops.c */ 1698 MYFLT *logbase2; 1699 NAMES *omacros, *smacros; 1700 void *namedgen; /* fgens.c */ 1701 void *open_files; /* fileopen.c */ 1702 void *searchPathCache; 1703 CS_HASH_TABLE *sndmemfiles; 1704 void *reset_list; 1705 void *pvFileTable; /* pvfileio.c */ 1706 int pvNumFiles; 1707 int pvErrorCode; 1708 /* database for deferred loading of opcode plugin libraries */ 1709 // void *pluginOpcodeFiles; 1710 int enableHostImplementedAudioIO; 1711 int enableHostImplementedMIDIIO; 1712 int hostRequestedBufferSize; 1713 /* engineStatus is sum of: 1714 * 1 (CS_STATE_PRE): csoundPreCompile was called 1715 * 2 (CS_STATE_COMP): csoundCompile was called 1716 * 4 (CS_STATE_UTIL): csoundRunUtility was called 1717 * 8 (CS_STATE_CLN): csoundCleanup needs to be called 1718 * 16 (CS_STATE_JMP): csoundLongJmp was called 1719 */ 1720 char engineStatus; 1721 /* stdXX_assign_flags can be {1,2,4,8} */ 1722 char stdin_assign_flg; 1723 char stdout_assign_flg; 1724 char orcname_mode; /* 0: normal, 1: ignore, 2: fail */ 1725 int use_only_orchfile; 1726 void *csmodule_db; 1727 char *dl_opcodes_oplibs; 1728 char *SF_csd_licence; 1729 char *SF_id_title; 1730 char *SF_id_copyright; 1731 int SF_id_scopyright; 1732 char *SF_id_software; 1733 char *SF_id_artist; 1734 char *SF_id_comment; 1735 char *SF_id_date; 1736 void *utility_db; 1737 int16 *isintab; /* ugens3.c */ 1738 void *lprdaddr; /* ugens5.c */ 1739 int currentLPCSlot; 1740 int max_lpc_slot; 1741 CS_HASH_TABLE *chn_db; 1742 int opcodedirWasOK; 1743 int disable_csd_options; 1744 CsoundRandMTState randState_; 1745 int performState; 1746 int ugens4_rand_16; 1747 int ugens4_rand_15; 1748 void *schedule_kicked; 1749 MYFLT *disprep_fftcoefs; 1750 void *winEPS_globals; 1751 OPARMS oparms_; 1752 REMOT_BUF SVrecvbuf; /* RM: rt_evt input Communications buffer */ 1753 void *remoteGlobals; 1754 /* VL: pvs bus */ 1755 int nchanif, nchanof; 1756 char *chanif, *chanof; 1757 /* VL: internal yield callback */ 1758 int multiThreadedComplete; 1759 THREADINFO *multiThreadedThreadInfo; 1760 struct dag_t *multiThreadedDag; 1761 void *barrier1; 1762 void *barrier2; 1763 /* Statics from cs_par_dispatch; */ 1764 /* ********These are no longer used******** */ 1765 void *pointer1; //struct global_var_lock_t *global_var_lock_root; 1766 void *pointer2; //struct global_var_lock_t **global_var_lock_cache; 1767 int int1; //global_var_lock_count; 1768 /* statics from cs_par_orc_semantic_analysis */ 1769 struct instr_semantics_t *instCurr; 1770 struct instr_semantics_t *instRoot; 1771 int inInstr; 1772 int dag_changed; 1773 int dag_num_active; 1774 INSDS **dag_task_map; 1775 volatile stateWithPadding *dag_task_status; 1776 watchList * volatile *dag_task_watch; 1777 watchList *dag_wlmm; 1778 char **dag_task_dep; 1779 int dag_task_max_size; 1780 uint32_t tempStatus; /* keeps track of which files are temps */ 1781 int orcLineOffset; /* 1 less than 1st orch line in the CSD */ 1782 int scoLineOffset; /* 1 less than 1st score line in the CSD */ 1783 char* csdname; 1784 /* original CSD name; do not free() */ 1785 int parserUdoflag; 1786 int parserNamedInstrFlag; 1787 int tran_nchnlsi; 1788 int scnt; /* Count of strings */ 1789 int strsiz; /* length of current strings space */ 1790 FUNC *sinetable; /* A useful table */ 1791 int sinelength; /* Size of table */ 1792 MYFLT *UNUSEDP; /* pow2 table */ 1793 MYFLT *cpsocfrc; /* cps conv table */ 1794 CORFIL* expanded_orc; /* output of preprocessor */ 1795 CORFIL* expanded_sco; /* output of preprocessor */ 1796 char *filedir[256];/* for location directory */ 1797 void *message_buffer; 1798 int jumpset; 1799 int info_message_request; 1800 int modules_loaded; 1801 MYFLT _system_sr; 1802 void* csdebug_data; /* debugger data */ 1803 int (*kperf)(CSOUND *); /* kperf function pointer, to switch between debug 1804 and nodebug function */ 1805 int score_parser; 1806 CS_HASH_TABLE* symbtab; 1807 int print_version; 1808 int inZero; /* flag compilation of instr0 */ 1809 struct _message_queue **msg_queue; 1810 volatile long msg_queue_wget; /* Writer - Get index */ 1811 volatile long msg_queue_wput; /* Writer - Put Index */ 1812 volatile long msg_queue_rstart; /* Reader - start index */ 1813 volatile long msg_queue_items; 1814 int aftouch; 1815 void *directory; 1816 ALLOC_DATA *alloc_queue; 1817 volatile unsigned long alloc_queue_items; 1818 unsigned long alloc_queue_wp; 1819 spin_lock_t alloc_spinlock; 1820 EVTBLK *init_event; 1821 void (*csoundMessageStringCallback)(CSOUND *csound, 1822 int attr, 1823 const char *str); 1824 char* message_string; 1825 volatile unsigned long message_string_queue_items; 1826 unsigned long message_string_queue_wp; 1827 message_string_queue_t *message_string_queue; 1828 int io_initialised; 1829 char *op; 1830 int mode; 1831 char *opcodedir; 1832 char *score_srt; 1833 /*struct CSOUND_ **self;*/ 1834 /**@}*/ 1835 #endif /* __BUILDING_LIBCSOUND */ 1836 }; 1837 1838 /* 1839 * Move the C++ guards to enclose the entire file, 1840 * in order to enable C++ to #include this file. 1841 */ 1842 1843 #define LINKAGE_BUILTIN(name) \ 1844 long name##_init(CSOUND *csound, OENTRY **ep) \ 1845 { (void) csound; *ep = name; return (long) (sizeof(name)); } 1846 1847 #define FLINKAGE_BUILTIN(name) \ 1848 NGFENS* name##_init(CSOUND *csound) \ 1849 { (void) csound; return name; } 1850 1851 #ifdef __cplusplus 1852 } 1853 #endif /* __cplusplus */ 1854 1855 #endif /* CSOUNDCORE_H */ 1856