Debian Codegraph @

iOS/Csound iOS Swift Examples/Csound iOS SwiftExamples/csound-iOS/headers/csdl.h

raw symbols SCIP
1 /*
2 csdl.h:
3
4 Copyright (C) 2002 John ffitch
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 #ifndef CSOUND_CSDL_H
25 #define CSOUND_CSDL_H
26 /**
27 * \file csdl.h
28 *
29 * \brief Declares the Csound plugin opcode interface.
30 * \author John P. ffitch, Michael Gogins, Matt Ingalls, John D. Ramsdell,
31 * Istvan Varga, Victor Lazzarini.
32 *
33 * Plugin opcodes can extend the functionality of Csound, providing new
34 * functionality that is exposed as opcodes in the Csound language.
35 * Plugins need to include this header file only, as it will bring all necessary
36 * data structures to interact with Csound. It is not necessary for plugins
37 * to link to the libcsound library, as plugin opcodes will always receive a
38 * CSOUND* pointer (to the CSOUND_ struct) which contains all the API functions
39 * inside.
40 *
41 * This is the basic template for a plugin opcode. See the manual for further
42 * details on accepted types and function call rates. The use of the LINKAGE
43 * macro is highly recommended, rather than calling the functions directly.
44 *
45 * \code
46 #include "csdl.h"
47
48 typedef struct {
49 OPDS h;
50 MYFLT *out;
51 MYFLT *in1, *in2;
52 } OPCODE;
53
54 static int op_init(CSOUND *csound, OPCODE *p)
55 {
56 // Intialization code goes here
57 return OK;
58 }
59
60 static int op_k(CSOUND *csound, OPCODE *p)
61 {
62 // code called at k-rate goes here
63 return OK;
64 }
65
66 // You can use these functions if you need to prepare and cleanup things on
67 // loading/unloading the library, but they can be absent if you don't need them
68
69 PUBLIC int csoundModuleCreate(CSOUND *csound)
70 {
71 return 0;
72 }
73
74 PUBLIC int csoundModuleInit(CSOUND *csound)
75 {
76 OENTRY *ep = (OENTRY *) &(localops[0]);
77 int err = 0;
78 while (ep->opname != NULL) {
79 err |= csound->AppendOpcode(csound,
80 ep->opname, ep->dsblksiz, ep->thread,
81 ep->outypes, ep->intypes,
82 (int (*)(CSOUND *, void *)) ep->iopadr,
83 (int (*)(CSOUND *, void *)) ep->kopadr,
84 (int (*)(CSOUND *, void *)) ep->aopadr);
85 ep++;
86 }
87 return err;
88 }
89
90 PUBLIC int csoundModuleDestroy(CSOUND *csound)
91 {
92 // Called when the plugin opcode is unloaded, usually when Csound terminates.
93 return 0;
94 }
95
96 static OENTRY localops[] =
97 {
98 { "opcode", sizeof(OPCODE), 0, 3, "i", "ii", (SUBR)op_init, (SUBR)op_k }}
99 };
100
101 LINKAGE(localops)
102
103 *
104 * \endcode
105 **/
106
107 #ifdef __BUILDING_LIBCSOUND
108 #undef __BUILDING_LIBCSOUND
109 #endif
110 #include "interlocks.h"
111 #include "csoundCore.h"
112
113
114 #ifdef __cplusplus
115 extern "C" {
116 #endif
117
118 /* Use the Str() macro for translations of strings */
119 #undef Str
120
121 /* VL commenting this out so ALL uses of Str(x)
122 call LocalizeString() [which might be a stub]
123 This would allows us to keep an eye on
124 -Wformat-security warnings
125 */
126 //#ifndef GNU_GETTEXT
127 //#define Str(x) (x)
128 //#else
129 #define Str(x) (csound->LocalizeString(x))
130 //#endif
131
132 PUBLIC int64_t csound_opcode_init(CSOUND *, OENTRY **);
133 PUBLIC NGFENS *csound_fgen_init(CSOUND *);
134
135 PUBLIC int csoundModuleCreate(CSOUND *);
136 PUBLIC int csoundModuleInit(CSOUND *);
137 PUBLIC int csoundModuleDestroy(CSOUND *);
138 PUBLIC const char *csoundModuleErrorCodeToString(int);
139
140 PUBLIC int csoundModuleInfo(void);
141
142 /** The LINKAGE macro sets up linking of opcode list*/
143
144 #define LINKAGE \
145 PUBLIC int64_t csound_opcode_init(CSOUND *csound, OENTRY **ep) \
146 { (void) csound; *ep = localops; return (int64_t) sizeof(localops); } \
147 PUBLIC int csoundModuleInfo(void) \
148 { return ((CS_APIVERSION << 16) + (CS_APISUBVER << 8) + (int) sizeof(MYFLT)); }
149
150 /** The LINKAGE_BUILTIN macro sets up linking of opcode list for builtin opcodes
151 * which must have unique function names */
152
153 #undef LINKAGE_BUILTIN
154 #define LINKAGE_BUILTIN(name) \
155 PUBLIC int64_t csound_opcode_init(CSOUND *csound, OENTRY **ep) \
156 { (void) csound; *ep = name; return (int64_t) (sizeof(name)); } \
157 PUBLIC int csoundModuleInfo(void) \
158 { return ((CS_APIVERSION << 16) + (CS_APISUBVER << 8) + (int) sizeof(MYFLT)); }
159
160 /** LINKAGE for f-table plugins */
161
162 #define FLINKAGE \
163 PUBLIC NGFENS *csound_fgen_init(CSOUND *csound) \
164 { (void) csound; return localfgens; } \
165 PUBLIC int csoundModuleInfo(void) \
166 { return ((CS_APIVERSION << 16) + (CS_APISUBVER << 8) + (int) sizeof(MYFLT)); }
167
168 #undef FLINKAGE_BUILTIN
169 #define FLINKAGE_BUILTIN(name) \
170 PUBLIC NGFENS *csound_fgen_init(CSOUND *csound) \
171 { (void) csound; return name; } \
172 PUBLIC int csoundModuleInfo(void) \
173 { return ((CS_APIVERSION << 16) + (CS_APISUBVER << 8) + (int) sizeof(MYFLT)); }
174
175 #ifdef __cplusplus
176 }
177 #endif
178
179 #endif /* CSOUND_CSDL_H */