1 /*
2     bus.h:
3 
4     Copyright (C) 2004 John ffitch
5         (C) 2005, 2006 Istvan Varga
6         (C) 2006 Victor Lazzarini
7 
8     This file is part of Csound.
9 
10     The Csound Library is free software; you can redistribute it
11     and/or modify it under the terms of the GNU Lesser General Public
12     License as published by the Free Software Foundation; either
13     version 2.1 of the License, or (at your option) any later version.
14 
15     Csound is distributed in the hope that it will be useful,
16     but WITHOUT ANY WARRANTY; without even the implied warranty of
17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18     GNU Lesser General Public License for more details.
19 
20     You should have received a copy of the GNU Lesser General Public
21     License along with Csound; if not, write to the Free Software
22     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23     02110-1301 USA
24 */
25 
26 /*                                                      BUS.H           */
27 
28 #ifndef CSOUND_BUS_H
29 #define CSOUND_BUS_H
30 
31 #include "pstream.h"
32 #include "arrays.h"
33 #include "csound_standard_types.h"
34 
35 #define MAX_CHAN_NAME 1024
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 typedef struct {
42     OPDS    h;
43     MYFLT   *r, *a;
44 } CHNVAL;
45 
46 typedef struct {
47     OPDS    h;
48     PVSDAT   *r;
49     MYFLT    *a,*N, *overlap, *winsize, *wintype, *format;
50     PVSDAT   init;
51 } FCHAN;
52 
53 typedef struct {
54     OPDS    h;
55     MYFLT   *ans;
56     MYFLT   *keyDown;
57     int32_t evtbuf;
58 } KSENSE;
59 
60 typedef struct channelEntry_s {
61     struct channelEntry_s *nxt;
62     controlChannelHints_t hints;
63     MYFLT       *data;
64     spin_lock_t lock;               /* Multi-thread protection */
65     int32_t     type;
66     int32_t     datasize;  /* size of allocated chn data */
67     char        name[1];
68 } CHNENTRY;
69 
70 typedef struct {
71     OPDS        h;
72     MYFLT       *arg;
73     STRINGDAT   *iname;
74     MYFLT       *fp;
75     spin_lock_t *lock;
76     int32_t     pos;
77     char        chname[MAX_CHAN_NAME+1];
78 } CHNGET;
79 
80 typedef struct {
81     OPDS        h;
82     ARRAYDAT    *arrayDat;
83     STRINGDAT   *iname;
84     MYFLT       *fp;
85     spin_lock_t *lock;
86     int32_t     pos;
87     int32_t     arraySize;
88     MYFLT**     channelPtrs;
89     STRINGDAT   *channels;
90     char        chname[MAX_CHAN_NAME+1];
91 } CHNGETARRAY;
92 
93 typedef struct {
94     OPDS    h;
95     STRINGDAT   *iname[MAX_CHAN_NAME+1];
96     MYFLT   *fp[MAX_CHAN_NAME+1];
97     spin_lock_t *lock[MAX_CHAN_NAME+1];
98 } CHNCLEAR;
99 
100 typedef struct {
101     OPDS    h;
102     STRINGDAT   *iname;
103     MYFLT   *imode;
104     MYFLT   *itype;
105     MYFLT   *idflt;
106     MYFLT   *imin;
107     MYFLT   *imax;
108     MYFLT   *ix;
109     MYFLT   *iy;
110     MYFLT   *iwidth;
111     MYFLT   *iheight;
112     STRINGDAT *Sattributes;
113     spin_lock_t      *lock;
114 } CHN_OPCODE_K;
115 
116 typedef struct {
117     OPDS    h;
118     STRINGDAT   *iname;
119     MYFLT   *imode;
120     spin_lock_t   *lock;
121 } CHN_OPCODE;
122 
123 typedef struct {
124     OPDS    h;
125     MYFLT   *arg;
126     STRINGDAT   *iname;
127     MYFLT   *imode;
128     MYFLT   *itype;
129     MYFLT   *idflt;
130     MYFLT   *imin;
131     MYFLT   *imax;
132 } CHNEXPORT_OPCODE;
133 
134 typedef struct {
135     OPDS    h;
136     MYFLT   *itype;
137     MYFLT   *imode;
138     MYFLT   *ictltype;
139     MYFLT   *idflt;
140     MYFLT   *imin;
141     MYFLT   *imax;
142     STRINGDAT   *iname;
143 } CHNPARAMS_OPCODE;
144 
145 typedef struct {
146     OPDS    h;
147     MYFLT   *value, *valID;
148     AUXCH   channelName;
149     const CS_TYPE *channelType;
150     void *channelptr;
151 } INVAL;
152 
153 typedef struct {
154     OPDS    h;
155     MYFLT   *valID, *value;
156     AUXCH   channelName;
157     const CS_TYPE *channelType;
158     void *channelptr;
159 } OUTVAL;
160 
161 int32_t     chano_opcode_perf_k(CSOUND *, CHNVAL *);
162 int32_t     chano_opcode_perf_a(CSOUND *, CHNVAL *);
163 int32_t     chani_opcode_perf_k(CSOUND *, CHNVAL *);
164 int32_t     chani_opcode_perf_a(CSOUND *, CHNVAL *);
165 int32_t     pvsin_init(CSOUND *, FCHAN *);
166 int32_t     pvsin_perf(CSOUND *, FCHAN *);
167 int32_t     pvsout_init(CSOUND *, FCHAN *);
168 int32_t     pvsout_perf(CSOUND *, FCHAN *);
169 
170 int32_t     sensekey_perf(CSOUND *, KSENSE *);
171 
172 //Rory 2020
173 int32_t     chnget_array_opcode_init_i(CSOUND *, CHNGETARRAY *);
174 int32_t     chnget_array_opcode_init(CSOUND *, CHNGETARRAY *);
175 int32_t     chnget_array_opcode_perf_k(CSOUND *, CHNGETARRAY *);
176 int32_t     chnget_array_opcode_perf_a(CSOUND *, CHNGETARRAY *);
177 int32_t     chnget_array_opcode_perf_S(CSOUND* csound, CHNGETARRAY* p);
178 int32_t     chnset_array_opcode_init_i(CSOUND *, CHNGETARRAY *);
179 int32_t     chnset_array_opcode_init(CSOUND *, CHNGETARRAY *);
180 int32_t     chnset_array_opcode_perf_k(CSOUND *csound, CHNGETARRAY *p);
181 int32_t     chnset_array_opcode_perf_a(CSOUND *csound, CHNGETARRAY *p);
182 int32_t     chnset_array_opcode_perf_S(CSOUND *csound, CHNGETARRAY *p);
183 
184 int32_t     notinit_opcode_stub(CSOUND *, void *);
185 int32_t     chnget_opcode_init_i(CSOUND *, CHNGET *);
186 int32_t     chnget_opcode_init_k(CSOUND *, CHNGET *);
187 int32_t     chnget_opcode_init_a(CSOUND *, CHNGET *);
188 int32_t     chnget_opcode_init_S(CSOUND *, CHNGET *);
189 int32_t     chnget_opcode_perf_S(CSOUND *, CHNGET *);
190 int32_t     chnset_opcode_init_i(CSOUND *, CHNGET *);
191 int32_t     chnset_opcode_init_k(CSOUND *, CHNGET *);
192 int32_t     chnset_opcode_init_a(CSOUND *, CHNGET *);
193 int32_t     chnset_opcode_init_S(CSOUND *, CHNGET *);
194 int32_t     chnset_opcode_perf_S(CSOUND *, CHNGET *);
195 int32_t     chnmix_opcode_init(CSOUND *, CHNGET *);
196 int32_t     chnclear_opcode_init(CSOUND *, CHNCLEAR *);
197 int32_t     chn_k_opcode_init(CSOUND *, CHN_OPCODE_K *);
198 int32_t     chn_k_opcode_init_S(CSOUND *, CHN_OPCODE_K *);
199 int32_t     chn_a_opcode_init(CSOUND *, CHN_OPCODE *);
200 int32_t     chn_S_opcode_init(CSOUND *, CHN_OPCODE *);
201 int32_t     chnexport_opcode_init(CSOUND *, CHNEXPORT_OPCODE *);
202 int32_t     chnparams_opcode_init(CSOUND *, CHNPARAMS_OPCODE *);
203 
204 int32_t kinval(CSOUND *csound, INVAL *p);
205 int32_t kinvalS(CSOUND *csound, INVAL *p);
206 int32_t invalset(CSOUND *csound, INVAL *p);
207 int32_t invalset_string(CSOUND *csound, INVAL *p);
208 int32_t invalset_string_S(CSOUND *csound, INVAL *p);
209 int32_t invalset_S(CSOUND *csound, INVAL *p);
210 int32_t invalsetgo(CSOUND *csound, INVAL *p);
211 int32_t invalsetSgo(CSOUND *csound, INVAL *p);
212 int32_t koutval(CSOUND *csound, OUTVAL *p);
213 int32_t koutvalS(CSOUND *csound, OUTVAL *p);
214 int32_t outvalset(CSOUND *csound, OUTVAL *p);
215 int32_t outvalset_string(CSOUND *csound, OUTVAL *p);
216 int32_t outvalset_string_S(CSOUND *csound, OUTVAL *p);
217 int32_t outvalset_S(CSOUND *csound, OUTVAL *p);
218 int32_t outvalsetgo(CSOUND *csound, OUTVAL *p);
219 int32_t outvalsetSgo(CSOUND *csound, OUTVAL *p);
220 #ifdef __cplusplus
221 }
222 #endif
223 
224 #endif      /* CSOUND_BUS_H */
225