CsoundUnity 3.4.0
https://github.com/rorywalsh/CsoundUnity
CsoundCsharp.cs
Go to the documentation of this file.
1/*
2
3C S O U N D for C#
4
5Simple wrapper building C# hosts for Csound 6 via the Csound API
6and is licensed under the same terms and disclaimers as Csound described below.
7
8Copyright (C) 2013 Richard Henninger, Rory Walsh
9
10This file is part of CsoundUnity: https://github.com/rorywalsh/CsoundUnity
11
12Contributors:
13
14Bernt Isak Wærstad
15Charles Berman
16Giovanni Bedetti
17Hector Centeno
18NPatch
19
20Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
21to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
22and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
23
24The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
25
26THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
28ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
29THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30*/
31
32using System;
33using System.Runtime.InteropServices;
34#if UNITY_EDITOR || UNITY_STANDALONE
35using MYFLT = System.Double;
36#elif UNITY_ANDROID || UNITY_IOS
37using MYFLT = System.Single;
38#endif
39
40namespace csoundcsharp
41{
42 // This simple wrapper is based on Richard Henninger's Csound6Net .NET wrapper. If you wish to
43 // use the Csound API in a model that is idiomatic to .net please use his wrapper instead.
44 // http://csound6net.codeplex.com // this site is not reachable anymore
45
46 // This lightweight wrapper was created to provide an interface to the Unity game engine
47 public partial class Csound6
48 {
49
50#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
51 internal const string _dllVersion = "csound64.dll";
52#elif UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
53 internal const string _dllVersion = "CsoundLib64.bundle";
54#elif UNITY_ANDROID
55 internal const string _dllVersion = "csoundandroid";
56#elif UNITY_IOS
57 internal const string _dllVersion = "__Internal";
58#endif
59
60 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
61 internal delegate void MessageCallbackProxy(IntPtr csound, Int32 attr, string format, IntPtr valist);
62
63 // Callbacks will be probably removed in Csound 7
64
65 //[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
66 //internal delegate void FileOpenCallbackProxy(IntPtr csound, string pathname, int csFileType, int writing, int temporary);
67
68 //[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
69 //internal delegate void RtcloseCallbackProxy(IntPtr csound);
70
71 //[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
72 //internal delegate void SenseEventCallbackProxy(IntPtr csound, IntPtr userdata);
73
74 //[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
75 //internal delegate int YieldCallback(IntPtr csound);
76
77 // Csound API 6.17
78 public class NativeMethods
79 {
80 #region Instantiation
81
82 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
83 internal static extern Int32 csoundInitialize([In] int flags);
84
85 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
86 internal static extern IntPtr csoundCreate(IntPtr hostdata);
87
88 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
89 internal static extern Int32 csoundLoadPlugins([In] IntPtr csound, [In, MarshalAs(UnmanagedType.LPStr)] String dir);
90
91 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
92 internal static extern void csoundDestroy([In] IntPtr csound);
93
94 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
95 internal static extern Int32 csoundGetVersion();
96
97 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
98 internal static extern Int32 csoundGetAPIVersion();
99
100 #endregion Instantiation
101
102
103 #region Performance
104
105 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
106 internal static extern IntPtr csoundParseOrc([In] IntPtr csound, [In] String str);
107
108 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
109 internal static extern Int32 csoundCompileTree([In] IntPtr csound, [In] IntPtr root);
110
111 // PUBLIC int csoundCompileTreeAsync (CSOUND *csound, TREE *root)
112
113 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
114 internal static extern void csoundDeleteTree([In] IntPtr csound, [In] IntPtr root);
115
116 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
117 internal static extern Int32 csoundCompileOrc([In] IntPtr csound, [In, MarshalAs(UnmanagedType.LPStr)] String orchStr);
118
119 // PUBLIC int csoundCompileOrcAsync (CSOUND *csound, const char *str)
120
121 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
122 internal static extern MYFLT csoundEvalCode([In] IntPtr csound, [In, MarshalAs(UnmanagedType.LPStr)] String orchStr);
123
124 // PUBLIC int csoundInitializeCscore (CSOUND *, FILE *insco, FILE *outsco)
125
126 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
127 internal static extern Int32 csoundCompileArgs([In] IntPtr csound, [In] Int32 argc, [In] string[] argv);
128
129 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
130 internal static extern Int32 csoundStart([In] IntPtr csound);
131
132 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
133 internal static extern Int32 csoundCompile([In] IntPtr csound, [In] Int32 argc, [In] string[] argv);
134
135 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
136 internal static extern Int32 csoundCompileCsd([In] IntPtr csound, [In, MarshalAs(UnmanagedType.LPStr)] String csdFilename);
137
138 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
139 internal static extern Int32 csoundCompileCsdText([In] IntPtr csound, [In, MarshalAs(UnmanagedType.LPStr)] String csdText);
140
141 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
142 internal static extern int csoundPerform([In] IntPtr csound);
143
144 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
145 internal static extern Int32 csoundPerformKsmps([In] IntPtr csound);
146
147 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
148 internal static extern Int32 csoundPerformBuffer([In] IntPtr csound);
149
150 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
151 internal static extern void csoundStop([In] IntPtr csound);
152
153 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
154 internal static extern Int32 csoundCleanup([In] IntPtr csound);
155
156 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
157 internal static extern void csoundReset([In] IntPtr csound);
158
159 #endregion Performance
160
161
162 #region UDP server
163
164 // PUBLIC int csoundUDPServerStart(CSOUND* csound, unsigned int port)
165
166 // PUBLIC int csoundUDPServerStatus(CSOUND* csound)
167
168 // PUBLIC int csoundUDPServerClose(CSOUND* csound)
169
170 // PUBLIC int csoundUDPConsole(CSOUND* csound, const char* addr, int port, int mirror)
171
172 // PUBLIC void csoundStopUDPConsole(CSOUND* csound)
173
174 #endregion UDP server
175
176
177 #region Attributes
178
179 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
180 internal static extern MYFLT csoundGetSr([In] IntPtr csound);
181
182 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
183 internal static extern MYFLT csoundGetKr([In] IntPtr csound);
184
185 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
186 internal static extern UInt32 csoundGetKsmps([In] IntPtr csound);
187
188 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
189 internal static extern UInt32 csoundGetNchnls([In] IntPtr csound);
190
191 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
192 internal static extern UInt32 csoundGetNchnlsInput([In] IntPtr csound);
193
194 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
195 internal static extern MYFLT csoundGet0dBFS([In] IntPtr csound);
196
197 // PUBLIC MYFLT csoundGetA4 (CSOUND *)
198
199 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
200 internal static extern Int64 csoundGetCurrentTimeSamples([In] IntPtr csound);
201
202 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
203 internal static extern Int32 csoundGetSizeOfMYFLT();
204
205 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
206 internal static extern IntPtr csoundGetHostData([In] IntPtr csound);
207
208 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
209 internal static extern void csoundSetHostData([In] IntPtr csound, IntPtr hostData);
210
211 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
212 internal static extern Int32 csoundSetOption([In] IntPtr csound, [In] string option);
213
214 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
215 internal static extern void csoundGetParams(IntPtr csound, [Out, MarshalAs(UnmanagedType.LPStruct)] CsoundUnityBridge.CSOUND_PARAMS parms);
216
217 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
218 internal static extern void csoundSetParams(IntPtr csound, [In, MarshalAs(UnmanagedType.LPStruct)] CsoundUnityBridge.CSOUND_PARAMS parms);
219
220 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
221 internal static extern Int32 csoundGetDebug([In] IntPtr csound);
222
223 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
224 internal static extern void csoundSetDebug([In] IntPtr csound, [In] Int32 debug);
225
226 #endregion Attributes
227
228
229 #region General Input/Output
230
231 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
232 internal static extern IntPtr csoundGetOutputName([In] IntPtr csound);
233
234 // PUBLIC const char * csoundGetInputName (CSOUND *)
235
236 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
237 internal static extern void csoundSetOutput([In] IntPtr csound, [In, MarshalAs(UnmanagedType.LPStr)] string name, [In, MarshalAs(UnmanagedType.LPStr)] string type, [In, MarshalAs(UnmanagedType.LPStr)] string format);
238
239 // PUBLIC void csoundGetOutputFormat (CSOUND *csound, char *type, char *format)
240
241 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
242 internal static extern void csoundSetInput([In] IntPtr csound, [In, MarshalAs(UnmanagedType.LPStr)] string name);
243
244 // csoundSetMIDIInput (CSOUND *csound, char *name)
245
246 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
247 internal static extern void csoundSetMIDIFileInput([In] IntPtr csound, [In, MarshalAs(UnmanagedType.LPStr)] string name);
248
249 // csoundSetMIDIOutput (CSOUND *csound, char *name)
250
251 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
252 internal static extern void csoundSetMIDIFileOutput([In] IntPtr csound, [In, MarshalAs(UnmanagedType.LPStr)] string name);
253
254 //[DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
255 //internal static extern void csoundSetFileOpenCallback([In] IntPtr csound, FileOpenCallbackProxy processMessage);
256
257 #endregion
258
259
260 #region Realtime Audio I/O
261
262 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
263 internal static extern void csoundSetRTAudioModule([In] IntPtr csound, [In, MarshalAs(UnmanagedType.LPStr)] string module);
264
265 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
266 internal static extern int csoundGetModule([In] IntPtr csound, int number, ref IntPtr name, ref IntPtr type);
267
268 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
269 internal static extern Int32 csoundGetInputBufferSize([In] IntPtr csound);
270
271 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
272 internal static extern Int32 csoundGetOutputBufferSize([In] IntPtr csound);
273
274 // PUBLIC MYFLT * csoundGetInputBuffer (CSOUND *)
275
276 // PUBLIC MYFLT * csoundGetOutputBuffer (CSOUND *)
277
278 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
279 internal static extern IntPtr csoundGetSpin([In] IntPtr csound);
280
281 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
282 internal static extern void csoundClearSpin([In] IntPtr csound);
283
284 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
285 internal static extern IntPtr csoundAddSpinSample([In] IntPtr csound, [In] Int32 frame, [In] Int32 channel, [In] MYFLT sample);
286
287 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
288 internal static extern void csoundSetSpinSample([In] IntPtr csound, [In] Int32 frame, [In] Int32 channel, [In] MYFLT value);
289
290 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
291 internal static extern IntPtr csoundGetSpout([In] IntPtr csound);
292
293 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
294 internal static extern MYFLT csoundGetSpoutSample([In] IntPtr csound, [In] Int32 frame, [In] Int32 channel);
295
296 // PUBLIC void ** csoundGetRtRecordUserData (CSOUND *)
297
298 // PUBLIC void ** csoundGetRtPlayUserData (CSOUND *)
299
300 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
301 internal static extern void csoundSetHostImplementedAudioIO([In] IntPtr csound, [In] int state, [In] int buffSize);
302
303 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
304 internal static extern Int32 csoundGetAudioDevList([In] IntPtr csound, [Out] IntPtr list, [In] Int32 isOutput);
305
306 // PUBLIC void csoundSetPlayopenCallback(CSOUND*, int(* playopen__)(CSOUND*, const csRtAudioParams* parm))
307
308 // PUBLIC void csoundSetRtplayCallback (CSOUND *, void(*rtplay__)(CSOUND *, const MYFLT *outBuf, int nbytes))
309
310 // PUBLIC void csoundSetRecopenCallback(CSOUND*, int(* recopen_)(CSOUND*, const csRtAudioParams* parm))
311
312 // PUBLIC void csoundSetRtrecordCallback (CSOUND *, int(*rtrecord__)(CSOUND *, MYFLT *inBuf, int nbytes))
313
314 // PUBLIC void csoundSetRtcloseCallback (CSOUND *, void(*rtclose__)(CSOUND *))
315
316 // PUBLIC void csoundSetAudioDeviceListCallback (CSOUND *csound, int(*audiodevlist__)(CSOUND *, CS_AUDIODEVICE *list, int isOutput))
317
318 #endregion Realtime Audio I/O
319
320
321 #region Realtime Midi I/O
322
323 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
324 internal static extern void csoundSetMIDIModule([In] IntPtr csound, [In, MarshalAs(UnmanagedType.LPStr)] string module);
325
326 // PUBLIC void csoundSetHostImplementedMIDIIO (CSOUND *csound, int state)
327
328 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
329 internal static extern Int32 csoundGetMIDIDevList([In] IntPtr csound, [Out] IntPtr list, [In] Int32 isOutput);
330
331 // PUBLIC void csoundSetExternalMidiInOpenCallback (CSOUND *, int(*func)(CSOUND *, void **userData, const char *devName))
332
333 // PUBLIC void csoundSetExternalMidiReadCallback (CSOUND *, int(*func)(CSOUND *, void *userData, unsigned char *buf, int nBytes))
334
335 // PUBLIC void csoundSetExternalMidiInCloseCallback (CSOUND *, int(*func)(CSOUND *, void *userData))
336
337 // PUBLIC void csoundSetExternalMidiOutOpenCallback (CSOUND *, int(*func)(CSOUND *, void **userData, const char *devName))
338
339 // PUBLIC void csoundSetExternalMidiWriteCallback (CSOUND *, int(*func)(CSOUND *, void *userData, const unsigned char *buf, int nBytes))
340
341 // PUBLIC void csoundSetExternalMidiOutCloseCallback (CSOUND *, int(*func)(CSOUND *, void *userData))
342
343 // PUBLIC void csoundSetExternalMidiErrorStringCallback (CSOUND *, const char *(*func)(int))
344
345 // PUBLIC void csoundSetMIDIDeviceListCallback (CSOUND *csound, int(*mididevlist__)(CSOUND *, CS_MIDIDEVICE *list, int isOutput))
346
347 #endregion Realtime Midi I/O
348
349
350 #region Score Handling
351
352 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
353 internal static extern Int32 csoundReadScore([In] IntPtr csound, [In, MarshalAs(UnmanagedType.LPStr)] string score);
354
355 // PUBLIC void csoundReadScoreAsync (CSOUND *csound, const char *str)
356
357 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
358 internal static extern MYFLT csoundGetScoreTime([In] IntPtr csound);
359
360 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
361 internal static extern int csoundIsScorePending([In] IntPtr csound);
362
363 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
364 internal static extern void csoundSetScorePending([In] IntPtr csound, [In] Int32 pending);
365
366 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
367 internal static extern MYFLT csoundGetScoreOffsetSeconds([In] IntPtr csound);
368
369 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
370 internal static extern void csoundSetScoreOffsetSeconds([In] IntPtr csound, [In] MYFLT time);
371
372 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
373 internal static extern void csoundRewindScore([In] IntPtr csound);
374
375 // PUBLIC void csoundSetCscoreCallback (CSOUND *, void(*cscoreCallback_)(CSOUND *))
376
377 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
378 internal static extern int csoundScoreSort([In] IntPtr csound, [In] IntPtr inFile, [In] IntPtr outFile);
379
380 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
381 internal static extern int csoundScoreExtract(IntPtr csound, IntPtr inFile, IntPtr outFile, IntPtr extractFile);
382
383 #endregion Score Handling
384
385
386 #region Messages and Text
387
388 // PUBLIC CS_PRINTF2 void csoundMessage (CSOUND *, const char *format,...)
389
390 // PUBLIC CS_PRINTF3 void csoundMessageS (CSOUND *, int attr, const char *format,...)
391
392 // PUBLIC void csoundMessageV (CSOUND *, int attr, const char *format, va_list args)
393
394 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
395 internal static extern void csoundSetDefaultMessageCallback(MessageCallbackProxy processMessage);
396
397 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
398 internal static extern void csoundSetMessageCallback([In] IntPtr csound, MessageCallbackProxy processMessage);
399
400 // PUBLIC void csoundSetMessageStringCallback (CSOUND *csound, void(*csoundMessageStrCallback)(CSOUND *csound, int attr, const char *str))
401
402 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
403 internal static extern Int32 csoundGetMessageLevel([In] IntPtr csound);
404
405 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
406 internal static extern void csoundSetMessageLevel([In] IntPtr csound, [In] Int32 messageLevel);
407
408 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
409 internal static extern void csoundCreateMessageBuffer([In] IntPtr csound, [In] int toStdOut);
410
411 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
412 internal static extern IntPtr csoundGetFirstMessage([In] IntPtr csound);
413
414 // PUBLIC int csoundGetFirstMessageAttr (CSOUND *csound)
415
416 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
417 internal static extern void csoundPopFirstMessage([In] IntPtr csound);
418
419 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
420 internal static extern int csoundGetMessageCnt([In] IntPtr csound);
421
422 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
423 internal static extern void csoundDestroyMessageBuffer([In] IntPtr csound);
424
425 #endregion Messages and Text
426
427
428 #region Channels, Control and Events
429
430 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
431 internal static extern int csoundGetChannelPtr([In] IntPtr csound, out IntPtr pChannel, [In, MarshalAs(UnmanagedType.LPStr)] string name, [In] Int32 flags);
432
433 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
434 internal static extern Int32 csoundListChannels([In] IntPtr csound, [Out] out IntPtr ppChannels);
435
436 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
437 internal static extern void csoundDeleteChannelList([In] IntPtr csound, [In] IntPtr ppChannels);
438
439 // PUBLIC int csoundSetControlChannelHints (CSOUND *, const char *name, controlChannelHints_t hints)
440
441 // PUBLIC int csoundGetControlChannelHints (CSOUND *, const char *name, controlChannelHints_t *hints)
442
443 // PUBLIC int * csoundGetChannelLock (CSOUND *, const char *name)
444
445 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
446 internal static extern MYFLT csoundGetControlChannel([In] IntPtr csound, [In] String str, [In] IntPtr err);
447
448 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
449 internal static extern IntPtr csoundSetControlChannel([In] IntPtr csound, [In] String str, [In] MYFLT value);
450
451 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
452 internal static extern void csoundGetAudioChannel([In] IntPtr csound, [In, MarshalAs(UnmanagedType.LPStr)] string name, IntPtr samples);
453
454 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
455 internal static extern void csoundSetAudioChannel([In] IntPtr csound, [In, MarshalAs(UnmanagedType.LPStr)] string name, IntPtr samples);
456
457
458 // PUBLIC void csoundGetStringChannel (CSOUND *csound, const char *name, char *string)
459
460 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
461 internal static extern IntPtr csoundSetStringChannel([In] IntPtr csound, [In] String str, [In] String value);
462
463 // PUBLIC int csoundGetChannelDatasize (CSOUND *csound, const char *name)
464
465 // PUBLIC void csoundSetInputChannelCallback (CSOUND *csound, channelCallback_t inputChannelCalback)
466
467 // PUBLIC void csoundSetOutputChannelCallback (CSOUND *csound, channelCallback_t outputChannelCalback)
468
469 // PUBLIC int csoundSetPvsChannel (CSOUND *, const PVSDATEXT *fin, const char *name)
470
471 // PUBLIC int csoundGetPvsChannel (CSOUND *csound, PVSDATEXT *fout, const char *name)
472
473 // PUBLIC int csoundScoreEvent (CSOUND *, char type, const MYFLT *pFields, long numFields)
474
475 // PUBLIC void csoundScoreEventAsync (CSOUND *, char type, const MYFLT *pFields, long numFields)
476
477 // PUBLIC int csoundScoreEventAbsolute (CSOUND *, char type, const MYFLT *pfields, long numFields, double time_ofs)
478
479 // PUBLIC void csoundScoreEventAbsoluteAsync (CSOUND *, char type, const MYFLT *pfields, long numFields, double time_ofs)
480
481 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
482 internal static extern IntPtr csoundInputMessage([In] IntPtr csound, [In] String str);
483
484 // PUBLIC void csoundInputMessageAsync (CSOUND *, const char *message)
485
486 // PUBLIC int csoundKillInstance (CSOUND *csound, MYFLT instr, char *instrName, int mode, int allow_release)
487
488 //[DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
489 //internal static extern int csoundRegisterSenseEventCallback([In] IntPtr csound, SenseEventCallbackProxy senseEventProxy);
490
491 // PUBLIC void csoundKeyPress (CSOUND *, char c)
492
493 // PUBLIC int csoundRegisterKeyboardCallback (CSOUND *, int(*func)(void *userData, void *p, unsigned int type), void *userData, unsigned int type)
494
495 // PUBLIC void csoundRemoveKeyboardCallback (CSOUND *csound, int(*func)(void *, void *, unsigned int))
496
497 #endregion Channels, Control and Events
498
499
500 #region Tables
501
502 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
503 internal static extern Int32 csoundTableLength([In] IntPtr csound, [In] Int32 table);
504
505 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
506 internal static extern MYFLT csoundTableGet([In] IntPtr csound, [In] Int32 table, [In] Int32 index);
507
508 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
509 internal static extern void csoundTableSet([In] IntPtr csound, [In] Int32 table, [In] Int32 index, [In] MYFLT value);
510
511 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
512 internal static extern void csoundTableCopyOut([In] IntPtr csound, Int32 table, IntPtr dest);
513
514 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
515 internal static extern void csoundTableCopyOutAsync([In] IntPtr csound, Int32 table, IntPtr dest);
516
517 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
518 internal static extern void csoundTableCopyIn([In] IntPtr csound, [In] Int32 table, IntPtr source);
519
520 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
521 internal static extern void csoundTableCopyInAsync([In] IntPtr csound, [In] Int32 table, IntPtr source);
522
523 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
524 internal static extern Int32 csoundGetTable([In] IntPtr csound, out IntPtr tablePtr, [In] Int32 index);
525
526 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
527 internal static extern Int32 csoundGetTableArgs([In] IntPtr csound, out IntPtr argsPtr, [In] Int32 index);
528
529 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
530 internal static extern Int32 csoundIsNamedGEN([In] IntPtr csound, [In] Int32 num);
531
532 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
533 internal static extern void csoundGetNamedGEN([In] IntPtr csound, [In] Int32 num, out string name, Int32 len);
534
535 #endregion Tables
536
537
538 #region Function table display
539
540 // PUBLIC int csoundSetIsGraphable(CSOUND*, int isGraphable)
541
542 // PUBLIC void csoundSetMakeGraphCallback (CSOUND *, void(*makeGraphCallback_)(CSOUND *, WINDAT *windat, const char *name))
543
544 // PUBLIC void csoundSetDrawGraphCallback (CSOUND *, void(*drawGraphCallback_)(CSOUND *, WINDAT *windat))
545
546 // PUBLIC void csoundSetKillGraphCallback (CSOUND *, void(*killGraphCallback_)(CSOUND *, WINDAT *windat))
547
548 // PUBLIC void csoundSetExitGraphCallback (CSOUND *, int(*exitGraphCallback_)(CSOUND *))
549
550 #endregion Function table display
551
552
553 #region Opcodes
554
555 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
556 internal static extern IntPtr csoundGetNamedGens([In] IntPtr csound);
557
558 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
559 internal static extern Int32 csoundNewOpcodeList([In] IntPtr csound, [Out] out IntPtr ppOpcodeList);
560
561 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
562 internal static extern void csoundDisposeOpcodeList([In] IntPtr csound, [In] IntPtr ppOpcodeList);
563
564 // PUBLIC int csoundAppendOpcode (CSOUND *, const char *opname, int dsblksiz, int flags, int thread, const char *outypes, const char *intypes, int(*iopadr)(CSOUND *, void *), int(*kopadr)(CSOUND *, void *), int(*aopadr)(CSOUND *, void *))
565
566 #endregion Opcodes
567
568
569 #region Threading and concurrency
570
571 //[DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
572 //internal static extern void csoundSetYieldCallback([In] IntPtr csound, YieldCallback yieldCallback);
573
574 // PUBLIC void * csoundCreateThread (uintptr_t(*threadRoutine)(void *), void *userdata)
575
576 // PUBLIC void * csoundGetCurrentThreadId (void)
577
578 // PUBLIC uintptr_t csoundJoinThread (void *thread)
579
580 // PUBLIC void * csoundCreateThreadLock (void)
581
582 // PUBLIC int csoundWaitThreadLock (void *lock, size_t milliseconds)
583
584 // PUBLIC void csoundWaitThreadLockNoTimeout (void *lock)
585
586 // PUBLIC void csoundNotifyThreadLock (void *lock)
587
588 // PUBLIC void csoundDestroyThreadLock (void *lock)
589
590 // PUBLIC void * csoundCreateMutex (int isRecursive)
591
592 // PUBLIC void csoundLockMutex (void *mutex_)
593
594 // PUBLIC int csoundLockMutexNoWait (void *mutex_)
595
596 // PUBLIC void csoundUnlockMutex (void *mutex_)
597
598 // PUBLIC void csoundDestroyMutex (void *mutex_)
599
600 // PUBLIC void * csoundCreateBarrier (unsigned int max)
601
602 // PUBLIC int csoundDestroyBarrier (void *barrier)
603
604 // PUBLIC int csoundWaitBarrier (void *barrier)
605
606 // PUBLIC void * csoundCreateCondVar ()
607
608 // PUBLIC void csoundCondWait (void *condVar, void *mutex)
609
610 // PUBLIC void csoundCondSignal (void *condVar)
611
612 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
613 internal static extern void csoundSleep(uint milleseconds);
614
615 // PUBLIC int csoundSpinLockInit (spin_lock_t *spinlock)
616
617 // PUBLIC void csoundSpinLock (spin_lock_t *spinlock)
618
619 // PUBLIC int csoundSpinTryLock (spin_lock_t *spinlock)
620
621 // PUBLIC void csoundSpinUnLock (spin_lock_t *spinlock)
622
623 #endregion Threading and concurrency
624
625
626 #region Miscellaneous functions
627
628 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
629 internal static extern long csoundRunCommand([In] string[] argv, [In] int nowait);
630
631 // PUBLIC void csoundInitTimerStruct(RTCLOCK*)
632
633 // PUBLIC double csoundGetRealTime (RTCLOCK *)
634
635 // PUBLIC double csoundGetCPUTime (RTCLOCK *)
636
637 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl)]
638 internal static extern UInt32 csoundGetRandomSeedFromTime();
639
640 // PUBLIC void csoundSetLanguage(cslanguage_t lang_code)
641
642 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
643 internal static extern IntPtr csoundGetEnv([In] IntPtr csound, [In, MarshalAs(UnmanagedType.LPStr)] String key);
644
645 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
646 internal static extern Int32 csoundSetGlobalEnv([In, MarshalAs(UnmanagedType.LPStr)] string name, [In, MarshalAs(UnmanagedType.LPStr)] string value);
647
648 // PUBLIC int csoundCreateGlobalVariable (CSOUND *, const char *name, size_t nbytes)
649
650 // PUBLIC void * csoundQueryGlobalVariable (CSOUND *, const char *name)
651
652 // PUBLIC void * csoundQueryGlobalVariableNoCheck (CSOUND *, const char *name)
653
654 // PUBLIC int csoundDestroyGlobalVariable (CSOUND *, const char *name)
655
656 // PUBLIC int csoundRunUtility (CSOUND *, const char *name, int argc, char **argv)
657
658 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
659 internal static extern IntPtr csoundListUtilities([In] IntPtr csound);
660
661 [DllImport(_dllVersion, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
662 internal static extern void csoundDeleteUtilityList([In] IntPtr csound, IntPtr list);
663
664 // PUBLIC const char *csoundGetUtilityDescription(CSOUND*, const char* utilName)
665
666 // PUBLIC int csoundRand31 (int *seedVal)
667
668 // PUBLIC void csoundSeedRandMT (CsoundRandMTState *p, const uint32_t *initKey, uint32_t keyLength)
669
670 // PUBLIC uint32_t csoundRandMT (CsoundRandMTState *p)
671
672 // PUBLIC void * csoundCreateCircularBuffer (CSOUND *csound, int numelem, int elemsize)
673
674 // PUBLIC int csoundReadCircularBuffer (CSOUND *csound, void *circular_buffer, void *out, int items)
675
676 // PUBLIC int csoundPeekCircularBuffer (CSOUND *csound, void *circular_buffer, void *out, int items)
677
678 // PUBLIC int csoundWriteCircularBuffer (CSOUND *csound, void *p, const void *inp, int items)
679
680 // PUBLIC void csoundFlushCircularBuffer (CSOUND *csound, void *p)
681
682 // PUBLIC void csoundDestroyCircularBuffer (CSOUND *csound, void *circularbuffer)
683
684 // PUBLIC int csoundOpenLibrary (void **library, const char *libraryPath)
685
686 // PUBLIC int csoundCloseLibrary (void *library)
687
688 // PUBLIC void * csoundGetLibrarySymbol (void *library, const char *symbolName)
689
690 #endregion Miscellaneous functions
691 }
692 }
693}