-
Notifications
You must be signed in to change notification settings - Fork 184
/
csoundCore.h
1864 lines (1723 loc) · 63.3 KB
/
csoundCore.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
csoundCore.h:
Copyright (C) 1991-2006 Barry Vercoe, John ffitch, Istvan Varga
This file is part of Csound.
The Csound Library is free software; you can redistribute it
and/or modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
Csound is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with Csound; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
*/
#if !defined(__BUILDING_LIBCSOUND) && !defined(CSOUND_CSDL_H)
# error "Csound plugins and host applications should not include csoundCore.h"
#endif
#ifndef CSOUNDCORE_H
#define CSOUNDCORE_H
#if defined(__EMSCRIPTEN__) && !defined(EMSCRIPTEN)
#define EMSCRIPTEN
#endif
#include "sysdep.h"
#if !defined(EMSCRIPTEN) && !defined(CABBAGE)
#if defined(HAVE_PTHREAD)
#include <pthread.h>
#endif
#endif
#include "cs_par_structs.h"
#include <stdarg.h>
#include <setjmp.h>
#include "csound_type_system.h"
#include "csound.h"
#include "cscore.h"
#include "csound_data_structures.h"
#include "csound_standard_types.h"
#include "pools.h"
#ifndef CSOUND_CSDL_H
/* VL not sure if we need to check for SSE */
#if defined(__SSE__) && !defined(EMSCRIPTEN)
#include <xmmintrin.h>
#ifndef _MM_DENORMALS_ZERO_ON
#define _MM_DENORMALS_ZERO_MASK 0x0040
#define _MM_DENORMALS_ZERO_ON 0x0040
#define _MM_DENORMALS_ZERO_OFF 0x0000
#define _MM_SET_DENORMALS_ZERO_MODE(mode) \
_mm_setcsr((_mm_getcsr() & ~_MM_DENORMALS_ZERO_MASK) | (mode))
#define _MM_GET_DENORMALS_ZERO_MODE() \
(_mm_getcsr() & _MM_DENORMALS_ZERO_MASK)
#endif
#else
#ifndef _MM_DENORMALS_ZERO_ON
#define _MM_DENORMALS_ZERO_MASK 0
#define _MM_DENORMALS_ZERO_ON 0
#define _MM_DENORMALS_ZERO_OFF 0
#define _MM_SET_DENORMALS_ZERO_MODE(mode)
#endif
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#if defined(__MACH__) || defined(__FreeBSD__) || defined(__DragonFly__)
#include <xlocale.h>
#endif
#if (defined(__MACH__) || defined(ANDROID) || defined(NACL) || defined(__CYGWIN__) || defined(__HAIKU__))
#include <pthread.h>
#define BARRIER_SERIAL_THREAD (-1)
typedef struct {
pthread_mutex_t mut;
pthread_cond_t cond;
unsigned int count, max, iteration;
} barrier_t;
#ifndef PTHREAD_BARRIER_SERIAL_THREAD
#define pthread_barrier_t barrier_t
#endif /* PTHREAD_BARRIER_SERIAL_THREAd */
#endif /* __MACH__ */
#define OK (0)
#define NOTOK (-1)
#define CSFILE_FD_R 1
#define CSFILE_FD_W 2
#define CSFILE_STD 3
#define CSFILE_SND_R 4
#define CSFILE_SND_W 5
#define MAXINSNO (200)
#define PMAX (1998)
#define VARGMAX (1999)
#define NOT_AN_INSTRUMENT INT32_MAX
#define ORTXT h.optext->t
#define INCOUNT ORTXT.inlist->count
#define OUTCOUNT ORTXT.outlist->count /* Not used */
//#define INOCOUNT ORTXT.inoffs->count
//#define OUTOCOUNT ORTXT.outoffs->count
#define INOCOUNT ORTXT.inArgCount
#define OUTOCOUNT ORTXT.outArgCount
#define IS_ASIG_ARG(x) (csoundGetTypeForArg(x) == &CS_VAR_TYPE_A)
#define IS_STR_ARG(x) (csoundGetTypeForArg(x) == &CS_VAR_TYPE_S)
#define CURTIME (((double)csound->icurTime)/((double)csound->esr))
#define CURTIME_inc (((double)csound->ksmps)/((double)csound->esr))
#ifdef B64BIT
#define MAXLEN 0x10000000
#define FMAXLEN ((MYFLT)(MAXLEN))
#define PHMASK 0x0fffffff
#else
#define MAXLEN 0x1000000L
#define FMAXLEN ((MYFLT)(MAXLEN))
#define PHMASK 0x0FFFFFFL
#endif
#define MAX_STRING_CHANNEL_DATASIZE 16384
#define PFRAC(x) ((MYFLT)((x) & ftp->lomask) * ftp->lodiv)
#define MAXPOS 0x7FFFFFFFL
#define BYTREVS(n) ((n>>8 & 0xFF) | (n<<8 & 0xFF00))
#define BYTREVL(n) ((n>>24 & 0xFF) | (n>>8 & 0xFF00L) | \
(n<<8 & 0xFF0000L) | (n<<24 & 0xFF000000L))
#define OCTRES 8192
#define CPSOCTL(n) ((MYFLT)(1<<((int)(n)>>13))*csound->cpsocfrc[(int)(n)&8191])
#define LOBITS 10
#define LOFACT 1024
/* LOSCAL is 1/LOFACT as MYFLT */
#define LOSCAL FL(0.0009765625)
#define LOMASK 1023
#ifdef USE_DOUBLE
extern int64_t MYNAN;
//#define SSTRCOD (nan("0"))
#define SSTRCOD (double)NAN
#else
extern int32 MYNAN;
#define SSTRCOD (float)NAN
//#define SSTRCOD (nanf("0"))
#endif
//#define ISSTRCOD(X) isnan(X)
//#ifndef __MACH__
extern int ISSTRCOD(MYFLT);
//#else
//#define ISSTRCOD(X) isnan(X)
//#endif
#define SSTRSIZ 1024
#define ALLCHNLS 0x7fff
#define DFLT_SR FL(44100.0)
#define DFLT_KR FL(4410.0)
#define DFLT_KSMPS 10
#define DFLT_NCHNLS 1
#define MAXCHNLS 256
#define MAXNAME (256)
#define DFLT_DBFS (FL(32768.0))
#define MAXOCTS 8
#define MAXCHAN 16 /* 16 MIDI channels; only one port for now */
/* A440 tuning factor */
#define ONEPT (csound->A4/430.5389646099018460319362438314060262605)
#define LOG10D20 0.11512925 /* for db to ampfac */
#define DV32768 FL(0.000030517578125)
#ifndef PI
#define PI (3.141592653589793238462643383279502884197)
#endif /* pi */
#define TWOPI (6.283185307179586476925286766559005768394)
#define HALFPI (1.570796326794896619231321691639751442099)
#define PI_F ((MYFLT) PI)
#define TWOPI_F ((MYFLT) TWOPI)
#define HALFPI_F ((MYFLT) HALFPI)
#define INF (2147483647.0)
#define ROOT2 (1.414213562373095048801688724209698078569)
/* CONSTANTS FOR USE IN MSGLEVEL */
#define CS_AMPLMSG 01
#define CS_RNGEMSG 02
#define CS_WARNMSG 04
//#define CS_UNUSED1 08
#define CS_NOMSG 0x10
//#define CS_UNUSED2 0x20
#define CS_RAWMSG 0x40
#define CS_TIMEMSG 0x80
#define CS_NOQQ 0x400
#define IGN(X) (void) X
#define ARG_CONSTANT 0
#define ARG_STRING 1
#define ARG_PFIELD 2
#define ARG_GLOBAL 3
#define ARG_LOCAL 4
#define ARG_LABEL 5
#define ASYNC_GLOBAL 1
#define ASYNC_LOCAL 2
enum {FFT_LIB=0, PFFT_LIB, VDSP_LIB};
enum {FFT_FWD=0, FFT_INV};
/* advance declaration for
API message queue struct
*/
struct _message_queue;
typedef struct CORFIL {
char *body;
unsigned int len;
unsigned int p;
} CORFIL;
typedef struct {
int odebug;
int sfread, sfwrite, sfheader, filetyp;
int inbufsamps, outbufsamps;
int informat, outformat;
int sfsampsize;
int displays, graphsoff, postscript, msglevel;
int Beatmode, oMaxLag;
int usingcscore, Linein;
int RTevents, Midiin, FMidiin, RMidiin;
int ringbell, termifend;
int rewrt_hdr, heartbeat, gen01defer;
double cmdTempo;
float sr_override, kr_override;
int nchnls_override, nchnls_i_override;
char *infilename, *outfilename;
CORFIL *playscore;
char *Linename, *Midiname, *FMidiname;
char *Midioutname; /* jjk 09252000 - MIDI output device, -Q option */
char *FMidioutname;
int midiKey, midiKeyCps, midiKeyOct, midiKeyPch;
int midiVelocity, midiVelocityAmp;
int noDefaultPaths; /* syy - Oct 25, 2006: for disabling relative paths
from files */
int numThreads;
int syntaxCheckOnly;
int useCsdLineCounts;
int sampleAccurate; /* switch for score events sample accuracy */
int realtime; /* realtime priority mode */
MYFLT e0dbfs_override;
int daemon;
double quality; /* for ogg encoding */
int ksmps_override;
int fft_lib;
int echo;
MYFLT limiter;
float sr_default, kr_default;
} OPARMS;
typedef struct arglst {
int count;
char *arg[1];
} ARGLST;
typedef struct arg {
int type;
void* argPtr;
int index;
struct arg* next;
} ARG;
// typedef struct argoffs {
// int count;
// int indx[1];
// } ARGOFFS;
typedef struct oentry {
char *opname;
uint16 dsblksiz;
uint16 flags;
uint8_t thread;
char *outypes;
char *intypes;
int (*iopadr)(CSOUND *, void *p);
int (*kopadr)(CSOUND *, void *p);
int (*aopadr)(CSOUND *, void *p);
void *useropinfo; /* user opcode parameters */
} OENTRY;
/**
* Storage for parsed orchestra code, for each opcode in an INSTRTXT.
*/
typedef struct text {
uint16_t linenum; /* Line num in orch file (currently buggy!) */
uint64_t locn; /* and location */
OENTRY *oentry;
char *opcod; /* Pointer to opcode name in global pool */
ARGLST *inlist; /* Input args (pointer to item in name list) */
ARGLST *outlist;
ARG *inArgs; /* Input args (index into list of values) */
unsigned int inArgCount;
ARG *outArgs;
unsigned int outArgCount;
char intype; /* Type of first input argument (g,k,a,w etc) */
char pftype; /* Type of output argument (k,a etc) */
} TEXT;
/**
* This struct is filled out by otran() at orch parse time.
* It is used as a template for instrument events.
*/
typedef struct instr {
struct op * nxtop; /* Linked list of instr opcodes */
TEXT t; /* Text of instrument (same in nxtop) */
int pmax, vmax, pextrab; /* Arg count, size of data for all
opcodes in instr */
//int mdepends; /* Opcode type (i/k/a) */
CS_VAR_POOL* varPool;
// int optxtcount;
int16 muted;
// int32 localen;
int32 opdstot; /* Total size of opds structs in instr */
// int32 *inslist; /* Only used in parsing (?) */
MYFLT *psetdata; /* Used for pset opcode */
struct insds * instance; /* Chain of allocated instances of
this instrument */
struct insds * lst_instance; /* last allocated instance */
struct insds * act_instance; /* Chain of free (inactive) instances */
/* (pointer to next one is INSDS.nxtact) */
struct instr * nxtinstxt; /* Next instrument in orch (num order) */
int active; /* To count activations for control */
int pending_release; /* To count instruments in release phase */
int maxalloc;
MYFLT cpuload; /* % load this instrumemnt makes */
struct opcodinfo *opcode_info; /* UDO info (when instrs are UDOs) */
char *insname; /* instrument name */
int instcnt; /* Count number of instances ever */
int isNew; /* is this a new definition */
int nocheckpcnt; /* Control checks on pcnt */
} INSTRTXT;
typedef struct namedInstr {
int32 instno;
char *name;
INSTRTXT *ip;
struct namedInstr *next;
} INSTRNAME;
/**
* A chain of TEXT structs. Note that this is identical with the first two
* members of struct INSTRTEXT, and is so typecast at various points in code.
*/
typedef struct op {
struct op *nxtop;
TEXT t;
} OPTXT;
typedef struct fdch {
struct fdch *nxtchp;
/** handle returned by csound->FileOpen() */
void *fd;
} FDCH;
typedef struct auxch {
struct auxch *nxtchp;
size_t size;
void *auxp, *endp;
} AUXCH;
/** this callback is used to notify the
availability of new storage in AUXCH *.
It can be used to swap the old storage
for the new one and return it for deallocation.
*/
typedef AUXCH* (*aux_cb)(CSOUND *, void *, AUXCH *);
/**
* AuxAllocAsync data
*/
typedef struct {
CSOUND *csound;
size_t nbytes;
AUXCH *auxchp;
void *userData;
aux_cb notify;
} AUXASYNC;
typedef struct {
int dimensions;
int* sizes; /* size of each dimensions */
int arrayMemberSize;
CS_TYPE* arrayType;
MYFLT* data;
size_t allocated;
// AUXCH aux;
} ARRAYDAT;
typedef struct {
int size; /* 0...size-1 */
MYFLT *data;
AUXCH aux;
} TABDAT;
typedef struct {
char *data;
int size;
} STRINGDAT;
typedef struct monblk {
int16 pch;
struct monblk *prv;
} MONPCH;
typedef struct {
int notnum[4];
} DPEXCL;
typedef struct {
DPEXCL dpexcl[8];
/** for keys 25-99 */
int exclset[75];
} DPARM;
typedef struct dklst {
struct dklst *nxtlst;
int32 pgmno;
/** cnt + keynos */
MYFLT keylst[1];
} DKLST;
typedef struct mchnblk {
/** most recently received program change */
int16 pgmno;
/** instrument number assigned to this channel */
int16 insno;
int16 RegParNo;
int16 mono;
MONPCH *monobas;
MONPCH *monocur;
/** list of active notes (NULL: not active) */
struct insds *kinsptr[128];
/** polyphonic pressure indexed by note number */
MYFLT polyaft[128];
/** ... with GS vib_rate, stored in c128-c135 */
MYFLT ctl_val[136];
/** program change to instr number (<=0: ignore) */
int16 pgm2ins[128];
/** channel pressure (0-127) */
MYFLT aftouch;
/** pitch bend (-1 to 1) */
MYFLT pchbend;
/** pitch bend sensitivity in semitones */
MYFLT pbensens;
/** number of held (sustaining) notes */
int16 ksuscnt;
/** current state of sustain pedal (0: off) */
int16 sustaining;
int dpmsb;
int dplsb;
int datenabl;
/** chain of dpgm keylists */
DKLST *klists;
/** drumset params */
DPARM *dparms;
} MCHNBLK;
/**
* This struct holds the data for one score event.
*/
typedef struct event {
/** String argument(s) (NULL if none) */
int scnt;
char *strarg;
/* instance pointer */
void *pinstance; /* used in nstance opcode */
/** Event type */
char opcod;
/** Number of p-fields */
int16 pcnt;
/** Event start time */
MYFLT p2orig;
/** Length */
MYFLT p3orig;
/** All p-fields for this event (SSTRCOD: string argument) */
MYFLT p[PMAX + 1];
union { /* To ensure size is same as earlier */
MYFLT *extra;
MYFLT p[2];
} c;
} EVTBLK;
/**
* This struct holds the info for a concrete instrument event
* instance in performance.
*/
typedef struct insds {
/* Chain of init-time opcodes */
struct opds * nxti;
/* Chain of performance-time opcodes */
struct opds * nxtp;
/* Next allocated instance */
struct insds * nxtinstance;
/* Previous allocated instance */
struct insds * prvinstance;
/* Next in list of active instruments */
struct insds * nxtact;
/* Previous in list of active instruments */
struct insds * prvact;
/* Next instrument to terminate */
struct insds * nxtoff;
/* Chain of files used by opcodes in this instr */
FDCH *fdchp;
/* Extra memory used by opcodes in this instr */
AUXCH *auxchp;
/* Extra release time requested with xtratim opcode */
int xtratim;
/* MIDI note info block if event started from MIDI */
MCHNBLK *m_chnbp;
/* ptr to next overlapping MIDI voice */
struct insds * nxtolap;
/* Instrument number */
int16 insno;
/* Instrument def address */
INSTRTXT *instr;
/* non-zero for sustaining MIDI note */
int16 m_sust;
/* MIDI pitch, for simple access */
unsigned char m_pitch;
/* ...ditto velocity */
unsigned char m_veloc;
/* Flag to indicate we are releasing, test with release opcode */
char relesing;
/* Set if instr instance is active (perfing) */
char actflg;
/* Time to turn off event, in score beats */
double offbet;
/* Time to turn off event, in seconds (negative on indef/tie) */
double offtim;
/* Python namespace for just this instance. */
void *pylocal;
/* pointer to Csound engine and API for externals */
CSOUND *csound;
uint64_t kcounter;
unsigned int ksmps; /* Instrument copy of ksmps */
MYFLT ekr; /* and of rates */
MYFLT onedksmps, onedkr, kicvt;
struct opds *pds; /* Used for jumping */
MYFLT scratchpad[4]; /* Persistent data */
/* user defined opcode I/O buffers */
void *opcod_iobufs;
void *opcod_deact, *subins_deact;
/* opcodes to be run at note deactivation */
void *nxtd;
uint32_t ksmps_offset; /* ksmps offset for sample accuracy */
uint32_t no_end; /* samps left at the end for sample accuracy
(calculated) */
uint32_t ksmps_no_end; /* samps left at the end for sample accuracy
(used by opcodes) */
MYFLT *spin; /* offset into csound->spin */
MYFLT *spout; /* offset into csound->spout, or local spout */
int init_done;
int tieflag;
int reinitflag;
MYFLT retval;
MYFLT *lclbas; /* base for variable memory pool */
char *strarg; /* string argument */
/* Copy of required p-field values for quick access */
CS_VAR_MEM p0;
CS_VAR_MEM p1;
CS_VAR_MEM p2;
CS_VAR_MEM p3;
} INSDS;
#define CS_KSMPS (p->h.insdshead->ksmps)
#define CS_KCNT (p->h.insdshead->kcounter)
#define CS_EKR (p->h.insdshead->ekr)
#define CS_ONEDKSMPS (p->h.insdshead->onedksmps)
#define CS_ONEDKR (p->h.insdshead->onedkr)
#define CS_KICVT (p->h.insdshead->kicvt)
#define CS_ESR (csound->esr)
#define CS_PDS (p->h.insdshead->pds)
#define CS_SPIN (p->h.insdshead->spin)
#define CS_SPOUT (p->h.insdshead->spout)
typedef int (*SUBR)(CSOUND *, void *);
/**
* This struct holds the info for one opcode in a concrete
* instrument instance in performance.
*/
typedef struct opds {
/** Next opcode in init-time chain */
struct opds * nxti;
/** Next opcode in perf-time chain */
struct opds * nxtp;
/** Initialization (i-time) function pointer */
SUBR iopadr;
/** Perf-time (k- or a-rate) function pointer */
SUBR opadr;
/** Orch file template part for this opcode */
OPTXT *optext;
/** Owner instrument instance data structure */
INSDS *insdshead;
} OPDS;
typedef struct lblblk {
OPDS h;
OPDS *prvi;
OPDS *prvp;
} LBLBLK;
typedef struct {
MYFLT *begp, *curp, *endp, feedback[6];
int32 scount;
} OCTDAT;
typedef struct {
int32 npts, nocts, nsamps;
MYFLT lofrq, hifrq, looct, srate;
OCTDAT octdata[MAXOCTS];
AUXCH auxch;
} DOWNDAT;
typedef struct {
uint32_t ktimstamp, ktimprd;
int32 npts, nfreqs, dbout;
DOWNDAT *downsrcp;
AUXCH auxch;
} SPECDAT;
typedef struct {
MYFLT gen01;
MYFLT ifilno;
MYFLT iskptim;
MYFLT iformat;
MYFLT channel;
MYFLT sample_rate;
char strarg[SSTRSIZ];
} GEN01ARGS;
typedef struct {
/** table length, not including the guard point */
uint32_t flen;
/** length mask ( = flen - 1) for power of two table size, 0 otherwise */
int32 lenmask;
/** log2(MAXLEN / flen) for power of two table size, 0 otherwise */
int32 lobits;
/** 2^lobits - 1 */
int32 lomask;
/** 1 / 2^lobits */
MYFLT lodiv;
/** LOFACT * (table_sr / orch_sr), cpscvt = cvtbas / base_freq */
MYFLT cvtbas, cpscvt;
/** sustain loop mode (0: none, 1: forward, 2: forward and backward) */
int16 loopmode1;
/** release loop mode (0: none, 1: forward, 2: forward and backward) */
int16 loopmode2;
/** sustain loop start and end in sample frames */
int32 begin1, end1;
/** release loop start and end in sample frames */
int32 begin2, end2;
/** sound file length in sample frames (flenfrms = soundend - 1) */
int32 soundend, flenfrms;
/** number of channels */
int32 nchanls;
/** table number */
int32 fno;
/** args */
MYFLT args[PMAX - 4];
/** arg count */
int argcnt;
/** GEN01 parameters */
GEN01ARGS gen01args;
/** table data (flen + 1 MYFLT values) */
MYFLT *ftable;
} FUNC;
typedef struct {
CSOUND *csound;
int32 flen;
int fno, guardreq;
EVTBLK e;
} FGDATA;
typedef struct {
char *name;
int (*fn)(FGDATA *, FUNC *);
} NGFENS;
typedef int (*GEN)(FGDATA *, FUNC *);
typedef struct MEMFIL {
char filename[256]; /* Made larger RWD */
char *beginp;
char *endp;
int32 length;
struct MEMFIL *next;
} MEMFIL;
typedef struct {
int16 type;
int16 chan;
int16 dat1;
int16 dat2;
} MEVENT;
typedef struct SNDMEMFILE_ {
/** file ID (short name) */
char *name;
struct SNDMEMFILE_ *nxt;
/** full path filename */
char *fullName;
/** file length in sample frames */
size_t nFrames;
/** sample rate in Hz */
double sampleRate;
/** number of channels */
int nChannels;
/** AE_SHORT, AE_FLOAT, etc. */
int sampleFormat;
/** TYP_WAV, TYP_AIFF, etc. */
int fileType;
/**
* loop mode:
* 0: no loop information
* 1: off
* 2: forward
* 3: backward
* 4: bidirectional
*/
int loopMode;
/** playback start offset frames */
double startOffs;
/** loop start (sample frames) */
double loopStart;
/** loop end (sample frames) */
double loopEnd;
/** base frequency (in Hz) */
double baseFreq;
/** amplitude scale factor */
double scaleFac;
/** interleaved sample data */
float data[1];
} SNDMEMFILE;
typedef struct pvx_memfile_ {
char *filename;
struct pvx_memfile_ *nxt;
float *data;
uint32 nframes;
int format;
int fftsize;
int overlap;
int winsize;
int wintype;
int chans;
MYFLT srate;
} PVOCEX_MEMFILE;
#ifdef __BUILDING_LIBCSOUND
#define INSTR 1
#define ENDIN 2
#define OPCODE 3
#define ENDOP 4
#define LABEL 5
#define SETBEG 6
#define PSET 6
#define USEROPCODE 7
#define SETEND 8
#define TOKMAX 50L /* Should be 50 but bust */
/* max number of input/output args for user defined opcodes */
#define OPCODENUMOUTS_LOW 16
#define OPCODENUMOUTS_HIGH 64
#define OPCODENUMOUTS_MAX 256
#define MBUFSIZ (4096)
#define MIDIINBUFMAX (1024)
#define MIDIINBUFMSK (MIDIINBUFMAX-1)
#define MIDIMAXPORTS (64)
typedef union {
uint32 dwData;
unsigned char bData[4];
} MIDIMESSAGE;
/* MIDI globals */
typedef struct midiglobals {
MEVENT *Midevtblk;
int sexp;
int MIDIoutDONE;
int MIDIINbufIndex;
MIDIMESSAGE MIDIINbuffer2[MIDIINBUFMAX];
int (*MidiInOpenCallback)(CSOUND *, void **, const char *);
int (*MidiReadCallback)(CSOUND *, void *, unsigned char *, int);
int (*MidiInCloseCallback)(CSOUND *, void *);
int (*MidiOutOpenCallback)(CSOUND *, void **, const char *);
int (*MidiWriteCallback)(CSOUND *, void *, const unsigned char *, int);
int (*MidiOutCloseCallback)(CSOUND *, void *);
const char *(*MidiErrorStringCallback)(int);
void *midiInUserData;
void *midiOutUserData;
void *midiFileData;
void *midiOutFileData;
int rawControllerMode;
char muteTrackList[256];
unsigned char mbuf[MBUFSIZ];
unsigned char *bufp, *endatp;
int16 datreq, datcnt;
} MGLOBAL;
typedef struct eventnode {
struct eventnode *nxt;
uint32 start_kcnt;
EVTBLK evt;
} EVTNODE;
typedef struct {
OPDS h;
MYFLT *ktempo, *istartempo;
MYFLT prvtempo;
} TEMPO;
/* typedef struct token { */
/* char *str; */
/* int16 prec; */
/* } TOKEN; */
typedef struct names {
char *mac;
struct names *next;
} NAMES;
typedef struct threadInfo {
struct threadInfo *next;
void * threadId;
} THREADINFO;
#include "sort.h"
#include "text.h"
#include "prototyp.h"
#include "cwindow.h"
#include "envvar.h"
#include "remote.h"
#define CS_STATE_PRE (1)
#define CS_STATE_COMP (2)
#define CS_STATE_UTIL (4)
#define CS_STATE_CLN (8)
#define CS_STATE_JMP (16)
/* These are used to set/clear bits in csound->tempStatus.
If the bit is set, it indicates that the given file is
a temporary. */
extern const uint32_t csOrcMask;
extern const uint32_t csScoInMask;
extern const uint32_t csScoSortMask;
extern const uint32_t csMidiScoMask;
extern const uint32_t csPlayScoMask;
/* kperf function protoypes. Used by the debugger to switch between debug
* and nodebug kperf functions */
int kperf_nodebug(CSOUND *csound);
int kperf_debug(CSOUND *csound);
#endif /* __BUILDING_LIBCSOUND */
#define MARGS (3)
#define MAX_INCLUDE_DEPTH 100
struct MACRO;
typedef struct MACRON {
int n;
unsigned int line;
struct MACRO *s;
char *path;
} MACRON;
typedef struct MACRO { /* To store active macros */
char *name; /* Use is by name */
int acnt; /* Count of arguments */
char *body; /* The text of the macro */
struct MACRO *next; /* Chain of active macros */
int margs; /* amount of space for args */
char *arg[MARGS]; /* With these arguments */
} MACRO;
typedef struct in_stack_s { /* Stack of active inputs */
int16 is_marked_repeat; /* 1 if this input created by 'n' stmnt */
int16 args; /* Argument count for macro */
//CORFIL *cf; /* In core file */
//void *fd; /* for closing stream */
MACRO *mac;
int line;
int32 oposit;
} IN_STACK;
typedef struct marked_sections {
char *name;
int32 posit;
int line;
} MARKED_SECTIONS;
typedef struct namelst {
char *name;
struct namelst *next;
} NAMELST;
typedef struct NAME__ {
char *namep;
struct NAME__ *nxt;
int type, count;
} NAME;
/* Holds UDO information, when an instrument is
defined as a UDO
*/
typedef struct opcodinfo {
int32 instno;
char *name, *intypes, *outtypes;
int16 inchns, outchns;
CS_VAR_POOL* out_arg_pool;
CS_VAR_POOL* in_arg_pool;
INSTRTXT *ip;
struct opcodinfo *prv;
} OPCODINFO;
/**
* This struct will hold the current engine state after compilation
*/
typedef struct engine_state {
CS_VAR_POOL *varPool; /* global variable pool */
CS_HASH_TABLE *constantsPool;
CS_HASH_TABLE *stringPool;
int maxopcno;
INSTRTXT **instrtxtp; /* instrument list */
INSTRTXT instxtanchor;
CS_HASH_TABLE *instrumentNames; /* instrument names */
int maxinsno;
} ENGINE_STATE;
/**
* Nen FFT interface
*/
typedef struct _FFT_SETUP{
int N, M;
void *setup;
MYFLT *buffer;
int lib;
int d;
int p2;
} CSOUND_FFT_SETUP;
/**
* plugin module info
*/
typedef struct {
char module[12];
char type[12];
} MODULE_INFO;
#define MAX_ALLOC_QUEUE 1024
typedef struct _alloc_data_ {
int type;
int insno;
EVTBLK blk;
MCHNBLK *chn;
MEVENT mep;
INSDS *ip;
OPDS *ids;
} ALLOC_DATA;
#define MAX_MESSAGE_STR 1024
typedef struct _message_queue_t_ {
int attr;