summary refs log tree commit diff stats
path: root/vendor/fmod/inc/fmod.cs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/fmod/inc/fmod.cs')
-rw-r--r--vendor/fmod/inc/fmod.cs3974
1 files changed, 3974 insertions, 0 deletions
diff --git a/vendor/fmod/inc/fmod.cs b/vendor/fmod/inc/fmod.cs new file mode 100644 index 0000000..6345688 --- /dev/null +++ b/vendor/fmod/inc/fmod.cs
@@ -0,0 +1,3974 @@
1/* ======================================================================================== */
2/* FMOD Core API - C# wrapper. */
3/* Copyright (c), Firelight Technologies Pty, Ltd. 2004-2021. */
4/* */
5/* For more detail visit: */
6/* https://fmod.com/resources/documentation-api?version=2.0&page=core-api.html */
7/* ======================================================================================== */
8
9using System;
10using System.Text;
11using System.Runtime.InteropServices;
12using System.Collections.Generic;
13
14namespace FMOD
15{
16 /*
17 FMOD version number. Check this against FMOD::System::getVersion / System_GetVersion
18 0xaaaabbcc -> aaaa = major version number. bb = minor version number. cc = development version number.
19 */
20 public partial class VERSION
21 {
22 public const int number = 0x00020205;
23#if !UNITY_2019_4_OR_NEWER
24 public const string dll = "fmod";
25#endif
26 }
27
28 public class CONSTANTS
29 {
30 public const int MAX_CHANNEL_WIDTH = 32;
31 public const int MAX_LISTENERS = 8;
32 public const int REVERB_MAXINSTANCES = 4;
33 public const int MAX_SYSTEMS = 8;
34 }
35
36 /*
37 FMOD core types
38 */
39 public enum RESULT : int
40 {
41 OK,
42 ERR_BADCOMMAND,
43 ERR_CHANNEL_ALLOC,
44 ERR_CHANNEL_STOLEN,
45 ERR_DMA,
46 ERR_DSP_CONNECTION,
47 ERR_DSP_DONTPROCESS,
48 ERR_DSP_FORMAT,
49 ERR_DSP_INUSE,
50 ERR_DSP_NOTFOUND,
51 ERR_DSP_RESERVED,
52 ERR_DSP_SILENCE,
53 ERR_DSP_TYPE,
54 ERR_FILE_BAD,
55 ERR_FILE_COULDNOTSEEK,
56 ERR_FILE_DISKEJECTED,
57 ERR_FILE_EOF,
58 ERR_FILE_ENDOFDATA,
59 ERR_FILE_NOTFOUND,
60 ERR_FORMAT,
61 ERR_HEADER_MISMATCH,
62 ERR_HTTP,
63 ERR_HTTP_ACCESS,
64 ERR_HTTP_PROXY_AUTH,
65 ERR_HTTP_SERVER_ERROR,
66 ERR_HTTP_TIMEOUT,
67 ERR_INITIALIZATION,
68 ERR_INITIALIZED,
69 ERR_INTERNAL,
70 ERR_INVALID_FLOAT,
71 ERR_INVALID_HANDLE,
72 ERR_INVALID_PARAM,
73 ERR_INVALID_POSITION,
74 ERR_INVALID_SPEAKER,
75 ERR_INVALID_SYNCPOINT,
76 ERR_INVALID_THREAD,
77 ERR_INVALID_VECTOR,
78 ERR_MAXAUDIBLE,
79 ERR_MEMORY,
80 ERR_MEMORY_CANTPOINT,
81 ERR_NEEDS3D,
82 ERR_NEEDSHARDWARE,
83 ERR_NET_CONNECT,
84 ERR_NET_SOCKET_ERROR,
85 ERR_NET_URL,
86 ERR_NET_WOULD_BLOCK,
87 ERR_NOTREADY,
88 ERR_OUTPUT_ALLOCATED,
89 ERR_OUTPUT_CREATEBUFFER,
90 ERR_OUTPUT_DRIVERCALL,
91 ERR_OUTPUT_FORMAT,
92 ERR_OUTPUT_INIT,
93 ERR_OUTPUT_NODRIVERS,
94 ERR_PLUGIN,
95 ERR_PLUGIN_MISSING,
96 ERR_PLUGIN_RESOURCE,
97 ERR_PLUGIN_VERSION,
98 ERR_RECORD,
99 ERR_REVERB_CHANNELGROUP,
100 ERR_REVERB_INSTANCE,
101 ERR_SUBSOUNDS,
102 ERR_SUBSOUND_ALLOCATED,
103 ERR_SUBSOUND_CANTMOVE,
104 ERR_TAGNOTFOUND,
105 ERR_TOOMANYCHANNELS,
106 ERR_TRUNCATED,
107 ERR_UNIMPLEMENTED,
108 ERR_UNINITIALIZED,
109 ERR_UNSUPPORTED,
110 ERR_VERSION,
111 ERR_EVENT_ALREADY_LOADED,
112 ERR_EVENT_LIVEUPDATE_BUSY,
113 ERR_EVENT_LIVEUPDATE_MISMATCH,
114 ERR_EVENT_LIVEUPDATE_TIMEOUT,
115 ERR_EVENT_NOTFOUND,
116 ERR_STUDIO_UNINITIALIZED,
117 ERR_STUDIO_NOT_LOADED,
118 ERR_INVALID_STRING,
119 ERR_ALREADY_LOCKED,
120 ERR_NOT_LOCKED,
121 ERR_RECORD_DISCONNECTED,
122 ERR_TOOMANYSAMPLES,
123 }
124
125 public enum CHANNELCONTROL_TYPE : int
126 {
127 CHANNEL,
128 CHANNELGROUP,
129 MAX
130 }
131
132 [StructLayout(LayoutKind.Sequential)]
133 public struct VECTOR
134 {
135 public float x;
136 public float y;
137 public float z;
138 }
139
140 [StructLayout(LayoutKind.Sequential)]
141 public struct ATTRIBUTES_3D
142 {
143 public VECTOR position;
144 public VECTOR velocity;
145 public VECTOR forward;
146 public VECTOR up;
147 }
148
149 [StructLayout(LayoutKind.Sequential)]
150 public partial struct GUID
151 {
152 public int Data1;
153 public int Data2;
154 public int Data3;
155 public int Data4;
156 }
157
158 [StructLayout(LayoutKind.Sequential)]
159 public struct ASYNCREADINFO
160 {
161 public IntPtr handle;
162 public uint offset;
163 public uint sizebytes;
164 public int priority;
165
166 public IntPtr userdata;
167 public IntPtr buffer;
168 public uint bytesread;
169 public FILE_ASYNCDONE_FUNC done;
170 }
171
172 public enum OUTPUTTYPE : int
173 {
174 AUTODETECT,
175
176 UNKNOWN,
177 NOSOUND,
178 WAVWRITER,
179 NOSOUND_NRT,
180 WAVWRITER_NRT,
181
182 WASAPI,
183 ASIO,
184 PULSEAUDIO,
185 ALSA,
186 COREAUDIO,
187 AUDIOTRACK,
188 OPENSL,
189 AUDIOOUT,
190 AUDIO3D,
191 WEBAUDIO,
192 NNAUDIO,
193 WINSONIC,
194 AAUDIO,
195 AUDIOWORKLET,
196
197 MAX,
198 }
199
200 public enum PORT_TYPE : int
201 {
202 MUSIC,
203 COPYRIGHT_MUSIC,
204 VOICE,
205 CONTROLLER,
206 PERSONAL,
207 VIBRATION,
208 AUX,
209
210 MAX
211 }
212
213 public enum DEBUG_MODE : int
214 {
215 TTY,
216 FILE,
217 CALLBACK,
218 }
219
220 [Flags]
221 public enum DEBUG_FLAGS : uint
222 {
223 NONE = 0x00000000,
224 ERROR = 0x00000001,
225 WARNING = 0x00000002,
226 LOG = 0x00000004,
227
228 TYPE_MEMORY = 0x00000100,
229 TYPE_FILE = 0x00000200,
230 TYPE_CODEC = 0x00000400,
231 TYPE_TRACE = 0x00000800,
232
233 DISPLAY_TIMESTAMPS = 0x00010000,
234 DISPLAY_LINENUMBERS = 0x00020000,
235 DISPLAY_THREAD = 0x00040000,
236 }
237
238 [Flags]
239 public enum MEMORY_TYPE : uint
240 {
241 NORMAL = 0x00000000,
242 STREAM_FILE = 0x00000001,
243 STREAM_DECODE = 0x00000002,
244 SAMPLEDATA = 0x00000004,
245 DSP_BUFFER = 0x00000008,
246 PLUGIN = 0x00000010,
247 PERSISTENT = 0x00200000,
248 ALL = 0xFFFFFFFF
249 }
250
251 public enum SPEAKERMODE : int
252 {
253 DEFAULT,
254 RAW,
255 MONO,
256 STEREO,
257 QUAD,
258 SURROUND,
259 _5POINT1,
260 _7POINT1,
261 _7POINT1POINT4,
262
263 MAX,
264 }
265
266 public enum SPEAKER : int
267 {
268 NONE = -1,
269 FRONT_LEFT,
270 FRONT_RIGHT,
271 FRONT_CENTER,
272 LOW_FREQUENCY,
273 SURROUND_LEFT,
274 SURROUND_RIGHT,
275 BACK_LEFT,
276 BACK_RIGHT,
277 TOP_FRONT_LEFT,
278 TOP_FRONT_RIGHT,
279 TOP_BACK_LEFT,
280 TOP_BACK_RIGHT,
281
282 MAX,
283 }
284
285 [Flags]
286 public enum CHANNELMASK : uint
287 {
288 FRONT_LEFT = 0x00000001,
289 FRONT_RIGHT = 0x00000002,
290 FRONT_CENTER = 0x00000004,
291 LOW_FREQUENCY = 0x00000008,
292 SURROUND_LEFT = 0x00000010,
293 SURROUND_RIGHT = 0x00000020,
294 BACK_LEFT = 0x00000040,
295 BACK_RIGHT = 0x00000080,
296 BACK_CENTER = 0x00000100,
297
298 MONO = (FRONT_LEFT),
299 STEREO = (FRONT_LEFT | FRONT_RIGHT),
300 LRC = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER),
301 QUAD = (FRONT_LEFT | FRONT_RIGHT | SURROUND_LEFT | SURROUND_RIGHT),
302 SURROUND = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | SURROUND_LEFT | SURROUND_RIGHT),
303 _5POINT1 = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | LOW_FREQUENCY | SURROUND_LEFT | SURROUND_RIGHT),
304 _5POINT1_REARS = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | LOW_FREQUENCY | BACK_LEFT | BACK_RIGHT),
305 _7POINT0 = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | SURROUND_LEFT | SURROUND_RIGHT | BACK_LEFT | BACK_RIGHT),
306 _7POINT1 = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | LOW_FREQUENCY | SURROUND_LEFT | SURROUND_RIGHT | BACK_LEFT | BACK_RIGHT)
307 }
308
309 public enum CHANNELORDER : int
310 {
311 DEFAULT,
312 WAVEFORMAT,
313 PROTOOLS,
314 ALLMONO,
315 ALLSTEREO,
316 ALSA,
317
318 MAX,
319 }
320
321 public enum PLUGINTYPE : int
322 {
323 OUTPUT,
324 CODEC,
325 DSP,
326
327 MAX,
328 }
329
330 [StructLayout(LayoutKind.Sequential)]
331 public struct PLUGINLIST
332 {
333 PLUGINTYPE type;
334 IntPtr description;
335 }
336
337 [Flags]
338 public enum INITFLAGS : uint
339 {
340 NORMAL = 0x00000000,
341 STREAM_FROM_UPDATE = 0x00000001,
342 MIX_FROM_UPDATE = 0x00000002,
343 _3D_RIGHTHANDED = 0x00000004,
344 CHANNEL_LOWPASS = 0x00000100,
345 CHANNEL_DISTANCEFILTER = 0x00000200,
346 PROFILE_ENABLE = 0x00010000,
347 VOL0_BECOMES_VIRTUAL = 0x00020000,
348 GEOMETRY_USECLOSEST = 0x00040000,
349 PREFER_DOLBY_DOWNMIX = 0x00080000,
350 THREAD_UNSAFE = 0x00100000,
351 PROFILE_METER_ALL = 0x00200000,
352 MEMORY_TRACKING = 0x00400000,
353 }
354
355 public enum SOUND_TYPE : int
356 {
357 UNKNOWN,
358 AIFF,
359 ASF,
360 DLS,
361 FLAC,
362 FSB,
363 IT,
364 MIDI,
365 MOD,
366 MPEG,
367 OGGVORBIS,
368 PLAYLIST,
369 RAW,
370 S3M,
371 USER,
372 WAV,
373 XM,
374 XMA,
375 AUDIOQUEUE,
376 AT9,
377 VORBIS,
378 MEDIA_FOUNDATION,
379 MEDIACODEC,
380 FADPCM,
381 OPUS,
382
383 MAX,
384 }
385
386 public enum SOUND_FORMAT : int
387 {
388 NONE,
389 PCM8,
390 PCM16,
391 PCM24,
392 PCM32,
393 PCMFLOAT,
394 BITSTREAM,
395
396 MAX
397 }
398
399 [Flags]
400 public enum MODE : uint
401 {
402 DEFAULT = 0x00000000,
403 LOOP_OFF = 0x00000001,
404 LOOP_NORMAL = 0x00000002,
405 LOOP_BIDI = 0x00000004,
406 _2D = 0x00000008,
407 _3D = 0x00000010,
408 CREATESTREAM = 0x00000080,
409 CREATESAMPLE = 0x00000100,
410 CREATECOMPRESSEDSAMPLE = 0x00000200,
411 OPENUSER = 0x00000400,
412 OPENMEMORY = 0x00000800,
413 OPENMEMORY_POINT = 0x10000000,
414 OPENRAW = 0x00001000,
415 OPENONLY = 0x00002000,
416 ACCURATETIME = 0x00004000,
417 MPEGSEARCH = 0x00008000,
418 NONBLOCKING = 0x00010000,
419 UNIQUE = 0x00020000,
420 _3D_HEADRELATIVE = 0x00040000,
421 _3D_WORLDRELATIVE = 0x00080000,
422 _3D_INVERSEROLLOFF = 0x00100000,
423 _3D_LINEARROLLOFF = 0x00200000,
424 _3D_LINEARSQUAREROLLOFF = 0x00400000,
425 _3D_INVERSETAPEREDROLLOFF = 0x00800000,
426 _3D_CUSTOMROLLOFF = 0x04000000,
427 _3D_IGNOREGEOMETRY = 0x40000000,
428 IGNORETAGS = 0x02000000,
429 LOWMEM = 0x08000000,
430 VIRTUAL_PLAYFROMSTART = 0x80000000
431 }
432
433 public enum OPENSTATE : int
434 {
435 READY = 0,
436 LOADING,
437 ERROR,
438 CONNECTING,
439 BUFFERING,
440 SEEKING,
441 PLAYING,
442 SETPOSITION,
443
444 MAX,
445 }
446
447 public enum SOUNDGROUP_BEHAVIOR : int
448 {
449 BEHAVIOR_FAIL,
450 BEHAVIOR_MUTE,
451 BEHAVIOR_STEALLOWEST,
452
453 MAX,
454 }
455
456 public enum CHANNELCONTROL_CALLBACK_TYPE : int
457 {
458 END,
459 VIRTUALVOICE,
460 SYNCPOINT,
461 OCCLUSION,
462
463 MAX,
464 }
465
466 public struct CHANNELCONTROL_DSP_INDEX
467 {
468 public const int HEAD = -1;
469 public const int FADER = -2;
470 public const int TAIL = -3;
471 }
472
473 public enum ERRORCALLBACK_INSTANCETYPE : int
474 {
475 NONE,
476 SYSTEM,
477 CHANNEL,
478 CHANNELGROUP,
479 CHANNELCONTROL,
480 SOUND,
481 SOUNDGROUP,
482 DSP,
483 DSPCONNECTION,
484 GEOMETRY,
485 REVERB3D,
486 STUDIO_SYSTEM,
487 STUDIO_EVENTDESCRIPTION,
488 STUDIO_EVENTINSTANCE,
489 STUDIO_PARAMETERINSTANCE,
490 STUDIO_BUS,
491 STUDIO_VCA,
492 STUDIO_BANK,
493 STUDIO_COMMANDREPLAY
494 }
495
496 [StructLayout(LayoutKind.Sequential)]
497 public struct ERRORCALLBACK_INFO
498 {
499 public RESULT result;
500 public ERRORCALLBACK_INSTANCETYPE instancetype;
501 public IntPtr instance;
502 public StringWrapper functionname;
503 public StringWrapper functionparams;
504 }
505
506 [StructLayout(LayoutKind.Sequential)]
507 public struct CPU_USAGE
508 {
509 public float dsp; /* DSP mixing CPU usage. */
510 public float stream; /* Streaming engine CPU usage. */
511 public float geometry; /* Geometry engine CPU usage. */
512 public float update; /* System::update CPU usage. */
513 public float convolution1; /* Convolution reverb processing thread #1 CPU usage */
514 public float convolution2; /* Convolution reverb processing thread #2 CPU usage */
515 }
516
517 [Flags]
518 public enum SYSTEM_CALLBACK_TYPE : uint
519 {
520 DEVICELISTCHANGED = 0x00000001,
521 DEVICELOST = 0x00000002,
522 MEMORYALLOCATIONFAILED = 0x00000004,
523 THREADCREATED = 0x00000008,
524 BADDSPCONNECTION = 0x00000010,
525 PREMIX = 0x00000020,
526 POSTMIX = 0x00000040,
527 ERROR = 0x00000080,
528 MIDMIX = 0x00000100,
529 THREADDESTROYED = 0x00000200,
530 PREUPDATE = 0x00000400,
531 POSTUPDATE = 0x00000800,
532 RECORDLISTCHANGED = 0x00001000,
533 BUFFEREDNOMIX = 0x00002000,
534 DEVICEREINITIALIZE = 0x00004000,
535 OUTPUTUNDERRUN = 0x00008000,
536 ALL = 0xFFFFFFFF,
537 }
538
539 /*
540 FMOD Callbacks
541 */
542 public delegate RESULT DEBUG_CALLBACK (DEBUG_FLAGS flags, IntPtr file, int line, IntPtr func, IntPtr message);
543 public delegate RESULT SYSTEM_CALLBACK (IntPtr system, SYSTEM_CALLBACK_TYPE type, IntPtr commanddata1, IntPtr commanddata2, IntPtr userdata);
544 public delegate RESULT CHANNELCONTROL_CALLBACK (IntPtr channelcontrol, CHANNELCONTROL_TYPE controltype, CHANNELCONTROL_CALLBACK_TYPE callbacktype, IntPtr commanddata1, IntPtr commanddata2);
545 public delegate RESULT SOUND_NONBLOCK_CALLBACK (IntPtr sound, RESULT result);
546 public delegate RESULT SOUND_PCMREAD_CALLBACK (IntPtr sound, IntPtr data, uint datalen);
547 public delegate RESULT SOUND_PCMSETPOS_CALLBACK (IntPtr sound, int subsound, uint position, TIMEUNIT postype);
548 public delegate RESULT FILE_OPEN_CALLBACK (IntPtr name, ref uint filesize, ref IntPtr handle, IntPtr userdata);
549 public delegate RESULT FILE_CLOSE_CALLBACK (IntPtr handle, IntPtr userdata);
550 public delegate RESULT FILE_READ_CALLBACK (IntPtr handle, IntPtr buffer, uint sizebytes, ref uint bytesread, IntPtr userdata);
551 public delegate RESULT FILE_SEEK_CALLBACK (IntPtr handle, uint pos, IntPtr userdata);
552 public delegate RESULT FILE_ASYNCREAD_CALLBACK (IntPtr info, IntPtr userdata);
553 public delegate RESULT FILE_ASYNCCANCEL_CALLBACK(IntPtr info, IntPtr userdata);
554 public delegate RESULT FILE_ASYNCDONE_FUNC (IntPtr info, RESULT result);
555 public delegate IntPtr MEMORY_ALLOC_CALLBACK (uint size, MEMORY_TYPE type, IntPtr sourcestr);
556 public delegate IntPtr MEMORY_REALLOC_CALLBACK (IntPtr ptr, uint size, MEMORY_TYPE type, IntPtr sourcestr);
557 public delegate void MEMORY_FREE_CALLBACK (IntPtr ptr, MEMORY_TYPE type, IntPtr sourcestr);
558 public delegate float CB_3D_ROLLOFF_CALLBACK (IntPtr channelcontrol, float distance);
559
560 public enum DSP_RESAMPLER : int
561 {
562 DEFAULT,
563 NOINTERP,
564 LINEAR,
565 CUBIC,
566 SPLINE,
567
568 MAX,
569 }
570
571 public enum DSPCONNECTION_TYPE : int
572 {
573 STANDARD,
574 SIDECHAIN,
575 SEND,
576 SEND_SIDECHAIN,
577
578 MAX,
579 }
580
581 public enum TAGTYPE : int
582 {
583 UNKNOWN = 0,
584 ID3V1,
585 ID3V2,
586 VORBISCOMMENT,
587 SHOUTCAST,
588 ICECAST,
589 ASF,
590 MIDI,
591 PLAYLIST,
592 FMOD,
593 USER,
594
595 MAX
596 }
597
598 public enum TAGDATATYPE : int
599 {
600 BINARY = 0,
601 INT,
602 FLOAT,
603 STRING,
604 STRING_UTF16,
605 STRING_UTF16BE,
606 STRING_UTF8,
607
608 MAX
609 }
610
611 [StructLayout(LayoutKind.Sequential)]
612 public struct TAG
613 {
614 public TAGTYPE type;
615 public TAGDATATYPE datatype;
616 public StringWrapper name;
617 public IntPtr data;
618 public uint datalen;
619 public bool updated;
620 }
621
622 [Flags]
623 public enum TIMEUNIT : uint
624 {
625 MS = 0x00000001,
626 PCM = 0x00000002,
627 PCMBYTES = 0x00000004,
628 RAWBYTES = 0x00000008,
629 PCMFRACTION = 0x00000010,
630 MODORDER = 0x00000100,
631 MODROW = 0x00000200,
632 MODPATTERN = 0x00000400,
633 }
634
635 public struct PORT_INDEX
636 {
637 public const ulong NONE = 0xFFFFFFFFFFFFFFFF;
638 }
639
640 [StructLayout(LayoutKind.Sequential)]
641 public struct CREATESOUNDEXINFO
642 {
643 public int cbsize;
644 public uint length;
645 public uint fileoffset;
646 public int numchannels;
647 public int defaultfrequency;
648 public SOUND_FORMAT format;
649 public uint decodebuffersize;
650 public int initialsubsound;
651 public int numsubsounds;
652 public IntPtr inclusionlist;
653 public int inclusionlistnum;
654 public SOUND_PCMREAD_CALLBACK pcmreadcallback;
655 public SOUND_PCMSETPOS_CALLBACK pcmsetposcallback;
656 public SOUND_NONBLOCK_CALLBACK nonblockcallback;
657 public IntPtr dlsname;
658 public IntPtr encryptionkey;
659 public int maxpolyphony;
660 public IntPtr userdata;
661 public SOUND_TYPE suggestedsoundtype;
662 public FILE_OPEN_CALLBACK fileuseropen;
663 public FILE_CLOSE_CALLBACK fileuserclose;
664 public FILE_READ_CALLBACK fileuserread;
665 public FILE_SEEK_CALLBACK fileuserseek;
666 public FILE_ASYNCREAD_CALLBACK fileuserasyncread;
667 public FILE_ASYNCCANCEL_CALLBACK fileuserasynccancel;
668 public IntPtr fileuserdata;
669 public int filebuffersize;
670 public CHANNELORDER channelorder;
671 public IntPtr initialsoundgroup;
672 public uint initialseekposition;
673 public TIMEUNIT initialseekpostype;
674 public int ignoresetfilesystem;
675 public uint audioqueuepolicy;
676 public uint minmidigranularity;
677 public int nonblockthreadid;
678 public IntPtr fsbguid;
679 }
680
681#pragma warning disable 414
682 [StructLayout(LayoutKind.Sequential)]
683 public struct REVERB_PROPERTIES
684 {
685 public float DecayTime;
686 public float EarlyDelay;
687 public float LateDelay;
688 public float HFReference;
689 public float HFDecayRatio;
690 public float Diffusion;
691 public float Density;
692 public float LowShelfFrequency;
693 public float LowShelfGain;
694 public float HighCut;
695 public float EarlyLateMix;
696 public float WetLevel;
697
698 #region wrapperinternal
699 public REVERB_PROPERTIES(float decayTime, float earlyDelay, float lateDelay, float hfReference,
700 float hfDecayRatio, float diffusion, float density, float lowShelfFrequency, float lowShelfGain,
701 float highCut, float earlyLateMix, float wetLevel)
702 {
703 DecayTime = decayTime;
704 EarlyDelay = earlyDelay;
705 LateDelay = lateDelay;
706 HFReference = hfReference;
707 HFDecayRatio = hfDecayRatio;
708 Diffusion = diffusion;
709 Density = density;
710 LowShelfFrequency = lowShelfFrequency;
711 LowShelfGain = lowShelfGain;
712 HighCut = highCut;
713 EarlyLateMix = earlyLateMix;
714 WetLevel = wetLevel;
715 }
716 #endregion
717 }
718#pragma warning restore 414
719
720 public class PRESET
721 {
722 /* Instance Env Diffus Room RoomHF RmLF DecTm DecHF DecLF Refl RefDel Revb RevDel ModTm ModDp HFRef LFRef Diffus Densty FLAGS */
723 public static REVERB_PROPERTIES OFF() { return new REVERB_PROPERTIES( 1000, 7, 11, 5000, 100, 100, 100, 250, 0, 20, 96, -80.0f );}
724 public static REVERB_PROPERTIES GENERIC() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 83, 100, 100, 250, 0, 14500, 96, -8.0f );}
725 public static REVERB_PROPERTIES PADDEDCELL() { return new REVERB_PROPERTIES( 170, 1, 2, 5000, 10, 100, 100, 250, 0, 160, 84, -7.8f );}
726 public static REVERB_PROPERTIES ROOM() { return new REVERB_PROPERTIES( 400, 2, 3, 5000, 83, 100, 100, 250, 0, 6050, 88, -9.4f );}
727 public static REVERB_PROPERTIES BATHROOM() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 54, 100, 60, 250, 0, 2900, 83, 0.5f );}
728 public static REVERB_PROPERTIES LIVINGROOM() { return new REVERB_PROPERTIES( 500, 3, 4, 5000, 10, 100, 100, 250, 0, 160, 58, -19.0f );}
729 public static REVERB_PROPERTIES STONEROOM() { return new REVERB_PROPERTIES( 2300, 12, 17, 5000, 64, 100, 100, 250, 0, 7800, 71, -8.5f );}
730 public static REVERB_PROPERTIES AUDITORIUM() { return new REVERB_PROPERTIES( 4300, 20, 30, 5000, 59, 100, 100, 250, 0, 5850, 64, -11.7f );}
731 public static REVERB_PROPERTIES CONCERTHALL() { return new REVERB_PROPERTIES( 3900, 20, 29, 5000, 70, 100, 100, 250, 0, 5650, 80, -9.8f );}
732 public static REVERB_PROPERTIES CAVE() { return new REVERB_PROPERTIES( 2900, 15, 22, 5000, 100, 100, 100, 250, 0, 20000, 59, -11.3f );}
733 public static REVERB_PROPERTIES ARENA() { return new REVERB_PROPERTIES( 7200, 20, 30, 5000, 33, 100, 100, 250, 0, 4500, 80, -9.6f );}
734 public static REVERB_PROPERTIES HANGAR() { return new REVERB_PROPERTIES( 10000, 20, 30, 5000, 23, 100, 100, 250, 0, 3400, 72, -7.4f );}
735 public static REVERB_PROPERTIES CARPETTEDHALLWAY() { return new REVERB_PROPERTIES( 300, 2, 30, 5000, 10, 100, 100, 250, 0, 500, 56, -24.0f );}
736 public static REVERB_PROPERTIES HALLWAY() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 59, 100, 100, 250, 0, 7800, 87, -5.5f );}
737 public static REVERB_PROPERTIES STONECORRIDOR() { return new REVERB_PROPERTIES( 270, 13, 20, 5000, 79, 100, 100, 250, 0, 9000, 86, -6.0f );}
738 public static REVERB_PROPERTIES ALLEY() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 86, 100, 100, 250, 0, 8300, 80, -9.8f );}
739 public static REVERB_PROPERTIES FOREST() { return new REVERB_PROPERTIES( 1500, 162, 88, 5000, 54, 79, 100, 250, 0, 760, 94, -12.3f );}
740 public static REVERB_PROPERTIES CITY() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 67, 50, 100, 250, 0, 4050, 66, -26.0f );}
741 public static REVERB_PROPERTIES MOUNTAINS() { return new REVERB_PROPERTIES( 1500, 300, 100, 5000, 21, 27, 100, 250, 0, 1220, 82, -24.0f );}
742 public static REVERB_PROPERTIES QUARRY() { return new REVERB_PROPERTIES( 1500, 61, 25, 5000, 83, 100, 100, 250, 0, 3400, 100, -5.0f );}
743 public static REVERB_PROPERTIES PLAIN() { return new REVERB_PROPERTIES( 1500, 179, 100, 5000, 50, 21, 100, 250, 0, 1670, 65, -28.0f );}
744 public static REVERB_PROPERTIES PARKINGLOT() { return new REVERB_PROPERTIES( 1700, 8, 12, 5000, 100, 100, 100, 250, 0, 20000, 56, -19.5f );}
745 public static REVERB_PROPERTIES SEWERPIPE() { return new REVERB_PROPERTIES( 2800, 14, 21, 5000, 14, 80, 60, 250, 0, 3400, 66, 1.2f );}
746 public static REVERB_PROPERTIES UNDERWATER() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 10, 100, 100, 250, 0, 500, 92, 7.0f );}
747 }
748
749 [StructLayout(LayoutKind.Sequential)]
750 public struct ADVANCEDSETTINGS
751 {
752 public int cbSize;
753 public int maxMPEGCodecs;
754 public int maxADPCMCodecs;
755 public int maxXMACodecs;
756 public int maxVorbisCodecs;
757 public int maxAT9Codecs;
758 public int maxFADPCMCodecs;
759 public int maxPCMCodecs;
760 public int ASIONumChannels;
761 public IntPtr ASIOChannelList;
762 public IntPtr ASIOSpeakerList;
763 public float vol0virtualvol;
764 public uint defaultDecodeBufferSize;
765 public ushort profilePort;
766 public uint geometryMaxFadeTime;
767 public float distanceFilterCenterFreq;
768 public int reverb3Dinstance;
769 public int DSPBufferPoolSize;
770 public DSP_RESAMPLER resamplerMethod;
771 public uint randomSeed;
772 public int maxConvolutionThreads;
773 public int maxOpusCodecs;
774 }
775
776 [Flags]
777 public enum DRIVER_STATE : uint
778 {
779 CONNECTED = 0x00000001,
780 DEFAULT = 0x00000002,
781 }
782
783 public enum THREAD_PRIORITY : int
784 {
785 /* Platform specific priority range */
786 PLATFORM_MIN = -32 * 1024,
787 PLATFORM_MAX = 32 * 1024,
788
789 /* Platform agnostic priorities, maps internally to platform specific value */
790 DEFAULT = PLATFORM_MIN - 1,
791 LOW = PLATFORM_MIN - 2,
792 MEDIUM = PLATFORM_MIN - 3,
793 HIGH = PLATFORM_MIN - 4,
794 VERY_HIGH = PLATFORM_MIN - 5,
795 EXTREME = PLATFORM_MIN - 6,
796 CRITICAL = PLATFORM_MIN - 7,
797
798 /* Thread defaults */
799 MIXER = EXTREME,
800 FEEDER = CRITICAL,
801 STREAM = VERY_HIGH,
802 FILE = HIGH,
803 NONBLOCKING = HIGH,
804 RECORD = HIGH,
805 GEOMETRY = LOW,
806 PROFILER = MEDIUM,
807 STUDIO_UPDATE = MEDIUM,
808 STUDIO_LOAD_BANK = MEDIUM,
809 STUDIO_LOAD_SAMPLE = MEDIUM,
810 CONVOLUTION1 = VERY_HIGH,
811 CONVOLUTION2 = VERY_HIGH
812
813 }
814
815 public enum THREAD_STACK_SIZE : uint
816 {
817 DEFAULT = 0,
818 MIXER = 80 * 1024,
819 FEEDER = 16 * 1024,
820 STREAM = 96 * 1024,
821 FILE = 64 * 1024,
822 NONBLOCKING = 112 * 1024,
823 RECORD = 16 * 1024,
824 GEOMETRY = 48 * 1024,
825 PROFILER = 128 * 1024,
826 STUDIO_UPDATE = 96 * 1024,
827 STUDIO_LOAD_BANK = 96 * 1024,
828 STUDIO_LOAD_SAMPLE = 96 * 1024,
829 CONVOLUTION1 = 16 * 1024,
830 CONVOLUTION2 = 16 * 1024
831 }
832
833 [Flags]
834 public enum THREAD_AFFINITY : long
835 {
836 /* Platform agnostic thread groupings */
837 GROUP_DEFAULT = 0x4000000000000000,
838 GROUP_A = 0x4000000000000001,
839 GROUP_B = 0x4000000000000002,
840 GROUP_C = 0x4000000000000003,
841
842 /* Thread defaults */
843 MIXER = GROUP_A,
844 FEEDER = GROUP_C,
845 STREAM = GROUP_C,
846 FILE = GROUP_C,
847 NONBLOCKING = GROUP_C,
848 RECORD = GROUP_C,
849 GEOMETRY = GROUP_C,
850 PROFILER = GROUP_C,
851 STUDIO_UPDATE = GROUP_B,
852 STUDIO_LOAD_BANK = GROUP_C,
853 STUDIO_LOAD_SAMPLE = GROUP_C,
854 CONVOLUTION1 = GROUP_C,
855 CONVOLUTION2 = GROUP_C,
856
857 /* Core mask, valid up to 1 << 61 */
858 CORE_ALL = 0,
859 CORE_0 = 1 << 0,
860 CORE_1 = 1 << 1,
861 CORE_2 = 1 << 2,
862 CORE_3 = 1 << 3,
863 CORE_4 = 1 << 4,
864 CORE_5 = 1 << 5,
865 CORE_6 = 1 << 6,
866 CORE_7 = 1 << 7,
867 CORE_8 = 1 << 8,
868 CORE_9 = 1 << 9,
869 CORE_10 = 1 << 10,
870 CORE_11 = 1 << 11,
871 CORE_12 = 1 << 12,
872 CORE_13 = 1 << 13,
873 CORE_14 = 1 << 14,
874 CORE_15 = 1 << 15
875 }
876
877 public enum THREAD_TYPE : int
878 {
879 MIXER,
880 FEEDER,
881 STREAM,
882 FILE,
883 NONBLOCKING,
884 RECORD,
885 GEOMETRY,
886 PROFILER,
887 STUDIO_UPDATE,
888 STUDIO_LOAD_BANK,
889 STUDIO_LOAD_SAMPLE,
890 CONVOLUTION1,
891 CONVOLUTION2,
892
893 MAX
894 }
895
896 /*
897 FMOD System factory functions. Use this to create an FMOD System Instance. below you will see System init/close to get started.
898 */
899 public struct Factory
900 {
901 public static RESULT System_Create(out System system)
902 {
903 return FMOD5_System_Create(out system.handle, VERSION.number);
904 }
905
906 #region importfunctions
907 [DllImport(VERSION.dll)]
908 private static extern RESULT FMOD5_System_Create(out IntPtr system, uint headerversion);
909
910 #endregion
911 }
912
913 /*
914 FMOD global system functions (optional).
915 */
916 public struct Memory
917 {
918 public static RESULT Initialize(IntPtr poolmem, int poollen, MEMORY_ALLOC_CALLBACK useralloc, MEMORY_REALLOC_CALLBACK userrealloc, MEMORY_FREE_CALLBACK userfree, MEMORY_TYPE memtypeflags = MEMORY_TYPE.ALL)
919 {
920 return FMOD5_Memory_Initialize(poolmem, poollen, useralloc, userrealloc, userfree, memtypeflags);
921 }
922
923 public static RESULT GetStats(out int currentalloced, out int maxalloced, bool blocking = true)
924 {
925 return FMOD5_Memory_GetStats(out currentalloced, out maxalloced, blocking);
926 }
927
928 #region importfunctions
929 [DllImport(VERSION.dll)]
930 private static extern RESULT FMOD5_Memory_Initialize(IntPtr poolmem, int poollen, MEMORY_ALLOC_CALLBACK useralloc, MEMORY_REALLOC_CALLBACK userrealloc, MEMORY_FREE_CALLBACK userfree, MEMORY_TYPE memtypeflags);
931 [DllImport(VERSION.dll)]
932 private static extern RESULT FMOD5_Memory_GetStats (out int currentalloced, out int maxalloced, bool blocking);
933
934 #endregion
935 }
936
937 public struct Debug
938 {
939 public static RESULT Initialize(DEBUG_FLAGS flags, DEBUG_MODE mode = DEBUG_MODE.TTY, DEBUG_CALLBACK callback = null, string filename = null)
940 {
941 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
942 {
943 return FMOD5_Debug_Initialize(flags, mode, callback, encoder.byteFromStringUTF8(filename));
944 }
945 }
946
947 #region importfunctions
948 [DllImport(VERSION.dll)]
949 private static extern RESULT FMOD5_Debug_Initialize(DEBUG_FLAGS flags, DEBUG_MODE mode, DEBUG_CALLBACK callback, byte[] filename);
950
951 #endregion
952 }
953
954 public struct Thread
955 {
956 public static RESULT SetAttributes(THREAD_TYPE type, THREAD_AFFINITY affinity = THREAD_AFFINITY.GROUP_DEFAULT, THREAD_PRIORITY priority = THREAD_PRIORITY.DEFAULT, THREAD_STACK_SIZE stacksize = THREAD_STACK_SIZE.DEFAULT)
957 {
958 return FMOD5_Thread_SetAttributes(type, affinity, priority, stacksize);
959 }
960
961 #region importfunctions
962 [DllImport(VERSION.dll)]
963 private static extern RESULT FMOD5_Thread_SetAttributes(THREAD_TYPE type, THREAD_AFFINITY affinity, THREAD_PRIORITY priority, THREAD_STACK_SIZE stacksize);
964 #endregion
965 }
966
967 /*
968 'System' API.
969 */
970 public struct System
971 {
972 public RESULT release()
973 {
974 return FMOD5_System_Release(this.handle);
975 }
976
977 // Setup functions.
978 public RESULT setOutput(OUTPUTTYPE output)
979 {
980 return FMOD5_System_SetOutput(this.handle, output);
981 }
982 public RESULT getOutput(out OUTPUTTYPE output)
983 {
984 return FMOD5_System_GetOutput(this.handle, out output);
985 }
986 public RESULT getNumDrivers(out int numdrivers)
987 {
988 return FMOD5_System_GetNumDrivers(this.handle, out numdrivers);
989 }
990 public RESULT getDriverInfo(int id, out string name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels)
991 {
992 IntPtr stringMem = Marshal.AllocHGlobal(namelen);
993
994 RESULT result = FMOD5_System_GetDriverInfo(this.handle, id, stringMem, namelen, out guid, out systemrate, out speakermode, out speakermodechannels);
995 using (StringHelper.ThreadSafeEncoding encoding = StringHelper.GetFreeHelper())
996 {
997 name = encoding.stringFromNative(stringMem);
998 }
999 Marshal.FreeHGlobal(stringMem);
1000
1001 return result;
1002 }
1003 public RESULT getDriverInfo(int id, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels)
1004 {
1005 return FMOD5_System_GetDriverInfo(this.handle, id, IntPtr.Zero, 0, out guid, out systemrate, out speakermode, out speakermodechannels);
1006 }
1007 public RESULT setDriver(int driver)
1008 {
1009 return FMOD5_System_SetDriver(this.handle, driver);
1010 }
1011 public RESULT getDriver(out int driver)
1012 {
1013 return FMOD5_System_GetDriver(this.handle, out driver);
1014 }
1015 public RESULT setSoftwareChannels(int numsoftwarechannels)
1016 {
1017 return FMOD5_System_SetSoftwareChannels(this.handle, numsoftwarechannels);
1018 }
1019 public RESULT getSoftwareChannels(out int numsoftwarechannels)
1020 {
1021 return FMOD5_System_GetSoftwareChannels(this.handle, out numsoftwarechannels);
1022 }
1023 public RESULT setSoftwareFormat(int samplerate, SPEAKERMODE speakermode, int numrawspeakers)
1024 {
1025 return FMOD5_System_SetSoftwareFormat(this.handle, samplerate, speakermode, numrawspeakers);
1026 }
1027 public RESULT getSoftwareFormat(out int samplerate, out SPEAKERMODE speakermode, out int numrawspeakers)
1028 {
1029 return FMOD5_System_GetSoftwareFormat(this.handle, out samplerate, out speakermode, out numrawspeakers);
1030 }
1031 public RESULT setDSPBufferSize(uint bufferlength, int numbuffers)
1032 {
1033 return FMOD5_System_SetDSPBufferSize(this.handle, bufferlength, numbuffers);
1034 }
1035 public RESULT getDSPBufferSize(out uint bufferlength, out int numbuffers)
1036 {
1037 return FMOD5_System_GetDSPBufferSize(this.handle, out bufferlength, out numbuffers);
1038 }
1039 public RESULT setFileSystem(FILE_OPEN_CALLBACK useropen, FILE_CLOSE_CALLBACK userclose, FILE_READ_CALLBACK userread, FILE_SEEK_CALLBACK userseek, FILE_ASYNCREAD_CALLBACK userasyncread, FILE_ASYNCCANCEL_CALLBACK userasynccancel, int blockalign)
1040 {
1041 return FMOD5_System_SetFileSystem(this.handle, useropen, userclose, userread, userseek, userasyncread, userasynccancel, blockalign);
1042 }
1043 public RESULT attachFileSystem(FILE_OPEN_CALLBACK useropen, FILE_CLOSE_CALLBACK userclose, FILE_READ_CALLBACK userread, FILE_SEEK_CALLBACK userseek)
1044 {
1045 return FMOD5_System_AttachFileSystem(this.handle, useropen, userclose, userread, userseek);
1046 }
1047 public RESULT setAdvancedSettings(ref ADVANCEDSETTINGS settings)
1048 {
1049 settings.cbSize = MarshalHelper.SizeOf(typeof(ADVANCEDSETTINGS));
1050 return FMOD5_System_SetAdvancedSettings(this.handle, ref settings);
1051 }
1052 public RESULT getAdvancedSettings(ref ADVANCEDSETTINGS settings)
1053 {
1054 settings.cbSize = MarshalHelper.SizeOf(typeof(ADVANCEDSETTINGS));
1055 return FMOD5_System_GetAdvancedSettings(this.handle, ref settings);
1056 }
1057 public RESULT setCallback(SYSTEM_CALLBACK callback, SYSTEM_CALLBACK_TYPE callbackmask = SYSTEM_CALLBACK_TYPE.ALL)
1058 {
1059 return FMOD5_System_SetCallback(this.handle, callback, callbackmask);
1060 }
1061
1062 // Plug-in support.
1063 public RESULT setPluginPath(string path)
1064 {
1065 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
1066 {
1067 return FMOD5_System_SetPluginPath(this.handle, encoder.byteFromStringUTF8(path));
1068 }
1069 }
1070 public RESULT loadPlugin(string filename, out uint handle, uint priority = 0)
1071 {
1072 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
1073 {
1074 return FMOD5_System_LoadPlugin(this.handle, encoder.byteFromStringUTF8(filename), out handle, priority);
1075 }
1076 }
1077 public RESULT unloadPlugin(uint handle)
1078 {
1079 return FMOD5_System_UnloadPlugin(this.handle, handle);
1080 }
1081 public RESULT getNumNestedPlugins(uint handle, out int count)
1082 {
1083 return FMOD5_System_GetNumNestedPlugins(this.handle, handle, out count);
1084 }
1085 public RESULT getNestedPlugin(uint handle, int index, out uint nestedhandle)
1086 {
1087 return FMOD5_System_GetNestedPlugin(this.handle, handle, index, out nestedhandle);
1088 }
1089 public RESULT getNumPlugins(PLUGINTYPE plugintype, out int numplugins)
1090 {
1091 return FMOD5_System_GetNumPlugins(this.handle, plugintype, out numplugins);
1092 }
1093 public RESULT getPluginHandle(PLUGINTYPE plugintype, int index, out uint handle)
1094 {
1095 return FMOD5_System_GetPluginHandle(this.handle, plugintype, index, out handle);
1096 }
1097 public RESULT getPluginInfo(uint handle, out PLUGINTYPE plugintype, out string name, int namelen, out uint version)
1098 {
1099 IntPtr stringMem = Marshal.AllocHGlobal(namelen);
1100
1101 RESULT result = FMOD5_System_GetPluginInfo(this.handle, handle, out plugintype, stringMem, namelen, out version);
1102 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
1103 {
1104 name = encoder.stringFromNative(stringMem);
1105 }
1106 Marshal.FreeHGlobal(stringMem);
1107
1108 return result;
1109 }
1110 public RESULT getPluginInfo(uint handle, out PLUGINTYPE plugintype, out uint version)
1111 {
1112 return FMOD5_System_GetPluginInfo(this.handle, handle, out plugintype, IntPtr.Zero, 0, out version);
1113 }
1114 public RESULT setOutputByPlugin(uint handle)
1115 {
1116 return FMOD5_System_SetOutputByPlugin(this.handle, handle);
1117 }
1118 public RESULT getOutputByPlugin(out uint handle)
1119 {
1120 return FMOD5_System_GetOutputByPlugin(this.handle, out handle);
1121 }
1122 public RESULT createDSPByPlugin(uint handle, out DSP dsp)
1123 {
1124 return FMOD5_System_CreateDSPByPlugin(this.handle, handle, out dsp.handle);
1125 }
1126 public RESULT getDSPInfoByPlugin(uint handle, out IntPtr description)
1127 {
1128 return FMOD5_System_GetDSPInfoByPlugin(this.handle, handle, out description);
1129 }
1130 /*
1131 public RESULT registerCodec (ref CODEC_DESCRIPTION description, out uint handle, uint priority)
1132 public RESULT registerCodec (ref CODEC_DESCRIPTION description, out uint handle, uint priority = 0)
1133 public RESULT registerCodec(ref CODEC_DESCRIPTION description, out uint handle, uint priority)
1134 {
1135 return FMOD5_System_RegisterCodec(this.handle, ref description, out handle, priority);
1136 }
1137 */
1138 public RESULT registerDSP(ref DSP_DESCRIPTION description, out uint handle)
1139 {
1140 return FMOD5_System_RegisterDSP(this.handle, ref description, out handle);
1141 }
1142 /*
1143 public RESULT registerOutput(ref OUTPUT_DESCRIPTION description, out uint handle)
1144 {
1145 return FMOD5_System_RegisterOutput(this.handle, ref description, out handle);
1146 }
1147 */
1148
1149 // Init/Close.
1150 public RESULT init(int maxchannels, INITFLAGS flags, IntPtr extradriverdata)
1151 {
1152 return FMOD5_System_Init(this.handle, maxchannels, flags, extradriverdata);
1153 }
1154 public RESULT close()
1155 {
1156 return FMOD5_System_Close(this.handle);
1157 }
1158
1159 // General post-init system functions.
1160 public RESULT update()
1161 {
1162 return FMOD5_System_Update(this.handle);
1163 }
1164 public RESULT setSpeakerPosition(SPEAKER speaker, float x, float y, bool active)
1165 {
1166 return FMOD5_System_SetSpeakerPosition(this.handle, speaker, x, y, active);
1167 }
1168 public RESULT getSpeakerPosition(SPEAKER speaker, out float x, out float y, out bool active)
1169 {
1170 return FMOD5_System_GetSpeakerPosition(this.handle, speaker, out x, out y, out active);
1171 }
1172 public RESULT setStreamBufferSize(uint filebuffersize, TIMEUNIT filebuffersizetype)
1173 {
1174 return FMOD5_System_SetStreamBufferSize(this.handle, filebuffersize, filebuffersizetype);
1175 }
1176 public RESULT getStreamBufferSize(out uint filebuffersize, out TIMEUNIT filebuffersizetype)
1177 {
1178 return FMOD5_System_GetStreamBufferSize(this.handle, out filebuffersize, out filebuffersizetype);
1179 }
1180 public RESULT set3DSettings(float dopplerscale, float distancefactor, float rolloffscale)
1181 {
1182 return FMOD5_System_Set3DSettings(this.handle, dopplerscale, distancefactor, rolloffscale);
1183 }
1184 public RESULT get3DSettings(out float dopplerscale, out float distancefactor, out float rolloffscale)
1185 {
1186 return FMOD5_System_Get3DSettings(this.handle, out dopplerscale, out distancefactor, out rolloffscale);
1187 }
1188 public RESULT set3DNumListeners(int numlisteners)
1189 {
1190 return FMOD5_System_Set3DNumListeners(this.handle, numlisteners);
1191 }
1192 public RESULT get3DNumListeners(out int numlisteners)
1193 {
1194 return FMOD5_System_Get3DNumListeners(this.handle, out numlisteners);
1195 }
1196 public RESULT set3DListenerAttributes(int listener, ref VECTOR pos, ref VECTOR vel, ref VECTOR forward, ref VECTOR up)
1197 {
1198 return FMOD5_System_Set3DListenerAttributes(this.handle, listener, ref pos, ref vel, ref forward, ref up);
1199 }
1200 public RESULT get3DListenerAttributes(int listener, out VECTOR pos, out VECTOR vel, out VECTOR forward, out VECTOR up)
1201 {
1202 return FMOD5_System_Get3DListenerAttributes(this.handle, listener, out pos, out vel, out forward, out up);
1203 }
1204 public RESULT set3DRolloffCallback(CB_3D_ROLLOFF_CALLBACK callback)
1205 {
1206 return FMOD5_System_Set3DRolloffCallback(this.handle, callback);
1207 }
1208 public RESULT mixerSuspend()
1209 {
1210 return FMOD5_System_MixerSuspend(this.handle);
1211 }
1212 public RESULT mixerResume()
1213 {
1214 return FMOD5_System_MixerResume(this.handle);
1215 }
1216 public RESULT getDefaultMixMatrix(SPEAKERMODE sourcespeakermode, SPEAKERMODE targetspeakermode, float[] matrix, int matrixhop)
1217 {
1218 return FMOD5_System_GetDefaultMixMatrix(this.handle, sourcespeakermode, targetspeakermode, matrix, matrixhop);
1219 }
1220 public RESULT getSpeakerModeChannels(SPEAKERMODE mode, out int channels)
1221 {
1222 return FMOD5_System_GetSpeakerModeChannels(this.handle, mode, out channels);
1223 }
1224
1225 // System information functions.
1226 public RESULT getVersion(out uint version)
1227 {
1228 return FMOD5_System_GetVersion(this.handle, out version);
1229 }
1230 public RESULT getOutputHandle(out IntPtr handle)
1231 {
1232 return FMOD5_System_GetOutputHandle(this.handle, out handle);
1233 }
1234 public RESULT getChannelsPlaying(out int channels)
1235 {
1236 return FMOD5_System_GetChannelsPlaying(this.handle, out channels, IntPtr.Zero);
1237 }
1238 public RESULT getChannelsPlaying(out int channels, out int realchannels)
1239 {
1240 return FMOD5_System_GetChannelsPlaying(this.handle, out channels, out realchannels);
1241 }
1242 public RESULT getCPUUsage(out CPU_USAGE usage)
1243 {
1244 return FMOD5_System_GetCPUUsage(this.handle, out usage);
1245 }
1246 public RESULT getFileUsage(out Int64 sampleBytesRead, out Int64 streamBytesRead, out Int64 otherBytesRead)
1247 {
1248 return FMOD5_System_GetFileUsage(this.handle, out sampleBytesRead, out streamBytesRead, out otherBytesRead);
1249 }
1250
1251 // Sound/DSP/Channel/FX creation and retrieval.
1252 public RESULT createSound(string name, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound)
1253 {
1254 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
1255 {
1256 return FMOD5_System_CreateSound(this.handle, encoder.byteFromStringUTF8(name), mode, ref exinfo, out sound.handle);
1257 }
1258 }
1259 public RESULT createSound(byte[] data, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound)
1260 {
1261 return FMOD5_System_CreateSound(this.handle, data, mode, ref exinfo, out sound.handle);
1262 }
1263 public RESULT createSound(IntPtr name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound)
1264 {
1265 return FMOD5_System_CreateSound(this.handle, name_or_data, mode, ref exinfo, out sound.handle);
1266 }
1267 public RESULT createSound(string name, MODE mode, out Sound sound)
1268 {
1269 CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO();
1270 exinfo.cbsize = MarshalHelper.SizeOf(typeof(CREATESOUNDEXINFO));
1271
1272 return createSound(name, mode, ref exinfo, out sound);
1273 }
1274 public RESULT createStream(string name, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound)
1275 {
1276 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
1277 {
1278 return FMOD5_System_CreateStream(this.handle, encoder.byteFromStringUTF8(name), mode, ref exinfo, out sound.handle);
1279 }
1280 }
1281 public RESULT createStream(byte[] data, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound)
1282 {
1283 return FMOD5_System_CreateStream(this.handle, data, mode, ref exinfo, out sound.handle);
1284 }
1285 public RESULT createStream(IntPtr name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound)
1286 {
1287 return FMOD5_System_CreateStream(this.handle, name_or_data, mode, ref exinfo, out sound.handle);
1288 }
1289 public RESULT createStream(string name, MODE mode, out Sound sound)
1290 {
1291 CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO();
1292 exinfo.cbsize = MarshalHelper.SizeOf(typeof(CREATESOUNDEXINFO));
1293
1294 return createStream(name, mode, ref exinfo, out sound);
1295 }
1296 public RESULT createDSP(ref DSP_DESCRIPTION description, out DSP dsp)
1297 {
1298 return FMOD5_System_CreateDSP(this.handle, ref description, out dsp.handle);
1299 }
1300 public RESULT createDSPByType(DSP_TYPE type, out DSP dsp)
1301 {
1302 return FMOD5_System_CreateDSPByType(this.handle, type, out dsp.handle);
1303 }
1304 public RESULT createChannelGroup(string name, out ChannelGroup channelgroup)
1305 {
1306 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
1307 {
1308 return FMOD5_System_CreateChannelGroup(this.handle, encoder.byteFromStringUTF8(name), out channelgroup.handle);
1309 }
1310 }
1311 public RESULT createSoundGroup(string name, out SoundGroup soundgroup)
1312 {
1313 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
1314 {
1315 return FMOD5_System_CreateSoundGroup(this.handle, encoder.byteFromStringUTF8(name), out soundgroup.handle);
1316 }
1317 }
1318 public RESULT createReverb3D(out Reverb3D reverb)
1319 {
1320 return FMOD5_System_CreateReverb3D(this.handle, out reverb.handle);
1321 }
1322 public RESULT playSound(Sound sound, ChannelGroup channelgroup, bool paused, out Channel channel)
1323 {
1324 return FMOD5_System_PlaySound(this.handle, sound.handle, channelgroup.handle, paused, out channel.handle);
1325 }
1326 public RESULT playDSP(DSP dsp, ChannelGroup channelgroup, bool paused, out Channel channel)
1327 {
1328 return FMOD5_System_PlayDSP(this.handle, dsp.handle, channelgroup.handle, paused, out channel.handle);
1329 }
1330 public RESULT getChannel(int channelid, out Channel channel)
1331 {
1332 return FMOD5_System_GetChannel(this.handle, channelid, out channel.handle);
1333 }
1334 public RESULT getDSPInfoByType(DSP_TYPE type, out IntPtr description)
1335 {
1336 return FMOD5_System_GetDSPInfoByType(this.handle, type, out description);
1337 }
1338 public RESULT getMasterChannelGroup(out ChannelGroup channelgroup)
1339 {
1340 return FMOD5_System_GetMasterChannelGroup(this.handle, out channelgroup.handle);
1341 }
1342 public RESULT getMasterSoundGroup(out SoundGroup soundgroup)
1343 {
1344 return FMOD5_System_GetMasterSoundGroup(this.handle, out soundgroup.handle);
1345 }
1346
1347 // Routing to ports.
1348 public RESULT attachChannelGroupToPort(PORT_TYPE portType, ulong portIndex, ChannelGroup channelgroup, bool passThru = false)
1349 {
1350 return FMOD5_System_AttachChannelGroupToPort(this.handle, portType, portIndex, channelgroup.handle, passThru);
1351 }
1352 public RESULT detachChannelGroupFromPort(ChannelGroup channelgroup)
1353 {
1354 return FMOD5_System_DetachChannelGroupFromPort(this.handle, channelgroup.handle);
1355 }
1356
1357 // Reverb api.
1358 public RESULT setReverbProperties(int instance, ref REVERB_PROPERTIES prop)
1359 {
1360 return FMOD5_System_SetReverbProperties(this.handle, instance, ref prop);
1361 }
1362 public RESULT getReverbProperties(int instance, out REVERB_PROPERTIES prop)
1363 {
1364 return FMOD5_System_GetReverbProperties(this.handle, instance, out prop);
1365 }
1366
1367 // System level DSP functionality.
1368 public RESULT lockDSP()
1369 {
1370 return FMOD5_System_LockDSP(this.handle);
1371 }
1372 public RESULT unlockDSP()
1373 {
1374 return FMOD5_System_UnlockDSP(this.handle);
1375 }
1376
1377 // Recording api
1378 public RESULT getRecordNumDrivers(out int numdrivers, out int numconnected)
1379 {
1380 return FMOD5_System_GetRecordNumDrivers(this.handle, out numdrivers, out numconnected);
1381 }
1382 public RESULT getRecordDriverInfo(int id, out string name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state)
1383 {
1384 IntPtr stringMem = Marshal.AllocHGlobal(namelen);
1385
1386 RESULT result = FMOD5_System_GetRecordDriverInfo(this.handle, id, stringMem, namelen, out guid, out systemrate, out speakermode, out speakermodechannels, out state);
1387
1388 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
1389 {
1390 name = encoder.stringFromNative(stringMem);
1391 }
1392 Marshal.FreeHGlobal(stringMem);
1393
1394 return result;
1395 }
1396 public RESULT getRecordDriverInfo(int id, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state)
1397 {
1398 return FMOD5_System_GetRecordDriverInfo(this.handle, id, IntPtr.Zero, 0, out guid, out systemrate, out speakermode, out speakermodechannels, out state);
1399 }
1400 public RESULT getRecordPosition(int id, out uint position)
1401 {
1402 return FMOD5_System_GetRecordPosition(this.handle, id, out position);
1403 }
1404 public RESULT recordStart(int id, Sound sound, bool loop)
1405 {
1406 return FMOD5_System_RecordStart(this.handle, id, sound.handle, loop);
1407 }
1408 public RESULT recordStop(int id)
1409 {
1410 return FMOD5_System_RecordStop(this.handle, id);
1411 }
1412 public RESULT isRecording(int id, out bool recording)
1413 {
1414 return FMOD5_System_IsRecording(this.handle, id, out recording);
1415 }
1416
1417 // Geometry api
1418 public RESULT createGeometry(int maxpolygons, int maxvertices, out Geometry geometry)
1419 {
1420 return FMOD5_System_CreateGeometry(this.handle, maxpolygons, maxvertices, out geometry.handle);
1421 }
1422 public RESULT setGeometrySettings(float maxworldsize)
1423 {
1424 return FMOD5_System_SetGeometrySettings(this.handle, maxworldsize);
1425 }
1426 public RESULT getGeometrySettings(out float maxworldsize)
1427 {
1428 return FMOD5_System_GetGeometrySettings(this.handle, out maxworldsize);
1429 }
1430 public RESULT loadGeometry(IntPtr data, int datasize, out Geometry geometry)
1431 {
1432 return FMOD5_System_LoadGeometry(this.handle, data, datasize, out geometry.handle);
1433 }
1434 public RESULT getGeometryOcclusion(ref VECTOR listener, ref VECTOR source, out float direct, out float reverb)
1435 {
1436 return FMOD5_System_GetGeometryOcclusion(this.handle, ref listener, ref source, out direct, out reverb);
1437 }
1438
1439 // Network functions
1440 public RESULT setNetworkProxy(string proxy)
1441 {
1442 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
1443 {
1444 return FMOD5_System_SetNetworkProxy(this.handle, encoder.byteFromStringUTF8(proxy));
1445 }
1446 }
1447 public RESULT getNetworkProxy(out string proxy, int proxylen)
1448 {
1449 IntPtr stringMem = Marshal.AllocHGlobal(proxylen);
1450
1451 RESULT result = FMOD5_System_GetNetworkProxy(this.handle, stringMem, proxylen);
1452 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
1453 {
1454 proxy = encoder.stringFromNative(stringMem);
1455 }
1456 Marshal.FreeHGlobal(stringMem);
1457
1458 return result;
1459 }
1460 public RESULT setNetworkTimeout(int timeout)
1461 {
1462 return FMOD5_System_SetNetworkTimeout(this.handle, timeout);
1463 }
1464 public RESULT getNetworkTimeout(out int timeout)
1465 {
1466 return FMOD5_System_GetNetworkTimeout(this.handle, out timeout);
1467 }
1468
1469 // Userdata set/get
1470 public RESULT setUserData(IntPtr userdata)
1471 {
1472 return FMOD5_System_SetUserData(this.handle, userdata);
1473 }
1474 public RESULT getUserData(out IntPtr userdata)
1475 {
1476 return FMOD5_System_GetUserData(this.handle, out userdata);
1477 }
1478
1479 #region importfunctions
1480 [DllImport(VERSION.dll)]
1481 private static extern RESULT FMOD5_System_Release (IntPtr system);
1482 [DllImport(VERSION.dll)]
1483 private static extern RESULT FMOD5_System_SetOutput (IntPtr system, OUTPUTTYPE output);
1484 [DllImport(VERSION.dll)]
1485 private static extern RESULT FMOD5_System_GetOutput (IntPtr system, out OUTPUTTYPE output);
1486 [DllImport(VERSION.dll)]
1487 private static extern RESULT FMOD5_System_GetNumDrivers (IntPtr system, out int numdrivers);
1488 [DllImport(VERSION.dll)]
1489 private static extern RESULT FMOD5_System_GetDriverInfo (IntPtr system, int id, IntPtr name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels);
1490 [DllImport(VERSION.dll)]
1491 private static extern RESULT FMOD5_System_SetDriver (IntPtr system, int driver);
1492 [DllImport(VERSION.dll)]
1493 private static extern RESULT FMOD5_System_GetDriver (IntPtr system, out int driver);
1494 [DllImport(VERSION.dll)]
1495 private static extern RESULT FMOD5_System_SetSoftwareChannels (IntPtr system, int numsoftwarechannels);
1496 [DllImport(VERSION.dll)]
1497 private static extern RESULT FMOD5_System_GetSoftwareChannels (IntPtr system, out int numsoftwarechannels);
1498 [DllImport(VERSION.dll)]
1499 private static extern RESULT FMOD5_System_SetSoftwareFormat (IntPtr system, int samplerate, SPEAKERMODE speakermode, int numrawspeakers);
1500 [DllImport(VERSION.dll)]
1501 private static extern RESULT FMOD5_System_GetSoftwareFormat (IntPtr system, out int samplerate, out SPEAKERMODE speakermode, out int numrawspeakers);
1502 [DllImport(VERSION.dll)]
1503 private static extern RESULT FMOD5_System_SetDSPBufferSize (IntPtr system, uint bufferlength, int numbuffers);
1504 [DllImport(VERSION.dll)]
1505 private static extern RESULT FMOD5_System_GetDSPBufferSize (IntPtr system, out uint bufferlength, out int numbuffers);
1506 [DllImport(VERSION.dll)]
1507 private static extern RESULT FMOD5_System_SetFileSystem (IntPtr system, FILE_OPEN_CALLBACK useropen, FILE_CLOSE_CALLBACK userclose, FILE_READ_CALLBACK userread, FILE_SEEK_CALLBACK userseek, FILE_ASYNCREAD_CALLBACK userasyncread, FILE_ASYNCCANCEL_CALLBACK userasynccancel, int blockalign);
1508 [DllImport(VERSION.dll)]
1509 private static extern RESULT FMOD5_System_AttachFileSystem (IntPtr system, FILE_OPEN_CALLBACK useropen, FILE_CLOSE_CALLBACK userclose, FILE_READ_CALLBACK userread, FILE_SEEK_CALLBACK userseek);
1510 [DllImport(VERSION.dll)]
1511 private static extern RESULT FMOD5_System_SetAdvancedSettings (IntPtr system, ref ADVANCEDSETTINGS settings);
1512 [DllImport(VERSION.dll)]
1513 private static extern RESULT FMOD5_System_GetAdvancedSettings (IntPtr system, ref ADVANCEDSETTINGS settings);
1514 [DllImport(VERSION.dll)]
1515 private static extern RESULT FMOD5_System_SetCallback (IntPtr system, SYSTEM_CALLBACK callback, SYSTEM_CALLBACK_TYPE callbackmask);
1516 [DllImport(VERSION.dll)]
1517 private static extern RESULT FMOD5_System_SetPluginPath (IntPtr system, byte[] path);
1518 [DllImport(VERSION.dll)]
1519 private static extern RESULT FMOD5_System_LoadPlugin (IntPtr system, byte[] filename, out uint handle, uint priority);
1520 [DllImport(VERSION.dll)]
1521 private static extern RESULT FMOD5_System_UnloadPlugin (IntPtr system, uint handle);
1522 [DllImport(VERSION.dll)]
1523 private static extern RESULT FMOD5_System_GetNumNestedPlugins (IntPtr system, uint handle, out int count);
1524 [DllImport(VERSION.dll)]
1525 private static extern RESULT FMOD5_System_GetNestedPlugin (IntPtr system, uint handle, int index, out uint nestedhandle);
1526 [DllImport(VERSION.dll)]
1527 private static extern RESULT FMOD5_System_GetNumPlugins (IntPtr system, PLUGINTYPE plugintype, out int numplugins);
1528 [DllImport(VERSION.dll)]
1529 private static extern RESULT FMOD5_System_GetPluginHandle (IntPtr system, PLUGINTYPE plugintype, int index, out uint handle);
1530 [DllImport(VERSION.dll)]
1531 private static extern RESULT FMOD5_System_GetPluginInfo (IntPtr system, uint handle, out PLUGINTYPE plugintype, IntPtr name, int namelen, out uint version);
1532 [DllImport(VERSION.dll)]
1533 private static extern RESULT FMOD5_System_SetOutputByPlugin (IntPtr system, uint handle);
1534 [DllImport(VERSION.dll)]
1535 private static extern RESULT FMOD5_System_GetOutputByPlugin (IntPtr system, out uint handle);
1536 [DllImport(VERSION.dll)]
1537 private static extern RESULT FMOD5_System_CreateDSPByPlugin (IntPtr system, uint handle, out IntPtr dsp);
1538 [DllImport(VERSION.dll)]
1539 private static extern RESULT FMOD5_System_GetDSPInfoByPlugin (IntPtr system, uint handle, out IntPtr description);
1540 //[DllImport(VERSION.dll)]
1541 //private static extern RESULT FMOD5_System_RegisterCodec (IntPtr system, out CODEC_DESCRIPTION description, out uint handle, uint priority);
1542 [DllImport(VERSION.dll)]
1543 private static extern RESULT FMOD5_System_RegisterDSP (IntPtr system, ref DSP_DESCRIPTION description, out uint handle);
1544 //[DllImport(VERSION.dll)]
1545 //private static extern RESULT FMOD5_System_RegisterOutput (IntPtr system, ref OUTPUT_DESCRIPTION description, out uint handle);
1546 [DllImport(VERSION.dll)]
1547 private static extern RESULT FMOD5_System_Init (IntPtr system, int maxchannels, INITFLAGS flags, IntPtr extradriverdata);
1548 [DllImport(VERSION.dll)]
1549 private static extern RESULT FMOD5_System_Close (IntPtr system);
1550 [DllImport(VERSION.dll)]
1551 private static extern RESULT FMOD5_System_Update (IntPtr system);
1552 [DllImport(VERSION.dll)]
1553 private static extern RESULT FMOD5_System_SetSpeakerPosition (IntPtr system, SPEAKER speaker, float x, float y, bool active);
1554 [DllImport(VERSION.dll)]
1555 private static extern RESULT FMOD5_System_GetSpeakerPosition (IntPtr system, SPEAKER speaker, out float x, out float y, out bool active);
1556 [DllImport(VERSION.dll)]
1557 private static extern RESULT FMOD5_System_SetStreamBufferSize (IntPtr system, uint filebuffersize, TIMEUNIT filebuffersizetype);
1558 [DllImport(VERSION.dll)]
1559 private static extern RESULT FMOD5_System_GetStreamBufferSize (IntPtr system, out uint filebuffersize, out TIMEUNIT filebuffersizetype);
1560 [DllImport(VERSION.dll)]
1561 private static extern RESULT FMOD5_System_Set3DSettings (IntPtr system, float dopplerscale, float distancefactor, float rolloffscale);
1562 [DllImport(VERSION.dll)]
1563 private static extern RESULT FMOD5_System_Get3DSettings (IntPtr system, out float dopplerscale, out float distancefactor, out float rolloffscale);
1564 [DllImport(VERSION.dll)]
1565 private static extern RESULT FMOD5_System_Set3DNumListeners (IntPtr system, int numlisteners);
1566 [DllImport(VERSION.dll)]
1567 private static extern RESULT FMOD5_System_Get3DNumListeners (IntPtr system, out int numlisteners);
1568 [DllImport(VERSION.dll)]
1569 private static extern RESULT FMOD5_System_Set3DListenerAttributes (IntPtr system, int listener, ref VECTOR pos, ref VECTOR vel, ref VECTOR forward, ref VECTOR up);
1570 [DllImport(VERSION.dll)]
1571 private static extern RESULT FMOD5_System_Get3DListenerAttributes (IntPtr system, int listener, out VECTOR pos, out VECTOR vel, out VECTOR forward, out VECTOR up);
1572 [DllImport(VERSION.dll)]
1573 private static extern RESULT FMOD5_System_Set3DRolloffCallback (IntPtr system, CB_3D_ROLLOFF_CALLBACK callback);
1574 [DllImport(VERSION.dll)]
1575 private static extern RESULT FMOD5_System_MixerSuspend (IntPtr system);
1576 [DllImport(VERSION.dll)]
1577 private static extern RESULT FMOD5_System_MixerResume (IntPtr system);
1578 [DllImport(VERSION.dll)]
1579 private static extern RESULT FMOD5_System_GetDefaultMixMatrix (IntPtr system, SPEAKERMODE sourcespeakermode, SPEAKERMODE targetspeakermode, float[] matrix, int matrixhop);
1580 [DllImport(VERSION.dll)]
1581 private static extern RESULT FMOD5_System_GetSpeakerModeChannels (IntPtr system, SPEAKERMODE mode, out int channels);
1582 [DllImport(VERSION.dll)]
1583 private static extern RESULT FMOD5_System_GetVersion (IntPtr system, out uint version);
1584 [DllImport(VERSION.dll)]
1585 private static extern RESULT FMOD5_System_GetOutputHandle (IntPtr system, out IntPtr handle);
1586 [DllImport(VERSION.dll)]
1587 private static extern RESULT FMOD5_System_GetChannelsPlaying (IntPtr system, out int channels, IntPtr zero);
1588 [DllImport(VERSION.dll)]
1589 private static extern RESULT FMOD5_System_GetChannelsPlaying (IntPtr system, out int channels, out int realchannels);
1590 [DllImport(VERSION.dll)]
1591 private static extern RESULT FMOD5_System_GetCPUUsage (IntPtr system, out CPU_USAGE usage);
1592 [DllImport(VERSION.dll)]
1593 private static extern RESULT FMOD5_System_GetFileUsage (IntPtr system, out Int64 sampleBytesRead, out Int64 streamBytesRead, out Int64 otherBytesRead);
1594 [DllImport(VERSION.dll)]
1595 private static extern RESULT FMOD5_System_CreateSound (IntPtr system, byte[] name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound);
1596 [DllImport(VERSION.dll)]
1597 private static extern RESULT FMOD5_System_CreateSound (IntPtr system, IntPtr name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound);
1598 [DllImport(VERSION.dll)]
1599 private static extern RESULT FMOD5_System_CreateStream (IntPtr system, byte[] name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound);
1600 [DllImport(VERSION.dll)]
1601 private static extern RESULT FMOD5_System_CreateStream (IntPtr system, IntPtr name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound);
1602 [DllImport(VERSION.dll)]
1603 private static extern RESULT FMOD5_System_CreateDSP (IntPtr system, ref DSP_DESCRIPTION description, out IntPtr dsp);
1604 [DllImport(VERSION.dll)]
1605 private static extern RESULT FMOD5_System_CreateDSPByType (IntPtr system, DSP_TYPE type, out IntPtr dsp);
1606 [DllImport(VERSION.dll)]
1607 private static extern RESULT FMOD5_System_CreateChannelGroup (IntPtr system, byte[] name, out IntPtr channelgroup);
1608 [DllImport(VERSION.dll)]
1609 private static extern RESULT FMOD5_System_CreateSoundGroup (IntPtr system, byte[] name, out IntPtr soundgroup);
1610 [DllImport(VERSION.dll)]
1611 private static extern RESULT FMOD5_System_CreateReverb3D (IntPtr system, out IntPtr reverb);
1612 [DllImport(VERSION.dll)]
1613 private static extern RESULT FMOD5_System_PlaySound (IntPtr system, IntPtr sound, IntPtr channelgroup, bool paused, out IntPtr channel);
1614 [DllImport(VERSION.dll)]
1615 private static extern RESULT FMOD5_System_PlayDSP (IntPtr system, IntPtr dsp, IntPtr channelgroup, bool paused, out IntPtr channel);
1616 [DllImport(VERSION.dll)]
1617 private static extern RESULT FMOD5_System_GetChannel (IntPtr system, int channelid, out IntPtr channel);
1618 [DllImport(VERSION.dll)]
1619 private static extern RESULT FMOD5_System_GetDSPInfoByType (IntPtr system, DSP_TYPE type, out IntPtr description);
1620 [DllImport(VERSION.dll)]
1621 private static extern RESULT FMOD5_System_GetMasterChannelGroup (IntPtr system, out IntPtr channelgroup);
1622 [DllImport(VERSION.dll)]
1623 private static extern RESULT FMOD5_System_GetMasterSoundGroup (IntPtr system, out IntPtr soundgroup);
1624 [DllImport(VERSION.dll)]
1625 private static extern RESULT FMOD5_System_AttachChannelGroupToPort (IntPtr system, PORT_TYPE portType, ulong portIndex, IntPtr channelgroup, bool passThru);
1626 [DllImport(VERSION.dll)]
1627 private static extern RESULT FMOD5_System_DetachChannelGroupFromPort(IntPtr system, IntPtr channelgroup);
1628 [DllImport(VERSION.dll)]
1629 private static extern RESULT FMOD5_System_SetReverbProperties (IntPtr system, int instance, ref REVERB_PROPERTIES prop);
1630 [DllImport(VERSION.dll)]
1631 private static extern RESULT FMOD5_System_GetReverbProperties (IntPtr system, int instance, out REVERB_PROPERTIES prop);
1632 [DllImport(VERSION.dll)]
1633 private static extern RESULT FMOD5_System_LockDSP (IntPtr system);
1634 [DllImport(VERSION.dll)]
1635 private static extern RESULT FMOD5_System_UnlockDSP (IntPtr system);
1636 [DllImport(VERSION.dll)]
1637 private static extern RESULT FMOD5_System_GetRecordNumDrivers (IntPtr system, out int numdrivers, out int numconnected);
1638 [DllImport(VERSION.dll)]
1639 private static extern RESULT FMOD5_System_GetRecordDriverInfo (IntPtr system, int id, IntPtr name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state);
1640 [DllImport(VERSION.dll)]
1641 private static extern RESULT FMOD5_System_GetRecordPosition (IntPtr system, int id, out uint position);
1642 [DllImport(VERSION.dll)]
1643 private static extern RESULT FMOD5_System_RecordStart (IntPtr system, int id, IntPtr sound, bool loop);
1644 [DllImport(VERSION.dll)]
1645 private static extern RESULT FMOD5_System_RecordStop (IntPtr system, int id);
1646 [DllImport(VERSION.dll)]
1647 private static extern RESULT FMOD5_System_IsRecording (IntPtr system, int id, out bool recording);
1648 [DllImport(VERSION.dll)]
1649 private static extern RESULT FMOD5_System_CreateGeometry (IntPtr system, int maxpolygons, int maxvertices, out IntPtr geometry);
1650 [DllImport(VERSION.dll)]
1651 private static extern RESULT FMOD5_System_SetGeometrySettings (IntPtr system, float maxworldsize);
1652 [DllImport(VERSION.dll)]
1653 private static extern RESULT FMOD5_System_GetGeometrySettings (IntPtr system, out float maxworldsize);
1654 [DllImport(VERSION.dll)]
1655 private static extern RESULT FMOD5_System_LoadGeometry (IntPtr system, IntPtr data, int datasize, out IntPtr geometry);
1656 [DllImport(VERSION.dll)]
1657 private static extern RESULT FMOD5_System_GetGeometryOcclusion (IntPtr system, ref VECTOR listener, ref VECTOR source, out float direct, out float reverb);
1658 [DllImport(VERSION.dll)]
1659 private static extern RESULT FMOD5_System_SetNetworkProxy (IntPtr system, byte[] proxy);
1660 [DllImport(VERSION.dll)]
1661 private static extern RESULT FMOD5_System_GetNetworkProxy (IntPtr system, IntPtr proxy, int proxylen);
1662 [DllImport(VERSION.dll)]
1663 private static extern RESULT FMOD5_System_SetNetworkTimeout (IntPtr system, int timeout);
1664 [DllImport(VERSION.dll)]
1665 private static extern RESULT FMOD5_System_GetNetworkTimeout (IntPtr system, out int timeout);
1666 [DllImport(VERSION.dll)]
1667 private static extern RESULT FMOD5_System_SetUserData (IntPtr system, IntPtr userdata);
1668 [DllImport(VERSION.dll)]
1669 private static extern RESULT FMOD5_System_GetUserData (IntPtr system, out IntPtr userdata);
1670 #endregion
1671
1672 #region wrapperinternal
1673
1674 public IntPtr handle;
1675
1676 public System(IntPtr ptr) { this.handle = ptr; }
1677 public bool hasHandle() { return this.handle != IntPtr.Zero; }
1678 public void clearHandle() { this.handle = IntPtr.Zero; }
1679
1680 #endregion
1681 }
1682
1683
1684 /*
1685 'Sound' API.
1686 */
1687 public struct Sound
1688 {
1689 public RESULT release()
1690 {
1691 return FMOD5_Sound_Release(this.handle);
1692 }
1693 public RESULT getSystemObject(out System system)
1694 {
1695 return FMOD5_Sound_GetSystemObject(this.handle, out system.handle);
1696 }
1697
1698 // Standard sound manipulation functions.
1699 public RESULT @lock(uint offset, uint length, out IntPtr ptr1, out IntPtr ptr2, out uint len1, out uint len2)
1700 {
1701 return FMOD5_Sound_Lock(this.handle, offset, length, out ptr1, out ptr2, out len1, out len2);
1702 }
1703 public RESULT unlock(IntPtr ptr1, IntPtr ptr2, uint len1, uint len2)
1704 {
1705 return FMOD5_Sound_Unlock(this.handle, ptr1, ptr2, len1, len2);
1706 }
1707 public RESULT setDefaults(float frequency, int priority)
1708 {
1709 return FMOD5_Sound_SetDefaults(this.handle, frequency, priority);
1710 }
1711 public RESULT getDefaults(out float frequency, out int priority)
1712 {
1713 return FMOD5_Sound_GetDefaults(this.handle, out frequency, out priority);
1714 }
1715 public RESULT set3DMinMaxDistance(float min, float max)
1716 {
1717 return FMOD5_Sound_Set3DMinMaxDistance(this.handle, min, max);
1718 }
1719 public RESULT get3DMinMaxDistance(out float min, out float max)
1720 {
1721 return FMOD5_Sound_Get3DMinMaxDistance(this.handle, out min, out max);
1722 }
1723 public RESULT set3DConeSettings(float insideconeangle, float outsideconeangle, float outsidevolume)
1724 {
1725 return FMOD5_Sound_Set3DConeSettings(this.handle, insideconeangle, outsideconeangle, outsidevolume);
1726 }
1727 public RESULT get3DConeSettings(out float insideconeangle, out float outsideconeangle, out float outsidevolume)
1728 {
1729 return FMOD5_Sound_Get3DConeSettings(this.handle, out insideconeangle, out outsideconeangle, out outsidevolume);
1730 }
1731 public RESULT set3DCustomRolloff(ref VECTOR points, int numpoints)
1732 {
1733 return FMOD5_Sound_Set3DCustomRolloff(this.handle, ref points, numpoints);
1734 }
1735 public RESULT get3DCustomRolloff(out IntPtr points, out int numpoints)
1736 {
1737 return FMOD5_Sound_Get3DCustomRolloff(this.handle, out points, out numpoints);
1738 }
1739
1740 public RESULT getSubSound(int index, out Sound subsound)
1741 {
1742 return FMOD5_Sound_GetSubSound(this.handle, index, out subsound.handle);
1743 }
1744 public RESULT getSubSoundParent(out Sound parentsound)
1745 {
1746 return FMOD5_Sound_GetSubSoundParent(this.handle, out parentsound.handle);
1747 }
1748 public RESULT getName(out string name, int namelen)
1749 {
1750 IntPtr stringMem = Marshal.AllocHGlobal(namelen);
1751
1752 RESULT result = FMOD5_Sound_GetName(this.handle, stringMem, namelen);
1753 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
1754 {
1755 name = encoder.stringFromNative(stringMem);
1756 }
1757 Marshal.FreeHGlobal(stringMem);
1758
1759 return result;
1760 }
1761 public RESULT getLength(out uint length, TIMEUNIT lengthtype)
1762 {
1763 return FMOD5_Sound_GetLength(this.handle, out length, lengthtype);
1764 }
1765 public RESULT getFormat(out SOUND_TYPE type, out SOUND_FORMAT format, out int channels, out int bits)
1766 {
1767 return FMOD5_Sound_GetFormat(this.handle, out type, out format, out channels, out bits);
1768 }
1769 public RESULT getNumSubSounds(out int numsubsounds)
1770 {
1771 return FMOD5_Sound_GetNumSubSounds(this.handle, out numsubsounds);
1772 }
1773 public RESULT getNumTags(out int numtags, out int numtagsupdated)
1774 {
1775 return FMOD5_Sound_GetNumTags(this.handle, out numtags, out numtagsupdated);
1776 }
1777 public RESULT getTag(string name, int index, out TAG tag)
1778 {
1779 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
1780 {
1781 return FMOD5_Sound_GetTag(this.handle, encoder.byteFromStringUTF8(name), index, out tag);
1782 }
1783 }
1784 public RESULT getOpenState(out OPENSTATE openstate, out uint percentbuffered, out bool starving, out bool diskbusy)
1785 {
1786 return FMOD5_Sound_GetOpenState(this.handle, out openstate, out percentbuffered, out starving, out diskbusy);
1787 }
1788 public RESULT readData(IntPtr buffer, uint length, out uint read)
1789 {
1790 return FMOD5_Sound_ReadData(this.handle, buffer, length, out read);
1791 }
1792 public RESULT seekData(uint pcm)
1793 {
1794 return FMOD5_Sound_SeekData(this.handle, pcm);
1795 }
1796 public RESULT setSoundGroup(SoundGroup soundgroup)
1797 {
1798 return FMOD5_Sound_SetSoundGroup(this.handle, soundgroup.handle);
1799 }
1800 public RESULT getSoundGroup(out SoundGroup soundgroup)
1801 {
1802 return FMOD5_Sound_GetSoundGroup(this.handle, out soundgroup.handle);
1803 }
1804
1805 // Synchronization point API. These points can come from markers embedded in wav files, and can also generate channel callbacks.
1806 public RESULT getNumSyncPoints(out int numsyncpoints)
1807 {
1808 return FMOD5_Sound_GetNumSyncPoints(this.handle, out numsyncpoints);
1809 }
1810 public RESULT getSyncPoint(int index, out IntPtr point)
1811 {
1812 return FMOD5_Sound_GetSyncPoint(this.handle, index, out point);
1813 }
1814 public RESULT getSyncPointInfo(IntPtr point, out string name, int namelen, out uint offset, TIMEUNIT offsettype)
1815 {
1816 IntPtr stringMem = Marshal.AllocHGlobal(namelen);
1817
1818 RESULT result = FMOD5_Sound_GetSyncPointInfo(this.handle, point, stringMem, namelen, out offset, offsettype);
1819 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
1820 {
1821 name = encoder.stringFromNative(stringMem);
1822 }
1823 Marshal.FreeHGlobal(stringMem);
1824
1825 return result;
1826 }
1827 public RESULT getSyncPointInfo(IntPtr point, out uint offset, TIMEUNIT offsettype)
1828 {
1829 return FMOD5_Sound_GetSyncPointInfo(this.handle, point, IntPtr.Zero, 0, out offset, offsettype);
1830 }
1831 public RESULT addSyncPoint(uint offset, TIMEUNIT offsettype, string name, out IntPtr point)
1832 {
1833 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
1834 {
1835 return FMOD5_Sound_AddSyncPoint(this.handle, offset, offsettype, encoder.byteFromStringUTF8(name), out point);
1836 }
1837 }
1838 public RESULT deleteSyncPoint(IntPtr point)
1839 {
1840 return FMOD5_Sound_DeleteSyncPoint(this.handle, point);
1841 }
1842
1843 // Functions also in Channel class but here they are the 'default' to save having to change it in Channel all the time.
1844 public RESULT setMode(MODE mode)
1845 {
1846 return FMOD5_Sound_SetMode(this.handle, mode);
1847 }
1848 public RESULT getMode(out MODE mode)
1849 {
1850 return FMOD5_Sound_GetMode(this.handle, out mode);
1851 }
1852 public RESULT setLoopCount(int loopcount)
1853 {
1854 return FMOD5_Sound_SetLoopCount(this.handle, loopcount);
1855 }
1856 public RESULT getLoopCount(out int loopcount)
1857 {
1858 return FMOD5_Sound_GetLoopCount(this.handle, out loopcount);
1859 }
1860 public RESULT setLoopPoints(uint loopstart, TIMEUNIT loopstarttype, uint loopend, TIMEUNIT loopendtype)
1861 {
1862 return FMOD5_Sound_SetLoopPoints(this.handle, loopstart, loopstarttype, loopend, loopendtype);
1863 }
1864 public RESULT getLoopPoints(out uint loopstart, TIMEUNIT loopstarttype, out uint loopend, TIMEUNIT loopendtype)
1865 {
1866 return FMOD5_Sound_GetLoopPoints(this.handle, out loopstart, loopstarttype, out loopend, loopendtype);
1867 }
1868
1869 // For MOD/S3M/XM/IT/MID sequenced formats only.
1870 public RESULT getMusicNumChannels(out int numchannels)
1871 {
1872 return FMOD5_Sound_GetMusicNumChannels(this.handle, out numchannels);
1873 }
1874 public RESULT setMusicChannelVolume(int channel, float volume)
1875 {
1876 return FMOD5_Sound_SetMusicChannelVolume(this.handle, channel, volume);
1877 }
1878 public RESULT getMusicChannelVolume(int channel, out float volume)
1879 {
1880 return FMOD5_Sound_GetMusicChannelVolume(this.handle, channel, out volume);
1881 }
1882 public RESULT setMusicSpeed(float speed)
1883 {
1884 return FMOD5_Sound_SetMusicSpeed(this.handle, speed);
1885 }
1886 public RESULT getMusicSpeed(out float speed)
1887 {
1888 return FMOD5_Sound_GetMusicSpeed(this.handle, out speed);
1889 }
1890
1891 // Userdata set/get.
1892 public RESULT setUserData(IntPtr userdata)
1893 {
1894 return FMOD5_Sound_SetUserData(this.handle, userdata);
1895 }
1896 public RESULT getUserData(out IntPtr userdata)
1897 {
1898 return FMOD5_Sound_GetUserData(this.handle, out userdata);
1899 }
1900
1901 #region importfunctions
1902 [DllImport(VERSION.dll)]
1903 private static extern RESULT FMOD5_Sound_Release (IntPtr sound);
1904 [DllImport(VERSION.dll)]
1905 private static extern RESULT FMOD5_Sound_GetSystemObject (IntPtr sound, out IntPtr system);
1906 [DllImport(VERSION.dll)]
1907 private static extern RESULT FMOD5_Sound_Lock (IntPtr sound, uint offset, uint length, out IntPtr ptr1, out IntPtr ptr2, out uint len1, out uint len2);
1908 [DllImport(VERSION.dll)]
1909 private static extern RESULT FMOD5_Sound_Unlock (IntPtr sound, IntPtr ptr1, IntPtr ptr2, uint len1, uint len2);
1910 [DllImport(VERSION.dll)]
1911 private static extern RESULT FMOD5_Sound_SetDefaults (IntPtr sound, float frequency, int priority);
1912 [DllImport(VERSION.dll)]
1913 private static extern RESULT FMOD5_Sound_GetDefaults (IntPtr sound, out float frequency, out int priority);
1914 [DllImport(VERSION.dll)]
1915 private static extern RESULT FMOD5_Sound_Set3DMinMaxDistance (IntPtr sound, float min, float max);
1916 [DllImport(VERSION.dll)]
1917 private static extern RESULT FMOD5_Sound_Get3DMinMaxDistance (IntPtr sound, out float min, out float max);
1918 [DllImport(VERSION.dll)]
1919 private static extern RESULT FMOD5_Sound_Set3DConeSettings (IntPtr sound, float insideconeangle, float outsideconeangle, float outsidevolume);
1920 [DllImport(VERSION.dll)]
1921 private static extern RESULT FMOD5_Sound_Get3DConeSettings (IntPtr sound, out float insideconeangle, out float outsideconeangle, out float outsidevolume);
1922 [DllImport(VERSION.dll)]
1923 private static extern RESULT FMOD5_Sound_Set3DCustomRolloff (IntPtr sound, ref VECTOR points, int numpoints);
1924 [DllImport(VERSION.dll)]
1925 private static extern RESULT FMOD5_Sound_Get3DCustomRolloff (IntPtr sound, out IntPtr points, out int numpoints);
1926 [DllImport(VERSION.dll)]
1927 private static extern RESULT FMOD5_Sound_GetSubSound (IntPtr sound, int index, out IntPtr subsound);
1928 [DllImport(VERSION.dll)]
1929 private static extern RESULT FMOD5_Sound_GetSubSoundParent (IntPtr sound, out IntPtr parentsound);
1930 [DllImport(VERSION.dll)]
1931 private static extern RESULT FMOD5_Sound_GetName (IntPtr sound, IntPtr name, int namelen);
1932 [DllImport(VERSION.dll)]
1933 private static extern RESULT FMOD5_Sound_GetLength (IntPtr sound, out uint length, TIMEUNIT lengthtype);
1934 [DllImport(VERSION.dll)]
1935 private static extern RESULT FMOD5_Sound_GetFormat (IntPtr sound, out SOUND_TYPE type, out SOUND_FORMAT format, out int channels, out int bits);
1936 [DllImport(VERSION.dll)]
1937 private static extern RESULT FMOD5_Sound_GetNumSubSounds (IntPtr sound, out int numsubsounds);
1938 [DllImport(VERSION.dll)]
1939 private static extern RESULT FMOD5_Sound_GetNumTags (IntPtr sound, out int numtags, out int numtagsupdated);
1940 [DllImport(VERSION.dll)]
1941 private static extern RESULT FMOD5_Sound_GetTag (IntPtr sound, byte[] name, int index, out TAG tag);
1942 [DllImport(VERSION.dll)]
1943 private static extern RESULT FMOD5_Sound_GetOpenState (IntPtr sound, out OPENSTATE openstate, out uint percentbuffered, out bool starving, out bool diskbusy);
1944 [DllImport(VERSION.dll)]
1945 private static extern RESULT FMOD5_Sound_ReadData (IntPtr sound, IntPtr buffer, uint length, out uint read);
1946 [DllImport(VERSION.dll)]
1947 private static extern RESULT FMOD5_Sound_SeekData (IntPtr sound, uint pcm);
1948 [DllImport(VERSION.dll)]
1949 private static extern RESULT FMOD5_Sound_SetSoundGroup (IntPtr sound, IntPtr soundgroup);
1950 [DllImport(VERSION.dll)]
1951 private static extern RESULT FMOD5_Sound_GetSoundGroup (IntPtr sound, out IntPtr soundgroup);
1952 [DllImport(VERSION.dll)]
1953 private static extern RESULT FMOD5_Sound_GetNumSyncPoints (IntPtr sound, out int numsyncpoints);
1954 [DllImport(VERSION.dll)]
1955 private static extern RESULT FMOD5_Sound_GetSyncPoint (IntPtr sound, int index, out IntPtr point);
1956 [DllImport(VERSION.dll)]
1957 private static extern RESULT FMOD5_Sound_GetSyncPointInfo (IntPtr sound, IntPtr point, IntPtr name, int namelen, out uint offset, TIMEUNIT offsettype);
1958 [DllImport(VERSION.dll)]
1959 private static extern RESULT FMOD5_Sound_AddSyncPoint (IntPtr sound, uint offset, TIMEUNIT offsettype, byte[] name, out IntPtr point);
1960 [DllImport(VERSION.dll)]
1961 private static extern RESULT FMOD5_Sound_DeleteSyncPoint (IntPtr sound, IntPtr point);
1962 [DllImport(VERSION.dll)]
1963 private static extern RESULT FMOD5_Sound_SetMode (IntPtr sound, MODE mode);
1964 [DllImport(VERSION.dll)]
1965 private static extern RESULT FMOD5_Sound_GetMode (IntPtr sound, out MODE mode);
1966 [DllImport(VERSION.dll)]
1967 private static extern RESULT FMOD5_Sound_SetLoopCount (IntPtr sound, int loopcount);
1968 [DllImport(VERSION.dll)]
1969 private static extern RESULT FMOD5_Sound_GetLoopCount (IntPtr sound, out int loopcount);
1970 [DllImport(VERSION.dll)]
1971 private static extern RESULT FMOD5_Sound_SetLoopPoints (IntPtr sound, uint loopstart, TIMEUNIT loopstarttype, uint loopend, TIMEUNIT loopendtype);
1972 [DllImport(VERSION.dll)]
1973 private static extern RESULT FMOD5_Sound_GetLoopPoints (IntPtr sound, out uint loopstart, TIMEUNIT loopstarttype, out uint loopend, TIMEUNIT loopendtype);
1974 [DllImport(VERSION.dll)]
1975 private static extern RESULT FMOD5_Sound_GetMusicNumChannels (IntPtr sound, out int numchannels);
1976 [DllImport(VERSION.dll)]
1977 private static extern RESULT FMOD5_Sound_SetMusicChannelVolume (IntPtr sound, int channel, float volume);
1978 [DllImport(VERSION.dll)]
1979 private static extern RESULT FMOD5_Sound_GetMusicChannelVolume (IntPtr sound, int channel, out float volume);
1980 [DllImport(VERSION.dll)]
1981 private static extern RESULT FMOD5_Sound_SetMusicSpeed (IntPtr sound, float speed);
1982 [DllImport(VERSION.dll)]
1983 private static extern RESULT FMOD5_Sound_GetMusicSpeed (IntPtr sound, out float speed);
1984 [DllImport(VERSION.dll)]
1985 private static extern RESULT FMOD5_Sound_SetUserData (IntPtr sound, IntPtr userdata);
1986 [DllImport(VERSION.dll)]
1987 private static extern RESULT FMOD5_Sound_GetUserData (IntPtr sound, out IntPtr userdata);
1988 #endregion
1989
1990 #region wrapperinternal
1991
1992 public IntPtr handle;
1993
1994 public Sound(IntPtr ptr) { this.handle = ptr; }
1995 public bool hasHandle() { return this.handle != IntPtr.Zero; }
1996 public void clearHandle() { this.handle = IntPtr.Zero; }
1997
1998 #endregion
1999 }
2000
2001 /*
2002 'ChannelControl' API
2003 */
2004 interface IChannelControl
2005 {
2006 RESULT getSystemObject (out System system);
2007
2008 // General control functionality for Channels and ChannelGroups.
2009 RESULT stop ();
2010 RESULT setPaused (bool paused);
2011 RESULT getPaused (out bool paused);
2012 RESULT setVolume (float volume);
2013 RESULT getVolume (out float volume);
2014 RESULT setVolumeRamp (bool ramp);
2015 RESULT getVolumeRamp (out bool ramp);
2016 RESULT getAudibility (out float audibility);
2017 RESULT setPitch (float pitch);
2018 RESULT getPitch (out float pitch);
2019 RESULT setMute (bool mute);
2020 RESULT getMute (out bool mute);
2021 RESULT setReverbProperties (int instance, float wet);
2022 RESULT getReverbProperties (int instance, out float wet);
2023 RESULT setLowPassGain (float gain);
2024 RESULT getLowPassGain (out float gain);
2025 RESULT setMode (MODE mode);
2026 RESULT getMode (out MODE mode);
2027 RESULT setCallback (CHANNELCONTROL_CALLBACK callback);
2028 RESULT isPlaying (out bool isplaying);
2029
2030 // Note all 'set' functions alter a final matrix, this is why the only get function is getMixMatrix, to avoid other get functions returning incorrect/obsolete values.
2031 RESULT setPan (float pan);
2032 RESULT setMixLevelsOutput (float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright);
2033 RESULT setMixLevelsInput (float[] levels, int numlevels);
2034 RESULT setMixMatrix (float[] matrix, int outchannels, int inchannels, int inchannel_hop);
2035 RESULT getMixMatrix (float[] matrix, out int outchannels, out int inchannels, int inchannel_hop);
2036
2037 // Clock based functionality.
2038 RESULT getDSPClock (out ulong dspclock, out ulong parentclock);
2039 RESULT setDelay (ulong dspclock_start, ulong dspclock_end, bool stopchannels);
2040 RESULT getDelay (out ulong dspclock_start, out ulong dspclock_end);
2041 RESULT getDelay (out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels);
2042 RESULT addFadePoint (ulong dspclock, float volume);
2043 RESULT setFadePointRamp (ulong dspclock, float volume);
2044 RESULT removeFadePoints (ulong dspclock_start, ulong dspclock_end);
2045 RESULT getFadePoints (ref uint numpoints, ulong[] point_dspclock, float[] point_volume);
2046
2047 // DSP effects.
2048 RESULT getDSP (int index, out DSP dsp);
2049 RESULT addDSP (int index, DSP dsp);
2050 RESULT removeDSP (DSP dsp);
2051 RESULT getNumDSPs (out int numdsps);
2052 RESULT setDSPIndex (DSP dsp, int index);
2053 RESULT getDSPIndex (DSP dsp, out int index);
2054
2055 // 3D functionality.
2056 RESULT set3DAttributes (ref VECTOR pos, ref VECTOR vel);
2057 RESULT get3DAttributes (out VECTOR pos, out VECTOR vel);
2058 RESULT set3DMinMaxDistance (float mindistance, float maxdistance);
2059 RESULT get3DMinMaxDistance (out float mindistance, out float maxdistance);
2060 RESULT set3DConeSettings (float insideconeangle, float outsideconeangle, float outsidevolume);
2061 RESULT get3DConeSettings (out float insideconeangle, out float outsideconeangle, out float outsidevolume);
2062 RESULT set3DConeOrientation (ref VECTOR orientation);
2063 RESULT get3DConeOrientation (out VECTOR orientation);
2064 RESULT set3DCustomRolloff (ref VECTOR points, int numpoints);
2065 RESULT get3DCustomRolloff (out IntPtr points, out int numpoints);
2066 RESULT set3DOcclusion (float directocclusion, float reverbocclusion);
2067 RESULT get3DOcclusion (out float directocclusion, out float reverbocclusion);
2068 RESULT set3DSpread (float angle);
2069 RESULT get3DSpread (out float angle);
2070 RESULT set3DLevel (float level);
2071 RESULT get3DLevel (out float level);
2072 RESULT set3DDopplerLevel (float level);
2073 RESULT get3DDopplerLevel (out float level);
2074 RESULT set3DDistanceFilter (bool custom, float customLevel, float centerFreq);
2075 RESULT get3DDistanceFilter (out bool custom, out float customLevel, out float centerFreq);
2076
2077 // Userdata set/get.
2078 RESULT setUserData (IntPtr userdata);
2079 RESULT getUserData (out IntPtr userdata);
2080 }
2081
2082 /*
2083 'Channel' API
2084 */
2085 public struct Channel : IChannelControl
2086 {
2087 // Channel specific control functionality.
2088 public RESULT setFrequency(float frequency)
2089 {
2090 return FMOD5_Channel_SetFrequency(this.handle, frequency);
2091 }
2092 public RESULT getFrequency(out float frequency)
2093 {
2094 return FMOD5_Channel_GetFrequency(this.handle, out frequency);
2095 }
2096 public RESULT setPriority(int priority)
2097 {
2098 return FMOD5_Channel_SetPriority(this.handle, priority);
2099 }
2100 public RESULT getPriority(out int priority)
2101 {
2102 return FMOD5_Channel_GetPriority(this.handle, out priority);
2103 }
2104 public RESULT setPosition(uint position, TIMEUNIT postype)
2105 {
2106 return FMOD5_Channel_SetPosition(this.handle, position, postype);
2107 }
2108 public RESULT getPosition(out uint position, TIMEUNIT postype)
2109 {
2110 return FMOD5_Channel_GetPosition(this.handle, out position, postype);
2111 }
2112 public RESULT setChannelGroup(ChannelGroup channelgroup)
2113 {
2114 return FMOD5_Channel_SetChannelGroup(this.handle, channelgroup.handle);
2115 }
2116 public RESULT getChannelGroup(out ChannelGroup channelgroup)
2117 {
2118 return FMOD5_Channel_GetChannelGroup(this.handle, out channelgroup.handle);
2119 }
2120 public RESULT setLoopCount(int loopcount)
2121 {
2122 return FMOD5_Channel_SetLoopCount(this.handle, loopcount);
2123 }
2124 public RESULT getLoopCount(out int loopcount)
2125 {
2126 return FMOD5_Channel_GetLoopCount(this.handle, out loopcount);
2127 }
2128 public RESULT setLoopPoints(uint loopstart, TIMEUNIT loopstarttype, uint loopend, TIMEUNIT loopendtype)
2129 {
2130 return FMOD5_Channel_SetLoopPoints(this.handle, loopstart, loopstarttype, loopend, loopendtype);
2131 }
2132 public RESULT getLoopPoints(out uint loopstart, TIMEUNIT loopstarttype, out uint loopend, TIMEUNIT loopendtype)
2133 {
2134 return FMOD5_Channel_GetLoopPoints(this.handle, out loopstart, loopstarttype, out loopend, loopendtype);
2135 }
2136
2137 // Information only functions.
2138 public RESULT isVirtual(out bool isvirtual)
2139 {
2140 return FMOD5_Channel_IsVirtual(this.handle, out isvirtual);
2141 }
2142 public RESULT getCurrentSound(out Sound sound)
2143 {
2144 return FMOD5_Channel_GetCurrentSound(this.handle, out sound.handle);
2145 }
2146 public RESULT getIndex(out int index)
2147 {
2148 return FMOD5_Channel_GetIndex(this.handle, out index);
2149 }
2150
2151 public RESULT getSystemObject(out System system)
2152 {
2153 return FMOD5_Channel_GetSystemObject(this.handle, out system.handle);
2154 }
2155
2156 // General control functionality for Channels and ChannelGroups.
2157 public RESULT stop()
2158 {
2159 return FMOD5_Channel_Stop(this.handle);
2160 }
2161 public RESULT setPaused(bool paused)
2162 {
2163 return FMOD5_Channel_SetPaused(this.handle, paused);
2164 }
2165 public RESULT getPaused(out bool paused)
2166 {
2167 return FMOD5_Channel_GetPaused(this.handle, out paused);
2168 }
2169 public RESULT setVolume(float volume)
2170 {
2171 return FMOD5_Channel_SetVolume(this.handle, volume);
2172 }
2173 public RESULT getVolume(out float volume)
2174 {
2175 return FMOD5_Channel_GetVolume(this.handle, out volume);
2176 }
2177 public RESULT setVolumeRamp(bool ramp)
2178 {
2179 return FMOD5_Channel_SetVolumeRamp(this.handle, ramp);
2180 }
2181 public RESULT getVolumeRamp(out bool ramp)
2182 {
2183 return FMOD5_Channel_GetVolumeRamp(this.handle, out ramp);
2184 }
2185 public RESULT getAudibility(out float audibility)
2186 {
2187 return FMOD5_Channel_GetAudibility(this.handle, out audibility);
2188 }
2189 public RESULT setPitch(float pitch)
2190 {
2191 return FMOD5_Channel_SetPitch(this.handle, pitch);
2192 }
2193 public RESULT getPitch(out float pitch)
2194 {
2195 return FMOD5_Channel_GetPitch(this.handle, out pitch);
2196 }
2197 public RESULT setMute(bool mute)
2198 {
2199 return FMOD5_Channel_SetMute(this.handle, mute);
2200 }
2201 public RESULT getMute(out bool mute)
2202 {
2203 return FMOD5_Channel_GetMute(this.handle, out mute);
2204 }
2205 public RESULT setReverbProperties(int instance, float wet)
2206 {
2207 return FMOD5_Channel_SetReverbProperties(this.handle, instance, wet);
2208 }
2209 public RESULT getReverbProperties(int instance, out float wet)
2210 {
2211 return FMOD5_Channel_GetReverbProperties(this.handle, instance, out wet);
2212 }
2213 public RESULT setLowPassGain(float gain)
2214 {
2215 return FMOD5_Channel_SetLowPassGain(this.handle, gain);
2216 }
2217 public RESULT getLowPassGain(out float gain)
2218 {
2219 return FMOD5_Channel_GetLowPassGain(this.handle, out gain);
2220 }
2221 public RESULT setMode(MODE mode)
2222 {
2223 return FMOD5_Channel_SetMode(this.handle, mode);
2224 }
2225 public RESULT getMode(out MODE mode)
2226 {
2227 return FMOD5_Channel_GetMode(this.handle, out mode);
2228 }
2229 public RESULT setCallback(CHANNELCONTROL_CALLBACK callback)
2230 {
2231 return FMOD5_Channel_SetCallback(this.handle, callback);
2232 }
2233 public RESULT isPlaying(out bool isplaying)
2234 {
2235 return FMOD5_Channel_IsPlaying(this.handle, out isplaying);
2236 }
2237
2238 // Note all 'set' functions alter a final matrix, this is why the only get function is getMixMatrix, to avoid other get functions returning incorrect/obsolete values.
2239 public RESULT setPan(float pan)
2240 {
2241 return FMOD5_Channel_SetPan(this.handle, pan);
2242 }
2243 public RESULT setMixLevelsOutput(float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright)
2244 {
2245 return FMOD5_Channel_SetMixLevelsOutput(this.handle, frontleft, frontright, center, lfe, surroundleft, surroundright, backleft, backright);
2246 }
2247 public RESULT setMixLevelsInput(float[] levels, int numlevels)
2248 {
2249 return FMOD5_Channel_SetMixLevelsInput(this.handle, levels, numlevels);
2250 }
2251 public RESULT setMixMatrix(float[] matrix, int outchannels, int inchannels, int inchannel_hop = 0)
2252 {
2253 return FMOD5_Channel_SetMixMatrix(this.handle, matrix, outchannels, inchannels, inchannel_hop);
2254 }
2255 public RESULT getMixMatrix(float[] matrix, out int outchannels, out int inchannels, int inchannel_hop = 0)
2256 {
2257 return FMOD5_Channel_GetMixMatrix(this.handle, matrix, out outchannels, out inchannels, inchannel_hop);
2258 }
2259
2260 // Clock based functionality.
2261 public RESULT getDSPClock(out ulong dspclock, out ulong parentclock)
2262 {
2263 return FMOD5_Channel_GetDSPClock(this.handle, out dspclock, out parentclock);
2264 }
2265 public RESULT setDelay(ulong dspclock_start, ulong dspclock_end, bool stopchannels = true)
2266 {
2267 return FMOD5_Channel_SetDelay(this.handle, dspclock_start, dspclock_end, stopchannels);
2268 }
2269 public RESULT getDelay(out ulong dspclock_start, out ulong dspclock_end)
2270 {
2271 return FMOD5_Channel_GetDelay(this.handle, out dspclock_start, out dspclock_end, IntPtr.Zero);
2272 }
2273 public RESULT getDelay(out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels)
2274 {
2275 return FMOD5_Channel_GetDelay(this.handle, out dspclock_start, out dspclock_end, out stopchannels);
2276 }
2277 public RESULT addFadePoint(ulong dspclock, float volume)
2278 {
2279 return FMOD5_Channel_AddFadePoint(this.handle, dspclock, volume);
2280 }
2281 public RESULT setFadePointRamp(ulong dspclock, float volume)
2282 {
2283 return FMOD5_Channel_SetFadePointRamp(this.handle, dspclock, volume);
2284 }
2285 public RESULT removeFadePoints(ulong dspclock_start, ulong dspclock_end)
2286 {
2287 return FMOD5_Channel_RemoveFadePoints(this.handle, dspclock_start, dspclock_end);
2288 }
2289 public RESULT getFadePoints(ref uint numpoints, ulong[] point_dspclock, float[] point_volume)
2290 {
2291 return FMOD5_Channel_GetFadePoints(this.handle, ref numpoints, point_dspclock, point_volume);
2292 }
2293
2294 // DSP effects.
2295 public RESULT getDSP(int index, out DSP dsp)
2296 {
2297 return FMOD5_Channel_GetDSP(this.handle, index, out dsp.handle);
2298 }
2299 public RESULT addDSP(int index, DSP dsp)
2300 {
2301 return FMOD5_Channel_AddDSP(this.handle, index, dsp.handle);
2302 }
2303 public RESULT removeDSP(DSP dsp)
2304 {
2305 return FMOD5_Channel_RemoveDSP(this.handle, dsp.handle);
2306 }
2307 public RESULT getNumDSPs(out int numdsps)
2308 {
2309 return FMOD5_Channel_GetNumDSPs(this.handle, out numdsps);
2310 }
2311 public RESULT setDSPIndex(DSP dsp, int index)
2312 {
2313 return FMOD5_Channel_SetDSPIndex(this.handle, dsp.handle, index);
2314 }
2315 public RESULT getDSPIndex(DSP dsp, out int index)
2316 {
2317 return FMOD5_Channel_GetDSPIndex(this.handle, dsp.handle, out index);
2318 }
2319
2320 // 3D functionality.
2321 public RESULT set3DAttributes(ref VECTOR pos, ref VECTOR vel)
2322 {
2323 return FMOD5_Channel_Set3DAttributes(this.handle, ref pos, ref vel);
2324 }
2325 public RESULT get3DAttributes(out VECTOR pos, out VECTOR vel)
2326 {
2327 return FMOD5_Channel_Get3DAttributes(this.handle, out pos, out vel);
2328 }
2329 public RESULT set3DMinMaxDistance(float mindistance, float maxdistance)
2330 {
2331 return FMOD5_Channel_Set3DMinMaxDistance(this.handle, mindistance, maxdistance);
2332 }
2333 public RESULT get3DMinMaxDistance(out float mindistance, out float maxdistance)
2334 {
2335 return FMOD5_Channel_Get3DMinMaxDistance(this.handle, out mindistance, out maxdistance);
2336 }
2337 public RESULT set3DConeSettings(float insideconeangle, float outsideconeangle, float outsidevolume)
2338 {
2339 return FMOD5_Channel_Set3DConeSettings(this.handle, insideconeangle, outsideconeangle, outsidevolume);
2340 }
2341 public RESULT get3DConeSettings(out float insideconeangle, out float outsideconeangle, out float outsidevolume)
2342 {
2343 return FMOD5_Channel_Get3DConeSettings(this.handle, out insideconeangle, out outsideconeangle, out outsidevolume);
2344 }
2345 public RESULT set3DConeOrientation(ref VECTOR orientation)
2346 {
2347 return FMOD5_Channel_Set3DConeOrientation(this.handle, ref orientation);
2348 }
2349 public RESULT get3DConeOrientation(out VECTOR orientation)
2350 {
2351 return FMOD5_Channel_Get3DConeOrientation(this.handle, out orientation);
2352 }
2353 public RESULT set3DCustomRolloff(ref VECTOR points, int numpoints)
2354 {
2355 return FMOD5_Channel_Set3DCustomRolloff(this.handle, ref points, numpoints);
2356 }
2357 public RESULT get3DCustomRolloff(out IntPtr points, out int numpoints)
2358 {
2359 return FMOD5_Channel_Get3DCustomRolloff(this.handle, out points, out numpoints);
2360 }
2361 public RESULT set3DOcclusion(float directocclusion, float reverbocclusion)
2362 {
2363 return FMOD5_Channel_Set3DOcclusion(this.handle, directocclusion, reverbocclusion);
2364 }
2365 public RESULT get3DOcclusion(out float directocclusion, out float reverbocclusion)
2366 {
2367 return FMOD5_Channel_Get3DOcclusion(this.handle, out directocclusion, out reverbocclusion);
2368 }
2369 public RESULT set3DSpread(float angle)
2370 {
2371 return FMOD5_Channel_Set3DSpread(this.handle, angle);
2372 }
2373 public RESULT get3DSpread(out float angle)
2374 {
2375 return FMOD5_Channel_Get3DSpread(this.handle, out angle);
2376 }
2377 public RESULT set3DLevel(float level)
2378 {
2379 return FMOD5_Channel_Set3DLevel(this.handle, level);
2380 }
2381 public RESULT get3DLevel(out float level)
2382 {
2383 return FMOD5_Channel_Get3DLevel(this.handle, out level);
2384 }
2385 public RESULT set3DDopplerLevel(float level)
2386 {
2387 return FMOD5_Channel_Set3DDopplerLevel(this.handle, level);
2388 }
2389 public RESULT get3DDopplerLevel(out float level)
2390 {
2391 return FMOD5_Channel_Get3DDopplerLevel(this.handle, out level);
2392 }
2393 public RESULT set3DDistanceFilter(bool custom, float customLevel, float centerFreq)
2394 {
2395 return FMOD5_Channel_Set3DDistanceFilter(this.handle, custom, customLevel, centerFreq);
2396 }
2397 public RESULT get3DDistanceFilter(out bool custom, out float customLevel, out float centerFreq)
2398 {
2399 return FMOD5_Channel_Get3DDistanceFilter(this.handle, out custom, out customLevel, out centerFreq);
2400 }
2401
2402 // Userdata set/get.
2403 public RESULT setUserData(IntPtr userdata)
2404 {
2405 return FMOD5_Channel_SetUserData(this.handle, userdata);
2406 }
2407 public RESULT getUserData(out IntPtr userdata)
2408 {
2409 return FMOD5_Channel_GetUserData(this.handle, out userdata);
2410 }
2411
2412 #region importfunctions
2413 [DllImport(VERSION.dll)]
2414 private static extern RESULT FMOD5_Channel_SetFrequency (IntPtr channel, float frequency);
2415 [DllImport(VERSION.dll)]
2416 private static extern RESULT FMOD5_Channel_GetFrequency (IntPtr channel, out float frequency);
2417 [DllImport(VERSION.dll)]
2418 private static extern RESULT FMOD5_Channel_SetPriority (IntPtr channel, int priority);
2419 [DllImport(VERSION.dll)]
2420 private static extern RESULT FMOD5_Channel_GetPriority (IntPtr channel, out int priority);
2421 [DllImport(VERSION.dll)]
2422 private static extern RESULT FMOD5_Channel_SetPosition (IntPtr channel, uint position, TIMEUNIT postype);
2423 [DllImport(VERSION.dll)]
2424 private static extern RESULT FMOD5_Channel_GetPosition (IntPtr channel, out uint position, TIMEUNIT postype);
2425 [DllImport(VERSION.dll)]
2426 private static extern RESULT FMOD5_Channel_SetChannelGroup (IntPtr channel, IntPtr channelgroup);
2427 [DllImport(VERSION.dll)]
2428 private static extern RESULT FMOD5_Channel_GetChannelGroup (IntPtr channel, out IntPtr channelgroup);
2429 [DllImport(VERSION.dll)]
2430 private static extern RESULT FMOD5_Channel_SetLoopCount (IntPtr channel, int loopcount);
2431 [DllImport(VERSION.dll)]
2432 private static extern RESULT FMOD5_Channel_GetLoopCount (IntPtr channel, out int loopcount);
2433 [DllImport(VERSION.dll)]
2434 private static extern RESULT FMOD5_Channel_SetLoopPoints (IntPtr channel, uint loopstart, TIMEUNIT loopstarttype, uint loopend, TIMEUNIT loopendtype);
2435 [DllImport(VERSION.dll)]
2436 private static extern RESULT FMOD5_Channel_GetLoopPoints (IntPtr channel, out uint loopstart, TIMEUNIT loopstarttype, out uint loopend, TIMEUNIT loopendtype);
2437 [DllImport(VERSION.dll)]
2438 private static extern RESULT FMOD5_Channel_IsVirtual (IntPtr channel, out bool isvirtual);
2439 [DllImport(VERSION.dll)]
2440 private static extern RESULT FMOD5_Channel_GetCurrentSound (IntPtr channel, out IntPtr sound);
2441 [DllImport(VERSION.dll)]
2442 private static extern RESULT FMOD5_Channel_GetIndex (IntPtr channel, out int index);
2443 [DllImport(VERSION.dll)]
2444 private static extern RESULT FMOD5_Channel_GetSystemObject (IntPtr channel, out IntPtr system);
2445 [DllImport(VERSION.dll)]
2446 private static extern RESULT FMOD5_Channel_Stop (IntPtr channel);
2447 [DllImport(VERSION.dll)]
2448 private static extern RESULT FMOD5_Channel_SetPaused (IntPtr channel, bool paused);
2449 [DllImport(VERSION.dll)]
2450 private static extern RESULT FMOD5_Channel_GetPaused (IntPtr channel, out bool paused);
2451 [DllImport(VERSION.dll)]
2452 private static extern RESULT FMOD5_Channel_SetVolume (IntPtr channel, float volume);
2453 [DllImport(VERSION.dll)]
2454 private static extern RESULT FMOD5_Channel_GetVolume (IntPtr channel, out float volume);
2455 [DllImport(VERSION.dll)]
2456 private static extern RESULT FMOD5_Channel_SetVolumeRamp (IntPtr channel, bool ramp);
2457 [DllImport(VERSION.dll)]
2458 private static extern RESULT FMOD5_Channel_GetVolumeRamp (IntPtr channel, out bool ramp);
2459 [DllImport(VERSION.dll)]
2460 private static extern RESULT FMOD5_Channel_GetAudibility (IntPtr channel, out float audibility);
2461 [DllImport(VERSION.dll)]
2462 private static extern RESULT FMOD5_Channel_SetPitch (IntPtr channel, float pitch);
2463 [DllImport(VERSION.dll)]
2464 private static extern RESULT FMOD5_Channel_GetPitch (IntPtr channel, out float pitch);
2465 [DllImport(VERSION.dll)]
2466 private static extern RESULT FMOD5_Channel_SetMute (IntPtr channel, bool mute);
2467 [DllImport(VERSION.dll)]
2468 private static extern RESULT FMOD5_Channel_GetMute (IntPtr channel, out bool mute);
2469 [DllImport(VERSION.dll)]
2470 private static extern RESULT FMOD5_Channel_SetReverbProperties (IntPtr channel, int instance, float wet);
2471 [DllImport(VERSION.dll)]
2472 private static extern RESULT FMOD5_Channel_GetReverbProperties (IntPtr channel, int instance, out float wet);
2473 [DllImport(VERSION.dll)]
2474 private static extern RESULT FMOD5_Channel_SetLowPassGain (IntPtr channel, float gain);
2475 [DllImport(VERSION.dll)]
2476 private static extern RESULT FMOD5_Channel_GetLowPassGain (IntPtr channel, out float gain);
2477 [DllImport(VERSION.dll)]
2478 private static extern RESULT FMOD5_Channel_SetMode (IntPtr channel, MODE mode);
2479 [DllImport(VERSION.dll)]
2480 private static extern RESULT FMOD5_Channel_GetMode (IntPtr channel, out MODE mode);
2481 [DllImport(VERSION.dll)]
2482 private static extern RESULT FMOD5_Channel_SetCallback (IntPtr channel, CHANNELCONTROL_CALLBACK callback);
2483 [DllImport(VERSION.dll)]
2484 private static extern RESULT FMOD5_Channel_IsPlaying (IntPtr channel, out bool isplaying);
2485 [DllImport(VERSION.dll)]
2486 private static extern RESULT FMOD5_Channel_SetPan (IntPtr channel, float pan);
2487 [DllImport(VERSION.dll)]
2488 private static extern RESULT FMOD5_Channel_SetMixLevelsOutput (IntPtr channel, float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright);
2489 [DllImport(VERSION.dll)]
2490 private static extern RESULT FMOD5_Channel_SetMixLevelsInput (IntPtr channel, float[] levels, int numlevels);
2491 [DllImport(VERSION.dll)]
2492 private static extern RESULT FMOD5_Channel_SetMixMatrix (IntPtr channel, float[] matrix, int outchannels, int inchannels, int inchannel_hop);
2493 [DllImport(VERSION.dll)]
2494 private static extern RESULT FMOD5_Channel_GetMixMatrix (IntPtr channel, float[] matrix, out int outchannels, out int inchannels, int inchannel_hop);
2495 [DllImport(VERSION.dll)]
2496 private static extern RESULT FMOD5_Channel_GetDSPClock (IntPtr channel, out ulong dspclock, out ulong parentclock);
2497 [DllImport(VERSION.dll)]
2498 private static extern RESULT FMOD5_Channel_SetDelay (IntPtr channel, ulong dspclock_start, ulong dspclock_end, bool stopchannels);
2499 [DllImport(VERSION.dll)]
2500 private static extern RESULT FMOD5_Channel_GetDelay (IntPtr channel, out ulong dspclock_start, out ulong dspclock_end, IntPtr zero);
2501 [DllImport(VERSION.dll)]
2502 private static extern RESULT FMOD5_Channel_GetDelay (IntPtr channel, out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels);
2503 [DllImport(VERSION.dll)]
2504 private static extern RESULT FMOD5_Channel_AddFadePoint (IntPtr channel, ulong dspclock, float volume);
2505 [DllImport(VERSION.dll)]
2506 private static extern RESULT FMOD5_Channel_SetFadePointRamp (IntPtr channel, ulong dspclock, float volume);
2507 [DllImport(VERSION.dll)]
2508 private static extern RESULT FMOD5_Channel_RemoveFadePoints (IntPtr channel, ulong dspclock_start, ulong dspclock_end);
2509 [DllImport(VERSION.dll)]
2510 private static extern RESULT FMOD5_Channel_GetFadePoints (IntPtr channel, ref uint numpoints, ulong[] point_dspclock, float[] point_volume);
2511 [DllImport(VERSION.dll)]
2512 private static extern RESULT FMOD5_Channel_GetDSP (IntPtr channel, int index, out IntPtr dsp);
2513 [DllImport(VERSION.dll)]
2514 private static extern RESULT FMOD5_Channel_AddDSP (IntPtr channel, int index, IntPtr dsp);
2515 [DllImport(VERSION.dll)]
2516 private static extern RESULT FMOD5_Channel_RemoveDSP (IntPtr channel, IntPtr dsp);
2517 [DllImport(VERSION.dll)]
2518 private static extern RESULT FMOD5_Channel_GetNumDSPs (IntPtr channel, out int numdsps);
2519 [DllImport(VERSION.dll)]
2520 private static extern RESULT FMOD5_Channel_SetDSPIndex (IntPtr channel, IntPtr dsp, int index);
2521 [DllImport(VERSION.dll)]
2522 private static extern RESULT FMOD5_Channel_GetDSPIndex (IntPtr channel, IntPtr dsp, out int index);
2523 [DllImport(VERSION.dll)]
2524 private static extern RESULT FMOD5_Channel_Set3DAttributes (IntPtr channel, ref VECTOR pos, ref VECTOR vel);
2525 [DllImport(VERSION.dll)]
2526 private static extern RESULT FMOD5_Channel_Get3DAttributes (IntPtr channel, out VECTOR pos, out VECTOR vel);
2527 [DllImport(VERSION.dll)]
2528 private static extern RESULT FMOD5_Channel_Set3DMinMaxDistance (IntPtr channel, float mindistance, float maxdistance);
2529 [DllImport(VERSION.dll)]
2530 private static extern RESULT FMOD5_Channel_Get3DMinMaxDistance (IntPtr channel, out float mindistance, out float maxdistance);
2531 [DllImport(VERSION.dll)]
2532 private static extern RESULT FMOD5_Channel_Set3DConeSettings (IntPtr channel, float insideconeangle, float outsideconeangle, float outsidevolume);
2533 [DllImport(VERSION.dll)]
2534 private static extern RESULT FMOD5_Channel_Get3DConeSettings (IntPtr channel, out float insideconeangle, out float outsideconeangle, out float outsidevolume);
2535 [DllImport(VERSION.dll)]
2536 private static extern RESULT FMOD5_Channel_Set3DConeOrientation (IntPtr channel, ref VECTOR orientation);
2537 [DllImport(VERSION.dll)]
2538 private static extern RESULT FMOD5_Channel_Get3DConeOrientation (IntPtr channel, out VECTOR orientation);
2539 [DllImport(VERSION.dll)]
2540 private static extern RESULT FMOD5_Channel_Set3DCustomRolloff (IntPtr channel, ref VECTOR points, int numpoints);
2541 [DllImport(VERSION.dll)]
2542 private static extern RESULT FMOD5_Channel_Get3DCustomRolloff (IntPtr channel, out IntPtr points, out int numpoints);
2543 [DllImport(VERSION.dll)]
2544 private static extern RESULT FMOD5_Channel_Set3DOcclusion (IntPtr channel, float directocclusion, float reverbocclusion);
2545 [DllImport(VERSION.dll)]
2546 private static extern RESULT FMOD5_Channel_Get3DOcclusion (IntPtr channel, out float directocclusion, out float reverbocclusion);
2547 [DllImport(VERSION.dll)]
2548 private static extern RESULT FMOD5_Channel_Set3DSpread (IntPtr channel, float angle);
2549 [DllImport(VERSION.dll)]
2550 private static extern RESULT FMOD5_Channel_Get3DSpread (IntPtr channel, out float angle);
2551 [DllImport(VERSION.dll)]
2552 private static extern RESULT FMOD5_Channel_Set3DLevel (IntPtr channel, float level);
2553 [DllImport(VERSION.dll)]
2554 private static extern RESULT FMOD5_Channel_Get3DLevel (IntPtr channel, out float level);
2555 [DllImport(VERSION.dll)]
2556 private static extern RESULT FMOD5_Channel_Set3DDopplerLevel (IntPtr channel, float level);
2557 [DllImport(VERSION.dll)]
2558 private static extern RESULT FMOD5_Channel_Get3DDopplerLevel (IntPtr channel, out float level);
2559 [DllImport(VERSION.dll)]
2560 private static extern RESULT FMOD5_Channel_Set3DDistanceFilter (IntPtr channel, bool custom, float customLevel, float centerFreq);
2561 [DllImport(VERSION.dll)]
2562 private static extern RESULT FMOD5_Channel_Get3DDistanceFilter (IntPtr channel, out bool custom, out float customLevel, out float centerFreq);
2563 [DllImport(VERSION.dll)]
2564 private static extern RESULT FMOD5_Channel_SetUserData (IntPtr channel, IntPtr userdata);
2565 [DllImport(VERSION.dll)]
2566 private static extern RESULT FMOD5_Channel_GetUserData (IntPtr channel, out IntPtr userdata);
2567 #endregion
2568
2569 #region wrapperinternal
2570
2571 public IntPtr handle;
2572
2573 public Channel(IntPtr ptr) { this.handle = ptr; }
2574 public bool hasHandle() { return this.handle != IntPtr.Zero; }
2575 public void clearHandle() { this.handle = IntPtr.Zero; }
2576
2577 #endregion
2578 }
2579
2580 /*
2581 'ChannelGroup' API
2582 */
2583 public struct ChannelGroup : IChannelControl
2584 {
2585 public RESULT release()
2586 {
2587 return FMOD5_ChannelGroup_Release(this.handle);
2588 }
2589
2590 // Nested channel groups.
2591 public RESULT addGroup(ChannelGroup group, bool propagatedspclock = true)
2592 {
2593 return FMOD5_ChannelGroup_AddGroup(this.handle, group.handle, propagatedspclock, IntPtr.Zero);
2594 }
2595 public RESULT addGroup(ChannelGroup group, bool propagatedspclock, out DSPConnection connection)
2596 {
2597 return FMOD5_ChannelGroup_AddGroup(this.handle, group.handle, propagatedspclock, out connection.handle);
2598 }
2599 public RESULT getNumGroups(out int numgroups)
2600 {
2601 return FMOD5_ChannelGroup_GetNumGroups(this.handle, out numgroups);
2602 }
2603 public RESULT getGroup(int index, out ChannelGroup group)
2604 {
2605 return FMOD5_ChannelGroup_GetGroup(this.handle, index, out group.handle);
2606 }
2607 public RESULT getParentGroup(out ChannelGroup group)
2608 {
2609 return FMOD5_ChannelGroup_GetParentGroup(this.handle, out group.handle);
2610 }
2611
2612 // Information only functions.
2613 public RESULT getName(out string name, int namelen)
2614 {
2615 IntPtr stringMem = Marshal.AllocHGlobal(namelen);
2616
2617 RESULT result = FMOD5_ChannelGroup_GetName(this.handle, stringMem, namelen);
2618 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
2619 {
2620 name = encoder.stringFromNative(stringMem);
2621 }
2622 Marshal.FreeHGlobal(stringMem);
2623
2624 return result;
2625 }
2626 public RESULT getNumChannels(out int numchannels)
2627 {
2628 return FMOD5_ChannelGroup_GetNumChannels(this.handle, out numchannels);
2629 }
2630 public RESULT getChannel(int index, out Channel channel)
2631 {
2632 return FMOD5_ChannelGroup_GetChannel(this.handle, index, out channel.handle);
2633 }
2634
2635 public RESULT getSystemObject(out System system)
2636 {
2637 return FMOD5_ChannelGroup_GetSystemObject(this.handle, out system.handle);
2638 }
2639
2640 // General control functionality for Channels and ChannelGroups.
2641 public RESULT stop()
2642 {
2643 return FMOD5_ChannelGroup_Stop(this.handle);
2644 }
2645 public RESULT setPaused(bool paused)
2646 {
2647 return FMOD5_ChannelGroup_SetPaused(this.handle, paused);
2648 }
2649 public RESULT getPaused(out bool paused)
2650 {
2651 return FMOD5_ChannelGroup_GetPaused(this.handle, out paused);
2652 }
2653 public RESULT setVolume(float volume)
2654 {
2655 return FMOD5_ChannelGroup_SetVolume(this.handle, volume);
2656 }
2657 public RESULT getVolume(out float volume)
2658 {
2659 return FMOD5_ChannelGroup_GetVolume(this.handle, out volume);
2660 }
2661 public RESULT setVolumeRamp(bool ramp)
2662 {
2663 return FMOD5_ChannelGroup_SetVolumeRamp(this.handle, ramp);
2664 }
2665 public RESULT getVolumeRamp(out bool ramp)
2666 {
2667 return FMOD5_ChannelGroup_GetVolumeRamp(this.handle, out ramp);
2668 }
2669 public RESULT getAudibility(out float audibility)
2670 {
2671 return FMOD5_ChannelGroup_GetAudibility(this.handle, out audibility);
2672 }
2673 public RESULT setPitch(float pitch)
2674 {
2675 return FMOD5_ChannelGroup_SetPitch(this.handle, pitch);
2676 }
2677 public RESULT getPitch(out float pitch)
2678 {
2679 return FMOD5_ChannelGroup_GetPitch(this.handle, out pitch);
2680 }
2681 public RESULT setMute(bool mute)
2682 {
2683 return FMOD5_ChannelGroup_SetMute(this.handle, mute);
2684 }
2685 public RESULT getMute(out bool mute)
2686 {
2687 return FMOD5_ChannelGroup_GetMute(this.handle, out mute);
2688 }
2689 public RESULT setReverbProperties(int instance, float wet)
2690 {
2691 return FMOD5_ChannelGroup_SetReverbProperties(this.handle, instance, wet);
2692 }
2693 public RESULT getReverbProperties(int instance, out float wet)
2694 {
2695 return FMOD5_ChannelGroup_GetReverbProperties(this.handle, instance, out wet);
2696 }
2697 public RESULT setLowPassGain(float gain)
2698 {
2699 return FMOD5_ChannelGroup_SetLowPassGain(this.handle, gain);
2700 }
2701 public RESULT getLowPassGain(out float gain)
2702 {
2703 return FMOD5_ChannelGroup_GetLowPassGain(this.handle, out gain);
2704 }
2705 public RESULT setMode(MODE mode)
2706 {
2707 return FMOD5_ChannelGroup_SetMode(this.handle, mode);
2708 }
2709 public RESULT getMode(out MODE mode)
2710 {
2711 return FMOD5_ChannelGroup_GetMode(this.handle, out mode);
2712 }
2713 public RESULT setCallback(CHANNELCONTROL_CALLBACK callback)
2714 {
2715 return FMOD5_ChannelGroup_SetCallback(this.handle, callback);
2716 }
2717 public RESULT isPlaying(out bool isplaying)
2718 {
2719 return FMOD5_ChannelGroup_IsPlaying(this.handle, out isplaying);
2720 }
2721
2722 // Note all 'set' functions alter a final matrix, this is why the only get function is getMixMatrix, to avoid other get functions returning incorrect/obsolete values.
2723 public RESULT setPan(float pan)
2724 {
2725 return FMOD5_ChannelGroup_SetPan(this.handle, pan);
2726 }
2727 public RESULT setMixLevelsOutput(float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright)
2728 {
2729 return FMOD5_ChannelGroup_SetMixLevelsOutput(this.handle, frontleft, frontright, center, lfe, surroundleft, surroundright, backleft, backright);
2730 }
2731 public RESULT setMixLevelsInput(float[] levels, int numlevels)
2732 {
2733 return FMOD5_ChannelGroup_SetMixLevelsInput(this.handle, levels, numlevels);
2734 }
2735 public RESULT setMixMatrix(float[] matrix, int outchannels, int inchannels, int inchannel_hop)
2736 {
2737 return FMOD5_ChannelGroup_SetMixMatrix(this.handle, matrix, outchannels, inchannels, inchannel_hop);
2738 }
2739 public RESULT getMixMatrix(float[] matrix, out int outchannels, out int inchannels, int inchannel_hop)
2740 {
2741 return FMOD5_ChannelGroup_GetMixMatrix(this.handle, matrix, out outchannels, out inchannels, inchannel_hop);
2742 }
2743
2744 // Clock based functionality.
2745 public RESULT getDSPClock(out ulong dspclock, out ulong parentclock)
2746 {
2747 return FMOD5_ChannelGroup_GetDSPClock(this.handle, out dspclock, out parentclock);
2748 }
2749 public RESULT setDelay(ulong dspclock_start, ulong dspclock_end, bool stopchannels)
2750 {
2751 return FMOD5_ChannelGroup_SetDelay(this.handle, dspclock_start, dspclock_end, stopchannels);
2752 }
2753 public RESULT getDelay(out ulong dspclock_start, out ulong dspclock_end)
2754 {
2755 return FMOD5_ChannelGroup_GetDelay(this.handle, out dspclock_start, out dspclock_end, IntPtr.Zero);
2756 }
2757 public RESULT getDelay(out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels)
2758 {
2759 return FMOD5_ChannelGroup_GetDelay(this.handle, out dspclock_start, out dspclock_end, out stopchannels);
2760 }
2761 public RESULT addFadePoint(ulong dspclock, float volume)
2762 {
2763 return FMOD5_ChannelGroup_AddFadePoint(this.handle, dspclock, volume);
2764 }
2765 public RESULT setFadePointRamp(ulong dspclock, float volume)
2766 {
2767 return FMOD5_ChannelGroup_SetFadePointRamp(this.handle, dspclock, volume);
2768 }
2769 public RESULT removeFadePoints(ulong dspclock_start, ulong dspclock_end)
2770 {
2771 return FMOD5_ChannelGroup_RemoveFadePoints(this.handle, dspclock_start, dspclock_end);
2772 }
2773 public RESULT getFadePoints(ref uint numpoints, ulong[] point_dspclock, float[] point_volume)
2774 {
2775 return FMOD5_ChannelGroup_GetFadePoints(this.handle, ref numpoints, point_dspclock, point_volume);
2776 }
2777
2778 // DSP effects.
2779 public RESULT getDSP(int index, out DSP dsp)
2780 {
2781 return FMOD5_ChannelGroup_GetDSP(this.handle, index, out dsp.handle);
2782 }
2783 public RESULT addDSP(int index, DSP dsp)
2784 {
2785 return FMOD5_ChannelGroup_AddDSP(this.handle, index, dsp.handle);
2786 }
2787 public RESULT removeDSP(DSP dsp)
2788 {
2789 return FMOD5_ChannelGroup_RemoveDSP(this.handle, dsp.handle);
2790 }
2791 public RESULT getNumDSPs(out int numdsps)
2792 {
2793 return FMOD5_ChannelGroup_GetNumDSPs(this.handle, out numdsps);
2794 }
2795 public RESULT setDSPIndex(DSP dsp, int index)
2796 {
2797 return FMOD5_ChannelGroup_SetDSPIndex(this.handle, dsp.handle, index);
2798 }
2799 public RESULT getDSPIndex(DSP dsp, out int index)
2800 {
2801 return FMOD5_ChannelGroup_GetDSPIndex(this.handle, dsp.handle, out index);
2802 }
2803
2804 // 3D functionality.
2805 public RESULT set3DAttributes(ref VECTOR pos, ref VECTOR vel)
2806 {
2807 return FMOD5_ChannelGroup_Set3DAttributes(this.handle, ref pos, ref vel);
2808 }
2809 public RESULT get3DAttributes(out VECTOR pos, out VECTOR vel)
2810 {
2811 return FMOD5_ChannelGroup_Get3DAttributes(this.handle, out pos, out vel);
2812 }
2813 public RESULT set3DMinMaxDistance(float mindistance, float maxdistance)
2814 {
2815 return FMOD5_ChannelGroup_Set3DMinMaxDistance(this.handle, mindistance, maxdistance);
2816 }
2817 public RESULT get3DMinMaxDistance(out float mindistance, out float maxdistance)
2818 {
2819 return FMOD5_ChannelGroup_Get3DMinMaxDistance(this.handle, out mindistance, out maxdistance);
2820 }
2821 public RESULT set3DConeSettings(float insideconeangle, float outsideconeangle, float outsidevolume)
2822 {
2823 return FMOD5_ChannelGroup_Set3DConeSettings(this.handle, insideconeangle, outsideconeangle, outsidevolume);
2824 }
2825 public RESULT get3DConeSettings(out float insideconeangle, out float outsideconeangle, out float outsidevolume)
2826 {
2827 return FMOD5_ChannelGroup_Get3DConeSettings(this.handle, out insideconeangle, out outsideconeangle, out outsidevolume);
2828 }
2829 public RESULT set3DConeOrientation(ref VECTOR orientation)
2830 {
2831 return FMOD5_ChannelGroup_Set3DConeOrientation(this.handle, ref orientation);
2832 }
2833 public RESULT get3DConeOrientation(out VECTOR orientation)
2834 {
2835 return FMOD5_ChannelGroup_Get3DConeOrientation(this.handle, out orientation);
2836 }
2837 public RESULT set3DCustomRolloff(ref VECTOR points, int numpoints)
2838 {
2839 return FMOD5_ChannelGroup_Set3DCustomRolloff(this.handle, ref points, numpoints);
2840 }
2841 public RESULT get3DCustomRolloff(out IntPtr points, out int numpoints)
2842 {
2843 return FMOD5_ChannelGroup_Get3DCustomRolloff(this.handle, out points, out numpoints);
2844 }
2845 public RESULT set3DOcclusion(float directocclusion, float reverbocclusion)
2846 {
2847 return FMOD5_ChannelGroup_Set3DOcclusion(this.handle, directocclusion, reverbocclusion);
2848 }
2849 public RESULT get3DOcclusion(out float directocclusion, out float reverbocclusion)
2850 {
2851 return FMOD5_ChannelGroup_Get3DOcclusion(this.handle, out directocclusion, out reverbocclusion);
2852 }
2853 public RESULT set3DSpread(float angle)
2854 {
2855 return FMOD5_ChannelGroup_Set3DSpread(this.handle, angle);
2856 }
2857 public RESULT get3DSpread(out float angle)
2858 {
2859 return FMOD5_ChannelGroup_Get3DSpread(this.handle, out angle);
2860 }
2861 public RESULT set3DLevel(float level)
2862 {
2863 return FMOD5_ChannelGroup_Set3DLevel(this.handle, level);
2864 }
2865 public RESULT get3DLevel(out float level)
2866 {
2867 return FMOD5_ChannelGroup_Get3DLevel(this.handle, out level);
2868 }
2869 public RESULT set3DDopplerLevel(float level)
2870 {
2871 return FMOD5_ChannelGroup_Set3DDopplerLevel(this.handle, level);
2872 }
2873 public RESULT get3DDopplerLevel(out float level)
2874 {
2875 return FMOD5_ChannelGroup_Get3DDopplerLevel(this.handle, out level);
2876 }
2877 public RESULT set3DDistanceFilter(bool custom, float customLevel, float centerFreq)
2878 {
2879 return FMOD5_ChannelGroup_Set3DDistanceFilter(this.handle, custom, customLevel, centerFreq);
2880 }
2881 public RESULT get3DDistanceFilter(out bool custom, out float customLevel, out float centerFreq)
2882 {
2883 return FMOD5_ChannelGroup_Get3DDistanceFilter(this.handle, out custom, out customLevel, out centerFreq);
2884 }
2885
2886 // Userdata set/get.
2887 public RESULT setUserData(IntPtr userdata)
2888 {
2889 return FMOD5_ChannelGroup_SetUserData(this.handle, userdata);
2890 }
2891 public RESULT getUserData(out IntPtr userdata)
2892 {
2893 return FMOD5_ChannelGroup_GetUserData(this.handle, out userdata);
2894 }
2895
2896 #region importfunctions
2897 [DllImport(VERSION.dll)]
2898 private static extern RESULT FMOD5_ChannelGroup_Release (IntPtr channelgroup);
2899 [DllImport(VERSION.dll)]
2900 private static extern RESULT FMOD5_ChannelGroup_AddGroup (IntPtr channelgroup, IntPtr group, bool propagatedspclock, IntPtr zero);
2901 [DllImport(VERSION.dll)]
2902 private static extern RESULT FMOD5_ChannelGroup_AddGroup (IntPtr channelgroup, IntPtr group, bool propagatedspclock, out IntPtr connection);
2903 [DllImport(VERSION.dll)]
2904 private static extern RESULT FMOD5_ChannelGroup_GetNumGroups (IntPtr channelgroup, out int numgroups);
2905 [DllImport(VERSION.dll)]
2906 private static extern RESULT FMOD5_ChannelGroup_GetGroup (IntPtr channelgroup, int index, out IntPtr group);
2907 [DllImport(VERSION.dll)]
2908 private static extern RESULT FMOD5_ChannelGroup_GetParentGroup (IntPtr channelgroup, out IntPtr group);
2909 [DllImport(VERSION.dll)]
2910 private static extern RESULT FMOD5_ChannelGroup_GetName (IntPtr channelgroup, IntPtr name, int namelen);
2911 [DllImport(VERSION.dll)]
2912 private static extern RESULT FMOD5_ChannelGroup_GetNumChannels (IntPtr channelgroup, out int numchannels);
2913 [DllImport(VERSION.dll)]
2914 private static extern RESULT FMOD5_ChannelGroup_GetChannel (IntPtr channelgroup, int index, out IntPtr channel);
2915 [DllImport(VERSION.dll)]
2916 private static extern RESULT FMOD5_ChannelGroup_GetSystemObject (IntPtr channelgroup, out IntPtr system);
2917 [DllImport(VERSION.dll)]
2918 private static extern RESULT FMOD5_ChannelGroup_Stop (IntPtr channelgroup);
2919 [DllImport(VERSION.dll)]
2920 private static extern RESULT FMOD5_ChannelGroup_SetPaused (IntPtr channelgroup, bool paused);
2921 [DllImport(VERSION.dll)]
2922 private static extern RESULT FMOD5_ChannelGroup_GetPaused (IntPtr channelgroup, out bool paused);
2923 [DllImport(VERSION.dll)]
2924 private static extern RESULT FMOD5_ChannelGroup_SetVolume (IntPtr channelgroup, float volume);
2925 [DllImport(VERSION.dll)]
2926 private static extern RESULT FMOD5_ChannelGroup_GetVolume (IntPtr channelgroup, out float volume);
2927 [DllImport(VERSION.dll)]
2928 private static extern RESULT FMOD5_ChannelGroup_SetVolumeRamp (IntPtr channelgroup, bool ramp);
2929 [DllImport(VERSION.dll)]
2930 private static extern RESULT FMOD5_ChannelGroup_GetVolumeRamp (IntPtr channelgroup, out bool ramp);
2931 [DllImport(VERSION.dll)]
2932 private static extern RESULT FMOD5_ChannelGroup_GetAudibility (IntPtr channelgroup, out float audibility);
2933 [DllImport(VERSION.dll)]
2934 private static extern RESULT FMOD5_ChannelGroup_SetPitch (IntPtr channelgroup, float pitch);
2935 [DllImport(VERSION.dll)]
2936 private static extern RESULT FMOD5_ChannelGroup_GetPitch (IntPtr channelgroup, out float pitch);
2937 [DllImport(VERSION.dll)]
2938 private static extern RESULT FMOD5_ChannelGroup_SetMute (IntPtr channelgroup, bool mute);
2939 [DllImport(VERSION.dll)]
2940 private static extern RESULT FMOD5_ChannelGroup_GetMute (IntPtr channelgroup, out bool mute);
2941 [DllImport(VERSION.dll)]
2942 private static extern RESULT FMOD5_ChannelGroup_SetReverbProperties (IntPtr channelgroup, int instance, float wet);
2943 [DllImport(VERSION.dll)]
2944 private static extern RESULT FMOD5_ChannelGroup_GetReverbProperties (IntPtr channelgroup, int instance, out float wet);
2945 [DllImport(VERSION.dll)]
2946 private static extern RESULT FMOD5_ChannelGroup_SetLowPassGain (IntPtr channelgroup, float gain);
2947 [DllImport(VERSION.dll)]
2948 private static extern RESULT FMOD5_ChannelGroup_GetLowPassGain (IntPtr channelgroup, out float gain);
2949 [DllImport(VERSION.dll)]
2950 private static extern RESULT FMOD5_ChannelGroup_SetMode (IntPtr channelgroup, MODE mode);
2951 [DllImport(VERSION.dll)]
2952 private static extern RESULT FMOD5_ChannelGroup_GetMode (IntPtr channelgroup, out MODE mode);
2953 [DllImport(VERSION.dll)]
2954 private static extern RESULT FMOD5_ChannelGroup_SetCallback (IntPtr channelgroup, CHANNELCONTROL_CALLBACK callback);
2955 [DllImport(VERSION.dll)]
2956 private static extern RESULT FMOD5_ChannelGroup_IsPlaying (IntPtr channelgroup, out bool isplaying);
2957 [DllImport(VERSION.dll)]
2958 private static extern RESULT FMOD5_ChannelGroup_SetPan (IntPtr channelgroup, float pan);
2959 [DllImport(VERSION.dll)]
2960 private static extern RESULT FMOD5_ChannelGroup_SetMixLevelsOutput (IntPtr channelgroup, float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright);
2961 [DllImport(VERSION.dll)]
2962 private static extern RESULT FMOD5_ChannelGroup_SetMixLevelsInput (IntPtr channelgroup, float[] levels, int numlevels);
2963 [DllImport(VERSION.dll)]
2964 private static extern RESULT FMOD5_ChannelGroup_SetMixMatrix (IntPtr channelgroup, float[] matrix, int outchannels, int inchannels, int inchannel_hop);
2965 [DllImport(VERSION.dll)]
2966 private static extern RESULT FMOD5_ChannelGroup_GetMixMatrix (IntPtr channelgroup, float[] matrix, out int outchannels, out int inchannels, int inchannel_hop);
2967 [DllImport(VERSION.dll)]
2968 private static extern RESULT FMOD5_ChannelGroup_GetDSPClock (IntPtr channelgroup, out ulong dspclock, out ulong parentclock);
2969 [DllImport(VERSION.dll)]
2970 private static extern RESULT FMOD5_ChannelGroup_SetDelay (IntPtr channelgroup, ulong dspclock_start, ulong dspclock_end, bool stopchannels);
2971 [DllImport(VERSION.dll)]
2972 private static extern RESULT FMOD5_ChannelGroup_GetDelay (IntPtr channelgroup, out ulong dspclock_start, out ulong dspclock_end, IntPtr zero);
2973 [DllImport(VERSION.dll)]
2974 private static extern RESULT FMOD5_ChannelGroup_GetDelay (IntPtr channelgroup, out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels);
2975 [DllImport(VERSION.dll)]
2976 private static extern RESULT FMOD5_ChannelGroup_AddFadePoint (IntPtr channelgroup, ulong dspclock, float volume);
2977 [DllImport(VERSION.dll)]
2978 private static extern RESULT FMOD5_ChannelGroup_SetFadePointRamp (IntPtr channelgroup, ulong dspclock, float volume);
2979 [DllImport(VERSION.dll)]
2980 private static extern RESULT FMOD5_ChannelGroup_RemoveFadePoints (IntPtr channelgroup, ulong dspclock_start, ulong dspclock_end);
2981 [DllImport(VERSION.dll)]
2982 private static extern RESULT FMOD5_ChannelGroup_GetFadePoints (IntPtr channelgroup, ref uint numpoints, ulong[] point_dspclock, float[] point_volume);
2983 [DllImport(VERSION.dll)]
2984 private static extern RESULT FMOD5_ChannelGroup_GetDSP (IntPtr channelgroup, int index, out IntPtr dsp);
2985 [DllImport(VERSION.dll)]
2986 private static extern RESULT FMOD5_ChannelGroup_AddDSP (IntPtr channelgroup, int index, IntPtr dsp);
2987 [DllImport(VERSION.dll)]
2988 private static extern RESULT FMOD5_ChannelGroup_RemoveDSP (IntPtr channelgroup, IntPtr dsp);
2989 [DllImport(VERSION.dll)]
2990 private static extern RESULT FMOD5_ChannelGroup_GetNumDSPs (IntPtr channelgroup, out int numdsps);
2991 [DllImport(VERSION.dll)]
2992 private static extern RESULT FMOD5_ChannelGroup_SetDSPIndex (IntPtr channelgroup, IntPtr dsp, int index);
2993 [DllImport(VERSION.dll)]
2994 private static extern RESULT FMOD5_ChannelGroup_GetDSPIndex (IntPtr channelgroup, IntPtr dsp, out int index);
2995 [DllImport(VERSION.dll)]
2996 private static extern RESULT FMOD5_ChannelGroup_Set3DAttributes (IntPtr channelgroup, ref VECTOR pos, ref VECTOR vel);
2997 [DllImport(VERSION.dll)]
2998 private static extern RESULT FMOD5_ChannelGroup_Get3DAttributes (IntPtr channelgroup, out VECTOR pos, out VECTOR vel);
2999 [DllImport(VERSION.dll)]
3000 private static extern RESULT FMOD5_ChannelGroup_Set3DMinMaxDistance (IntPtr channelgroup, float mindistance, float maxdistance);
3001 [DllImport(VERSION.dll)]
3002 private static extern RESULT FMOD5_ChannelGroup_Get3DMinMaxDistance (IntPtr channelgroup, out float mindistance, out float maxdistance);
3003 [DllImport(VERSION.dll)]
3004 private static extern RESULT FMOD5_ChannelGroup_Set3DConeSettings (IntPtr channelgroup, float insideconeangle, float outsideconeangle, float outsidevolume);
3005 [DllImport(VERSION.dll)]
3006 private static extern RESULT FMOD5_ChannelGroup_Get3DConeSettings (IntPtr channelgroup, out float insideconeangle, out float outsideconeangle, out float outsidevolume);
3007 [DllImport(VERSION.dll)]
3008 private static extern RESULT FMOD5_ChannelGroup_Set3DConeOrientation(IntPtr channelgroup, ref VECTOR orientation);
3009 [DllImport(VERSION.dll)]
3010 private static extern RESULT FMOD5_ChannelGroup_Get3DConeOrientation(IntPtr channelgroup, out VECTOR orientation);
3011 [DllImport(VERSION.dll)]
3012 private static extern RESULT FMOD5_ChannelGroup_Set3DCustomRolloff (IntPtr channelgroup, ref VECTOR points, int numpoints);
3013 [DllImport(VERSION.dll)]
3014 private static extern RESULT FMOD5_ChannelGroup_Get3DCustomRolloff (IntPtr channelgroup, out IntPtr points, out int numpoints);
3015 [DllImport(VERSION.dll)]
3016 private static extern RESULT FMOD5_ChannelGroup_Set3DOcclusion (IntPtr channelgroup, float directocclusion, float reverbocclusion);
3017 [DllImport(VERSION.dll)]
3018 private static extern RESULT FMOD5_ChannelGroup_Get3DOcclusion (IntPtr channelgroup, out float directocclusion, out float reverbocclusion);
3019 [DllImport(VERSION.dll)]
3020 private static extern RESULT FMOD5_ChannelGroup_Set3DSpread (IntPtr channelgroup, float angle);
3021 [DllImport(VERSION.dll)]
3022 private static extern RESULT FMOD5_ChannelGroup_Get3DSpread (IntPtr channelgroup, out float angle);
3023 [DllImport(VERSION.dll)]
3024 private static extern RESULT FMOD5_ChannelGroup_Set3DLevel (IntPtr channelgroup, float level);
3025 [DllImport(VERSION.dll)]
3026 private static extern RESULT FMOD5_ChannelGroup_Get3DLevel (IntPtr channelgroup, out float level);
3027 [DllImport(VERSION.dll)]
3028 private static extern RESULT FMOD5_ChannelGroup_Set3DDopplerLevel (IntPtr channelgroup, float level);
3029 [DllImport(VERSION.dll)]
3030 private static extern RESULT FMOD5_ChannelGroup_Get3DDopplerLevel (IntPtr channelgroup, out float level);
3031 [DllImport(VERSION.dll)]
3032 private static extern RESULT FMOD5_ChannelGroup_Set3DDistanceFilter (IntPtr channelgroup, bool custom, float customLevel, float centerFreq);
3033 [DllImport(VERSION.dll)]
3034 private static extern RESULT FMOD5_ChannelGroup_Get3DDistanceFilter (IntPtr channelgroup, out bool custom, out float customLevel, out float centerFreq);
3035 [DllImport(VERSION.dll)]
3036 private static extern RESULT FMOD5_ChannelGroup_SetUserData (IntPtr channelgroup, IntPtr userdata);
3037 [DllImport(VERSION.dll)]
3038 private static extern RESULT FMOD5_ChannelGroup_GetUserData (IntPtr channelgroup, out IntPtr userdata);
3039 #endregion
3040
3041 #region wrapperinternal
3042
3043 public IntPtr handle;
3044
3045 public ChannelGroup(IntPtr ptr) { this.handle = ptr; }
3046 public bool hasHandle() { return this.handle != IntPtr.Zero; }
3047 public void clearHandle() { this.handle = IntPtr.Zero; }
3048
3049 #endregion
3050 }
3051
3052 /*
3053 'SoundGroup' API
3054 */
3055 public struct SoundGroup
3056 {
3057 public RESULT release()
3058 {
3059 return FMOD5_SoundGroup_Release(this.handle);
3060 }
3061
3062 public RESULT getSystemObject(out System system)
3063 {
3064 return FMOD5_SoundGroup_GetSystemObject(this.handle, out system.handle);
3065 }
3066
3067 // SoundGroup control functions.
3068 public RESULT setMaxAudible(int maxaudible)
3069 {
3070 return FMOD5_SoundGroup_SetMaxAudible(this.handle, maxaudible);
3071 }
3072 public RESULT getMaxAudible(out int maxaudible)
3073 {
3074 return FMOD5_SoundGroup_GetMaxAudible(this.handle, out maxaudible);
3075 }
3076 public RESULT setMaxAudibleBehavior(SOUNDGROUP_BEHAVIOR behavior)
3077 {
3078 return FMOD5_SoundGroup_SetMaxAudibleBehavior(this.handle, behavior);
3079 }
3080 public RESULT getMaxAudibleBehavior(out SOUNDGROUP_BEHAVIOR behavior)
3081 {
3082 return FMOD5_SoundGroup_GetMaxAudibleBehavior(this.handle, out behavior);
3083 }
3084 public RESULT setMuteFadeSpeed(float speed)
3085 {
3086 return FMOD5_SoundGroup_SetMuteFadeSpeed(this.handle, speed);
3087 }
3088 public RESULT getMuteFadeSpeed(out float speed)
3089 {
3090 return FMOD5_SoundGroup_GetMuteFadeSpeed(this.handle, out speed);
3091 }
3092 public RESULT setVolume(float volume)
3093 {
3094 return FMOD5_SoundGroup_SetVolume(this.handle, volume);
3095 }
3096 public RESULT getVolume(out float volume)
3097 {
3098 return FMOD5_SoundGroup_GetVolume(this.handle, out volume);
3099 }
3100 public RESULT stop()
3101 {
3102 return FMOD5_SoundGroup_Stop(this.handle);
3103 }
3104
3105 // Information only functions.
3106 public RESULT getName(out string name, int namelen)
3107 {
3108 IntPtr stringMem = Marshal.AllocHGlobal(namelen);
3109
3110 RESULT result = FMOD5_SoundGroup_GetName(this.handle, stringMem, namelen);
3111 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
3112 {
3113 name = encoder.stringFromNative(stringMem);
3114 }
3115 Marshal.FreeHGlobal(stringMem);
3116
3117 return result;
3118 }
3119 public RESULT getNumSounds(out int numsounds)
3120 {
3121 return FMOD5_SoundGroup_GetNumSounds(this.handle, out numsounds);
3122 }
3123 public RESULT getSound(int index, out Sound sound)
3124 {
3125 return FMOD5_SoundGroup_GetSound(this.handle, index, out sound.handle);
3126 }
3127 public RESULT getNumPlaying(out int numplaying)
3128 {
3129 return FMOD5_SoundGroup_GetNumPlaying(this.handle, out numplaying);
3130 }
3131
3132 // Userdata set/get.
3133 public RESULT setUserData(IntPtr userdata)
3134 {
3135 return FMOD5_SoundGroup_SetUserData(this.handle, userdata);
3136 }
3137 public RESULT getUserData(out IntPtr userdata)
3138 {
3139 return FMOD5_SoundGroup_GetUserData(this.handle, out userdata);
3140 }
3141
3142 #region importfunctions
3143 [DllImport(VERSION.dll)]
3144 private static extern RESULT FMOD5_SoundGroup_Release (IntPtr soundgroup);
3145 [DllImport(VERSION.dll)]
3146 private static extern RESULT FMOD5_SoundGroup_GetSystemObject (IntPtr soundgroup, out IntPtr system);
3147 [DllImport(VERSION.dll)]
3148 private static extern RESULT FMOD5_SoundGroup_SetMaxAudible (IntPtr soundgroup, int maxaudible);
3149 [DllImport(VERSION.dll)]
3150 private static extern RESULT FMOD5_SoundGroup_GetMaxAudible (IntPtr soundgroup, out int maxaudible);
3151 [DllImport(VERSION.dll)]
3152 private static extern RESULT FMOD5_SoundGroup_SetMaxAudibleBehavior (IntPtr soundgroup, SOUNDGROUP_BEHAVIOR behavior);
3153 [DllImport(VERSION.dll)]
3154 private static extern RESULT FMOD5_SoundGroup_GetMaxAudibleBehavior (IntPtr soundgroup, out SOUNDGROUP_BEHAVIOR behavior);
3155 [DllImport(VERSION.dll)]
3156 private static extern RESULT FMOD5_SoundGroup_SetMuteFadeSpeed (IntPtr soundgroup, float speed);
3157 [DllImport(VERSION.dll)]
3158 private static extern RESULT FMOD5_SoundGroup_GetMuteFadeSpeed (IntPtr soundgroup, out float speed);
3159 [DllImport(VERSION.dll)]
3160 private static extern RESULT FMOD5_SoundGroup_SetVolume (IntPtr soundgroup, float volume);
3161 [DllImport(VERSION.dll)]
3162 private static extern RESULT FMOD5_SoundGroup_GetVolume (IntPtr soundgroup, out float volume);
3163 [DllImport(VERSION.dll)]
3164 private static extern RESULT FMOD5_SoundGroup_Stop (IntPtr soundgroup);
3165 [DllImport(VERSION.dll)]
3166 private static extern RESULT FMOD5_SoundGroup_GetName (IntPtr soundgroup, IntPtr name, int namelen);
3167 [DllImport(VERSION.dll)]
3168 private static extern RESULT FMOD5_SoundGroup_GetNumSounds (IntPtr soundgroup, out int numsounds);
3169 [DllImport(VERSION.dll)]
3170 private static extern RESULT FMOD5_SoundGroup_GetSound (IntPtr soundgroup, int index, out IntPtr sound);
3171 [DllImport(VERSION.dll)]
3172 private static extern RESULT FMOD5_SoundGroup_GetNumPlaying (IntPtr soundgroup, out int numplaying);
3173 [DllImport(VERSION.dll)]
3174 private static extern RESULT FMOD5_SoundGroup_SetUserData (IntPtr soundgroup, IntPtr userdata);
3175 [DllImport(VERSION.dll)]
3176 private static extern RESULT FMOD5_SoundGroup_GetUserData (IntPtr soundgroup, out IntPtr userdata);
3177 #endregion
3178
3179 #region wrapperinternal
3180
3181 public IntPtr handle;
3182
3183 public SoundGroup(IntPtr ptr) { this.handle = ptr; }
3184 public bool hasHandle() { return this.handle != IntPtr.Zero; }
3185 public void clearHandle() { this.handle = IntPtr.Zero; }
3186
3187 #endregion
3188 }
3189
3190 /*
3191 'DSP' API
3192 */
3193 public struct DSP
3194 {
3195 public RESULT release()
3196 {
3197 return FMOD5_DSP_Release(this.handle);
3198 }
3199 public RESULT getSystemObject(out System system)
3200 {
3201 return FMOD5_DSP_GetSystemObject(this.handle, out system.handle);
3202 }
3203
3204 // Connection / disconnection / input and output enumeration.
3205 public RESULT addInput(DSP input)
3206 {
3207 return FMOD5_DSP_AddInput(this.handle, input.handle, IntPtr.Zero, DSPCONNECTION_TYPE.STANDARD);
3208 }
3209 public RESULT addInput(DSP input, out DSPConnection connection, DSPCONNECTION_TYPE type = DSPCONNECTION_TYPE.STANDARD)
3210 {
3211 return FMOD5_DSP_AddInput(this.handle, input.handle, out connection.handle, type);
3212 }
3213 public RESULT disconnectFrom(DSP target, DSPConnection connection)
3214 {
3215 return FMOD5_DSP_DisconnectFrom(this.handle, target.handle, connection.handle);
3216 }
3217 public RESULT disconnectAll(bool inputs, bool outputs)
3218 {
3219 return FMOD5_DSP_DisconnectAll(this.handle, inputs, outputs);
3220 }
3221 public RESULT getNumInputs(out int numinputs)
3222 {
3223 return FMOD5_DSP_GetNumInputs(this.handle, out numinputs);
3224 }
3225 public RESULT getNumOutputs(out int numoutputs)
3226 {
3227 return FMOD5_DSP_GetNumOutputs(this.handle, out numoutputs);
3228 }
3229 public RESULT getInput(int index, out DSP input, out DSPConnection inputconnection)
3230 {
3231 return FMOD5_DSP_GetInput(this.handle, index, out input.handle, out inputconnection.handle);
3232 }
3233 public RESULT getOutput(int index, out DSP output, out DSPConnection outputconnection)
3234 {
3235 return FMOD5_DSP_GetOutput(this.handle, index, out output.handle, out outputconnection.handle);
3236 }
3237
3238 // DSP unit control.
3239 public RESULT setActive(bool active)
3240 {
3241 return FMOD5_DSP_SetActive(this.handle, active);
3242 }
3243 public RESULT getActive(out bool active)
3244 {
3245 return FMOD5_DSP_GetActive(this.handle, out active);
3246 }
3247 public RESULT setBypass(bool bypass)
3248 {
3249 return FMOD5_DSP_SetBypass(this.handle, bypass);
3250 }
3251 public RESULT getBypass(out bool bypass)
3252 {
3253 return FMOD5_DSP_GetBypass(this.handle, out bypass);
3254 }
3255 public RESULT setWetDryMix(float prewet, float postwet, float dry)
3256 {
3257 return FMOD5_DSP_SetWetDryMix(this.handle, prewet, postwet, dry);
3258 }
3259 public RESULT getWetDryMix(out float prewet, out float postwet, out float dry)
3260 {
3261 return FMOD5_DSP_GetWetDryMix(this.handle, out prewet, out postwet, out dry);
3262 }
3263 public RESULT setChannelFormat(CHANNELMASK channelmask, int numchannels, SPEAKERMODE source_speakermode)
3264 {
3265 return FMOD5_DSP_SetChannelFormat(this.handle, channelmask, numchannels, source_speakermode);
3266 }
3267 public RESULT getChannelFormat(out CHANNELMASK channelmask, out int numchannels, out SPEAKERMODE source_speakermode)
3268 {
3269 return FMOD5_DSP_GetChannelFormat(this.handle, out channelmask, out numchannels, out source_speakermode);
3270 }
3271 public RESULT getOutputChannelFormat(CHANNELMASK inmask, int inchannels, SPEAKERMODE inspeakermode, out CHANNELMASK outmask, out int outchannels, out SPEAKERMODE outspeakermode)
3272 {
3273 return FMOD5_DSP_GetOutputChannelFormat(this.handle, inmask, inchannels, inspeakermode, out outmask, out outchannels, out outspeakermode);
3274 }
3275 public RESULT reset()
3276 {
3277 return FMOD5_DSP_Reset(this.handle);
3278 }
3279
3280 // DSP parameter control.
3281 public RESULT setParameterFloat(int index, float value)
3282 {
3283 return FMOD5_DSP_SetParameterFloat(this.handle, index, value);
3284 }
3285 public RESULT setParameterInt(int index, int value)
3286 {
3287 return FMOD5_DSP_SetParameterInt(this.handle, index, value);
3288 }
3289 public RESULT setParameterBool(int index, bool value)
3290 {
3291 return FMOD5_DSP_SetParameterBool(this.handle, index, value);
3292 }
3293 public RESULT setParameterData(int index, byte[] data)
3294 {
3295 return FMOD5_DSP_SetParameterData(this.handle, index, Marshal.UnsafeAddrOfPinnedArrayElement(data, 0), (uint)data.Length);
3296 }
3297 public RESULT getParameterFloat(int index, out float value)
3298 {
3299 return FMOD5_DSP_GetParameterFloat(this.handle, index, out value, IntPtr.Zero, 0);
3300 }
3301 public RESULT getParameterInt(int index, out int value)
3302 {
3303 return FMOD5_DSP_GetParameterInt(this.handle, index, out value, IntPtr.Zero, 0);
3304 }
3305 public RESULT getParameterBool(int index, out bool value)
3306 {
3307 return FMOD5_DSP_GetParameterBool(this.handle, index, out value, IntPtr.Zero, 0);
3308 }
3309 public RESULT getParameterData(int index, out IntPtr data, out uint length)
3310 {
3311 return FMOD5_DSP_GetParameterData(this.handle, index, out data, out length, IntPtr.Zero, 0);
3312 }
3313 public RESULT getNumParameters(out int numparams)
3314 {
3315 return FMOD5_DSP_GetNumParameters(this.handle, out numparams);
3316 }
3317 public RESULT getParameterInfo(int index, out DSP_PARAMETER_DESC desc)
3318 {
3319 IntPtr descPtr;
3320 RESULT result = FMOD5_DSP_GetParameterInfo(this.handle, index, out descPtr);
3321 desc = (DSP_PARAMETER_DESC)MarshalHelper.PtrToStructure(descPtr, typeof(DSP_PARAMETER_DESC));
3322 return result;
3323 }
3324 public RESULT getDataParameterIndex(int datatype, out int index)
3325 {
3326 return FMOD5_DSP_GetDataParameterIndex(this.handle, datatype, out index);
3327 }
3328 public RESULT showConfigDialog(IntPtr hwnd, bool show)
3329 {
3330 return FMOD5_DSP_ShowConfigDialog(this.handle, hwnd, show);
3331 }
3332
3333 // DSP attributes.
3334 public RESULT getInfo(out string name, out uint version, out int channels, out int configwidth, out int configheight)
3335 {
3336 IntPtr nameMem = Marshal.AllocHGlobal(32);
3337
3338 RESULT result = FMOD5_DSP_GetInfo(this.handle, nameMem, out version, out channels, out configwidth, out configheight);
3339 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
3340 {
3341 name = encoder.stringFromNative(nameMem);
3342 }
3343 Marshal.FreeHGlobal(nameMem);
3344 return result;
3345 }
3346 public RESULT getInfo(out uint version, out int channels, out int configwidth, out int configheight)
3347 {
3348 return FMOD5_DSP_GetInfo(this.handle, IntPtr.Zero, out version, out channels, out configwidth, out configheight); ;
3349 }
3350 public RESULT getType(out DSP_TYPE type)
3351 {
3352 return FMOD5_DSP_GetType(this.handle, out type);
3353 }
3354 public RESULT getIdle(out bool idle)
3355 {
3356 return FMOD5_DSP_GetIdle(this.handle, out idle);
3357 }
3358
3359 // Userdata set/get.
3360 public RESULT setUserData(IntPtr userdata)
3361 {
3362 return FMOD5_DSP_SetUserData(this.handle, userdata);
3363 }
3364 public RESULT getUserData(out IntPtr userdata)
3365 {
3366 return FMOD5_DSP_GetUserData(this.handle, out userdata);
3367 }
3368
3369 // Metering.
3370 public RESULT setMeteringEnabled(bool inputEnabled, bool outputEnabled)
3371 {
3372 return FMOD5_DSP_SetMeteringEnabled(this.handle, inputEnabled, outputEnabled);
3373 }
3374 public RESULT getMeteringEnabled(out bool inputEnabled, out bool outputEnabled)
3375 {
3376 return FMOD5_DSP_GetMeteringEnabled(this.handle, out inputEnabled, out outputEnabled);
3377 }
3378
3379 public RESULT getMeteringInfo(IntPtr zero, out DSP_METERING_INFO outputInfo)
3380 {
3381 return FMOD5_DSP_GetMeteringInfo(this.handle, zero, out outputInfo);
3382 }
3383 public RESULT getMeteringInfo(out DSP_METERING_INFO inputInfo, IntPtr zero)
3384 {
3385 return FMOD5_DSP_GetMeteringInfo(this.handle, out inputInfo, zero);
3386 }
3387 public RESULT getMeteringInfo(out DSP_METERING_INFO inputInfo, out DSP_METERING_INFO outputInfo)
3388 {
3389 return FMOD5_DSP_GetMeteringInfo(this.handle, out inputInfo, out outputInfo);
3390 }
3391
3392 public RESULT getCPUUsage(out uint exclusive, out uint inclusive)
3393 {
3394 return FMOD5_DSP_GetCPUUsage(this.handle, out exclusive, out inclusive);
3395 }
3396
3397 #region importfunctions
3398 [DllImport(VERSION.dll)]
3399 private static extern RESULT FMOD5_DSP_Release (IntPtr dsp);
3400 [DllImport(VERSION.dll)]
3401 private static extern RESULT FMOD5_DSP_GetSystemObject (IntPtr dsp, out IntPtr system);
3402 [DllImport(VERSION.dll)]
3403 private static extern RESULT FMOD5_DSP_AddInput (IntPtr dsp, IntPtr input, IntPtr zero, DSPCONNECTION_TYPE type);
3404 [DllImport(VERSION.dll)]
3405 private static extern RESULT FMOD5_DSP_AddInput (IntPtr dsp, IntPtr input, out IntPtr connection, DSPCONNECTION_TYPE type);
3406 [DllImport(VERSION.dll)]
3407 private static extern RESULT FMOD5_DSP_DisconnectFrom (IntPtr dsp, IntPtr target, IntPtr connection);
3408 [DllImport(VERSION.dll)]
3409 private static extern RESULT FMOD5_DSP_DisconnectAll (IntPtr dsp, bool inputs, bool outputs);
3410 [DllImport(VERSION.dll)]
3411 private static extern RESULT FMOD5_DSP_GetNumInputs (IntPtr dsp, out int numinputs);
3412 [DllImport(VERSION.dll)]
3413 private static extern RESULT FMOD5_DSP_GetNumOutputs (IntPtr dsp, out int numoutputs);
3414 [DllImport(VERSION.dll)]
3415 private static extern RESULT FMOD5_DSP_GetInput (IntPtr dsp, int index, out IntPtr input, out IntPtr inputconnection);
3416 [DllImport(VERSION.dll)]
3417 private static extern RESULT FMOD5_DSP_GetOutput (IntPtr dsp, int index, out IntPtr output, out IntPtr outputconnection);
3418 [DllImport(VERSION.dll)]
3419 private static extern RESULT FMOD5_DSP_SetActive (IntPtr dsp, bool active);
3420 [DllImport(VERSION.dll)]
3421 private static extern RESULT FMOD5_DSP_GetActive (IntPtr dsp, out bool active);
3422 [DllImport(VERSION.dll)]
3423 private static extern RESULT FMOD5_DSP_SetBypass (IntPtr dsp, bool bypass);
3424 [DllImport(VERSION.dll)]
3425 private static extern RESULT FMOD5_DSP_GetBypass (IntPtr dsp, out bool bypass);
3426 [DllImport(VERSION.dll)]
3427 private static extern RESULT FMOD5_DSP_SetWetDryMix (IntPtr dsp, float prewet, float postwet, float dry);
3428 [DllImport(VERSION.dll)]
3429 private static extern RESULT FMOD5_DSP_GetWetDryMix (IntPtr dsp, out float prewet, out float postwet, out float dry);
3430 [DllImport(VERSION.dll)]
3431 private static extern RESULT FMOD5_DSP_SetChannelFormat (IntPtr dsp, CHANNELMASK channelmask, int numchannels, SPEAKERMODE source_speakermode);
3432 [DllImport(VERSION.dll)]
3433 private static extern RESULT FMOD5_DSP_GetChannelFormat (IntPtr dsp, out CHANNELMASK channelmask, out int numchannels, out SPEAKERMODE source_speakermode);
3434 [DllImport(VERSION.dll)]
3435 private static extern RESULT FMOD5_DSP_GetOutputChannelFormat (IntPtr dsp, CHANNELMASK inmask, int inchannels, SPEAKERMODE inspeakermode, out CHANNELMASK outmask, out int outchannels, out SPEAKERMODE outspeakermode);
3436 [DllImport(VERSION.dll)]
3437 private static extern RESULT FMOD5_DSP_Reset (IntPtr dsp);
3438 [DllImport(VERSION.dll)]
3439 private static extern RESULT FMOD5_DSP_SetParameterFloat (IntPtr dsp, int index, float value);
3440 [DllImport(VERSION.dll)]
3441 private static extern RESULT FMOD5_DSP_SetParameterInt (IntPtr dsp, int index, int value);
3442 [DllImport(VERSION.dll)]
3443 private static extern RESULT FMOD5_DSP_SetParameterBool (IntPtr dsp, int index, bool value);
3444 [DllImport(VERSION.dll)]
3445 private static extern RESULT FMOD5_DSP_SetParameterData (IntPtr dsp, int index, IntPtr data, uint length);
3446 [DllImport(VERSION.dll)]
3447 private static extern RESULT FMOD5_DSP_GetParameterFloat (IntPtr dsp, int index, out float value, IntPtr valuestr, int valuestrlen);
3448 [DllImport(VERSION.dll)]
3449 private static extern RESULT FMOD5_DSP_GetParameterInt (IntPtr dsp, int index, out int value, IntPtr valuestr, int valuestrlen);
3450 [DllImport(VERSION.dll)]
3451 private static extern RESULT FMOD5_DSP_GetParameterBool (IntPtr dsp, int index, out bool value, IntPtr valuestr, int valuestrlen);
3452 [DllImport(VERSION.dll)]
3453 private static extern RESULT FMOD5_DSP_GetParameterData (IntPtr dsp, int index, out IntPtr data, out uint length, IntPtr valuestr, int valuestrlen);
3454 [DllImport(VERSION.dll)]
3455 private static extern RESULT FMOD5_DSP_GetNumParameters (IntPtr dsp, out int numparams);
3456 [DllImport(VERSION.dll)]
3457 private static extern RESULT FMOD5_DSP_GetParameterInfo (IntPtr dsp, int index, out IntPtr desc);
3458 [DllImport(VERSION.dll)]
3459 private static extern RESULT FMOD5_DSP_GetDataParameterIndex (IntPtr dsp, int datatype, out int index);
3460 [DllImport(VERSION.dll)]
3461 private static extern RESULT FMOD5_DSP_ShowConfigDialog (IntPtr dsp, IntPtr hwnd, bool show);
3462 [DllImport(VERSION.dll)]
3463 private static extern RESULT FMOD5_DSP_GetInfo (IntPtr dsp, IntPtr name, out uint version, out int channels, out int configwidth, out int configheight);
3464 [DllImport(VERSION.dll)]
3465 private static extern RESULT FMOD5_DSP_GetType (IntPtr dsp, out DSP_TYPE type);
3466 [DllImport(VERSION.dll)]
3467 private static extern RESULT FMOD5_DSP_GetIdle (IntPtr dsp, out bool idle);
3468 [DllImport(VERSION.dll)]
3469 private static extern RESULT FMOD5_DSP_SetUserData (IntPtr dsp, IntPtr userdata);
3470 [DllImport(VERSION.dll)]
3471 private static extern RESULT FMOD5_DSP_GetUserData (IntPtr dsp, out IntPtr userdata);
3472 [DllImport(VERSION.dll)]
3473 public static extern RESULT FMOD5_DSP_SetMeteringEnabled (IntPtr dsp, bool inputEnabled, bool outputEnabled);
3474 [DllImport(VERSION.dll)]
3475 public static extern RESULT FMOD5_DSP_GetMeteringEnabled (IntPtr dsp, out bool inputEnabled, out bool outputEnabled);
3476 [DllImport(VERSION.dll)]
3477 public static extern RESULT FMOD5_DSP_GetMeteringInfo (IntPtr dsp, IntPtr zero, out DSP_METERING_INFO outputInfo);
3478 [DllImport(VERSION.dll)]
3479 public static extern RESULT FMOD5_DSP_GetMeteringInfo (IntPtr dsp, out DSP_METERING_INFO inputInfo, IntPtr zero);
3480 [DllImport(VERSION.dll)]
3481 public static extern RESULT FMOD5_DSP_GetMeteringInfo (IntPtr dsp, out DSP_METERING_INFO inputInfo, out DSP_METERING_INFO outputInfo);
3482 [DllImport(VERSION.dll)]
3483 public static extern RESULT FMOD5_DSP_GetCPUUsage (IntPtr dsp, out uint exclusive, out uint inclusive);
3484 #endregion
3485
3486 #region wrapperinternal
3487
3488 public IntPtr handle;
3489
3490 public DSP(IntPtr ptr) { this.handle = ptr; }
3491 public bool hasHandle() { return this.handle != IntPtr.Zero; }
3492 public void clearHandle() { this.handle = IntPtr.Zero; }
3493
3494 #endregion
3495 }
3496
3497 /*
3498 'DSPConnection' API
3499 */
3500 public struct DSPConnection
3501 {
3502 public RESULT getInput(out DSP input)
3503 {
3504 return FMOD5_DSPConnection_GetInput(this.handle, out input.handle);
3505 }
3506 public RESULT getOutput(out DSP output)
3507 {
3508 return FMOD5_DSPConnection_GetOutput(this.handle, out output.handle);
3509 }
3510 public RESULT setMix(float volume)
3511 {
3512 return FMOD5_DSPConnection_SetMix(this.handle, volume);
3513 }
3514 public RESULT getMix(out float volume)
3515 {
3516 return FMOD5_DSPConnection_GetMix(this.handle, out volume);
3517 }
3518 public RESULT setMixMatrix(float[] matrix, int outchannels, int inchannels, int inchannel_hop = 0)
3519 {
3520 return FMOD5_DSPConnection_SetMixMatrix(this.handle, matrix, outchannels, inchannels, inchannel_hop);
3521 }
3522 public RESULT getMixMatrix(float[] matrix, out int outchannels, out int inchannels, int inchannel_hop = 0)
3523 {
3524 return FMOD5_DSPConnection_GetMixMatrix(this.handle, matrix, out outchannels, out inchannels, inchannel_hop);
3525 }
3526 public RESULT getType(out DSPCONNECTION_TYPE type)
3527 {
3528 return FMOD5_DSPConnection_GetType(this.handle, out type);
3529 }
3530
3531 // Userdata set/get.
3532 public RESULT setUserData(IntPtr userdata)
3533 {
3534 return FMOD5_DSPConnection_SetUserData(this.handle, userdata);
3535 }
3536 public RESULT getUserData(out IntPtr userdata)
3537 {
3538 return FMOD5_DSPConnection_GetUserData(this.handle, out userdata);
3539 }
3540
3541 #region importfunctions
3542 [DllImport(VERSION.dll)]
3543 private static extern RESULT FMOD5_DSPConnection_GetInput (IntPtr dspconnection, out IntPtr input);
3544 [DllImport(VERSION.dll)]
3545 private static extern RESULT FMOD5_DSPConnection_GetOutput (IntPtr dspconnection, out IntPtr output);
3546 [DllImport(VERSION.dll)]
3547 private static extern RESULT FMOD5_DSPConnection_SetMix (IntPtr dspconnection, float volume);
3548 [DllImport(VERSION.dll)]
3549 private static extern RESULT FMOD5_DSPConnection_GetMix (IntPtr dspconnection, out float volume);
3550 [DllImport(VERSION.dll)]
3551 private static extern RESULT FMOD5_DSPConnection_SetMixMatrix (IntPtr dspconnection, float[] matrix, int outchannels, int inchannels, int inchannel_hop);
3552 [DllImport(VERSION.dll)]
3553 private static extern RESULT FMOD5_DSPConnection_GetMixMatrix (IntPtr dspconnection, float[] matrix, out int outchannels, out int inchannels, int inchannel_hop);
3554 [DllImport(VERSION.dll)]
3555 private static extern RESULT FMOD5_DSPConnection_GetType (IntPtr dspconnection, out DSPCONNECTION_TYPE type);
3556 [DllImport(VERSION.dll)]
3557 private static extern RESULT FMOD5_DSPConnection_SetUserData (IntPtr dspconnection, IntPtr userdata);
3558 [DllImport(VERSION.dll)]
3559 private static extern RESULT FMOD5_DSPConnection_GetUserData (IntPtr dspconnection, out IntPtr userdata);
3560 #endregion
3561
3562 #region wrapperinternal
3563
3564 public IntPtr handle;
3565
3566 public DSPConnection(IntPtr ptr) { this.handle = ptr; }
3567 public bool hasHandle() { return this.handle != IntPtr.Zero; }
3568 public void clearHandle() { this.handle = IntPtr.Zero; }
3569
3570 #endregion
3571 }
3572
3573 /*
3574 'Geometry' API
3575 */
3576 public struct Geometry
3577 {
3578 public RESULT release()
3579 {
3580 return FMOD5_Geometry_Release(this.handle);
3581 }
3582
3583 // Polygon manipulation.
3584 public RESULT addPolygon(float directocclusion, float reverbocclusion, bool doublesided, int numvertices, VECTOR[] vertices, out int polygonindex)
3585 {
3586 return FMOD5_Geometry_AddPolygon(this.handle, directocclusion, reverbocclusion, doublesided, numvertices, vertices, out polygonindex);
3587 }
3588 public RESULT getNumPolygons(out int numpolygons)
3589 {
3590 return FMOD5_Geometry_GetNumPolygons(this.handle, out numpolygons);
3591 }
3592 public RESULT getMaxPolygons(out int maxpolygons, out int maxvertices)
3593 {
3594 return FMOD5_Geometry_GetMaxPolygons(this.handle, out maxpolygons, out maxvertices);
3595 }
3596 public RESULT getPolygonNumVertices(int index, out int numvertices)
3597 {
3598 return FMOD5_Geometry_GetPolygonNumVertices(this.handle, index, out numvertices);
3599 }
3600 public RESULT setPolygonVertex(int index, int vertexindex, ref VECTOR vertex)
3601 {
3602 return FMOD5_Geometry_SetPolygonVertex(this.handle, index, vertexindex, ref vertex);
3603 }
3604 public RESULT getPolygonVertex(int index, int vertexindex, out VECTOR vertex)
3605 {
3606 return FMOD5_Geometry_GetPolygonVertex(this.handle, index, vertexindex, out vertex);
3607 }
3608 public RESULT setPolygonAttributes(int index, float directocclusion, float reverbocclusion, bool doublesided)
3609 {
3610 return FMOD5_Geometry_SetPolygonAttributes(this.handle, index, directocclusion, reverbocclusion, doublesided);
3611 }
3612 public RESULT getPolygonAttributes(int index, out float directocclusion, out float reverbocclusion, out bool doublesided)
3613 {
3614 return FMOD5_Geometry_GetPolygonAttributes(this.handle, index, out directocclusion, out reverbocclusion, out doublesided);
3615 }
3616
3617 // Object manipulation.
3618 public RESULT setActive(bool active)
3619 {
3620 return FMOD5_Geometry_SetActive(this.handle, active);
3621 }
3622 public RESULT getActive(out bool active)
3623 {
3624 return FMOD5_Geometry_GetActive(this.handle, out active);
3625 }
3626 public RESULT setRotation(ref VECTOR forward, ref VECTOR up)
3627 {
3628 return FMOD5_Geometry_SetRotation(this.handle, ref forward, ref up);
3629 }
3630 public RESULT getRotation(out VECTOR forward, out VECTOR up)
3631 {
3632 return FMOD5_Geometry_GetRotation(this.handle, out forward, out up);
3633 }
3634 public RESULT setPosition(ref VECTOR position)
3635 {
3636 return FMOD5_Geometry_SetPosition(this.handle, ref position);
3637 }
3638 public RESULT getPosition(out VECTOR position)
3639 {
3640 return FMOD5_Geometry_GetPosition(this.handle, out position);
3641 }
3642 public RESULT setScale(ref VECTOR scale)
3643 {
3644 return FMOD5_Geometry_SetScale(this.handle, ref scale);
3645 }
3646 public RESULT getScale(out VECTOR scale)
3647 {
3648 return FMOD5_Geometry_GetScale(this.handle, out scale);
3649 }
3650 public RESULT save(IntPtr data, out int datasize)
3651 {
3652 return FMOD5_Geometry_Save(this.handle, data, out datasize);
3653 }
3654
3655 // Userdata set/get.
3656 public RESULT setUserData(IntPtr userdata)
3657 {
3658 return FMOD5_Geometry_SetUserData(this.handle, userdata);
3659 }
3660 public RESULT getUserData(out IntPtr userdata)
3661 {
3662 return FMOD5_Geometry_GetUserData(this.handle, out userdata);
3663 }
3664
3665 #region importfunctions
3666 [DllImport(VERSION.dll)]
3667 private static extern RESULT FMOD5_Geometry_Release (IntPtr geometry);
3668 [DllImport(VERSION.dll)]
3669 private static extern RESULT FMOD5_Geometry_AddPolygon (IntPtr geometry, float directocclusion, float reverbocclusion, bool doublesided, int numvertices, VECTOR[] vertices, out int polygonindex);
3670 [DllImport(VERSION.dll)]
3671 private static extern RESULT FMOD5_Geometry_GetNumPolygons (IntPtr geometry, out int numpolygons);
3672 [DllImport(VERSION.dll)]
3673 private static extern RESULT FMOD5_Geometry_GetMaxPolygons (IntPtr geometry, out int maxpolygons, out int maxvertices);
3674 [DllImport(VERSION.dll)]
3675 private static extern RESULT FMOD5_Geometry_GetPolygonNumVertices(IntPtr geometry, int index, out int numvertices);
3676 [DllImport(VERSION.dll)]
3677 private static extern RESULT FMOD5_Geometry_SetPolygonVertex (IntPtr geometry, int index, int vertexindex, ref VECTOR vertex);
3678 [DllImport(VERSION.dll)]
3679 private static extern RESULT FMOD5_Geometry_GetPolygonVertex (IntPtr geometry, int index, int vertexindex, out VECTOR vertex);
3680 [DllImport(VERSION.dll)]
3681 private static extern RESULT FMOD5_Geometry_SetPolygonAttributes (IntPtr geometry, int index, float directocclusion, float reverbocclusion, bool doublesided);
3682 [DllImport(VERSION.dll)]
3683 private static extern RESULT FMOD5_Geometry_GetPolygonAttributes (IntPtr geometry, int index, out float directocclusion, out float reverbocclusion, out bool doublesided);
3684 [DllImport(VERSION.dll)]
3685 private static extern RESULT FMOD5_Geometry_SetActive (IntPtr geometry, bool active);
3686 [DllImport(VERSION.dll)]
3687 private static extern RESULT FMOD5_Geometry_GetActive (IntPtr geometry, out bool active);
3688 [DllImport(VERSION.dll)]
3689 private static extern RESULT FMOD5_Geometry_SetRotation (IntPtr geometry, ref VECTOR forward, ref VECTOR up);
3690 [DllImport(VERSION.dll)]
3691 private static extern RESULT FMOD5_Geometry_GetRotation (IntPtr geometry, out VECTOR forward, out VECTOR up);
3692 [DllImport(VERSION.dll)]
3693 private static extern RESULT FMOD5_Geometry_SetPosition (IntPtr geometry, ref VECTOR position);
3694 [DllImport(VERSION.dll)]
3695 private static extern RESULT FMOD5_Geometry_GetPosition (IntPtr geometry, out VECTOR position);
3696 [DllImport(VERSION.dll)]
3697 private static extern RESULT FMOD5_Geometry_SetScale (IntPtr geometry, ref VECTOR scale);
3698 [DllImport(VERSION.dll)]
3699 private static extern RESULT FMOD5_Geometry_GetScale (IntPtr geometry, out VECTOR scale);
3700 [DllImport(VERSION.dll)]
3701 private static extern RESULT FMOD5_Geometry_Save (IntPtr geometry, IntPtr data, out int datasize);
3702 [DllImport(VERSION.dll)]
3703 private static extern RESULT FMOD5_Geometry_SetUserData (IntPtr geometry, IntPtr userdata);
3704 [DllImport(VERSION.dll)]
3705 private static extern RESULT FMOD5_Geometry_GetUserData (IntPtr geometry, out IntPtr userdata);
3706 #endregion
3707
3708 #region wrapperinternal
3709
3710 public IntPtr handle;
3711
3712 public Geometry(IntPtr ptr) { this.handle = ptr; }
3713 public bool hasHandle() { return this.handle != IntPtr.Zero; }
3714 public void clearHandle() { this.handle = IntPtr.Zero; }
3715
3716 #endregion
3717 }
3718
3719 /*
3720 'Reverb3D' API
3721 */
3722 public struct Reverb3D
3723 {
3724 public RESULT release()
3725 {
3726 return FMOD5_Reverb3D_Release(this.handle);
3727 }
3728
3729 // Reverb manipulation.
3730 public RESULT set3DAttributes(ref VECTOR position, float mindistance, float maxdistance)
3731 {
3732 return FMOD5_Reverb3D_Set3DAttributes(this.handle, ref position, mindistance, maxdistance);
3733 }
3734 public RESULT get3DAttributes(ref VECTOR position, ref float mindistance, ref float maxdistance)
3735 {
3736 return FMOD5_Reverb3D_Get3DAttributes(this.handle, ref position, ref mindistance, ref maxdistance);
3737 }
3738 public RESULT setProperties(ref REVERB_PROPERTIES properties)
3739 {
3740 return FMOD5_Reverb3D_SetProperties(this.handle, ref properties);
3741 }
3742 public RESULT getProperties(ref REVERB_PROPERTIES properties)
3743 {
3744 return FMOD5_Reverb3D_GetProperties(this.handle, ref properties);
3745 }
3746 public RESULT setActive(bool active)
3747 {
3748 return FMOD5_Reverb3D_SetActive(this.handle, active);
3749 }
3750 public RESULT getActive(out bool active)
3751 {
3752 return FMOD5_Reverb3D_GetActive(this.handle, out active);
3753 }
3754
3755 // Userdata set/get.
3756 public RESULT setUserData(IntPtr userdata)
3757 {
3758 return FMOD5_Reverb3D_SetUserData(this.handle, userdata);
3759 }
3760 public RESULT getUserData(out IntPtr userdata)
3761 {
3762 return FMOD5_Reverb3D_GetUserData(this.handle, out userdata);
3763 }
3764
3765 #region importfunctions
3766 [DllImport(VERSION.dll)]
3767 private static extern RESULT FMOD5_Reverb3D_Release (IntPtr reverb3d);
3768 [DllImport(VERSION.dll)]
3769 private static extern RESULT FMOD5_Reverb3D_Set3DAttributes (IntPtr reverb3d, ref VECTOR position, float mindistance, float maxdistance);
3770 [DllImport(VERSION.dll)]
3771 private static extern RESULT FMOD5_Reverb3D_Get3DAttributes (IntPtr reverb3d, ref VECTOR position, ref float mindistance, ref float maxdistance);
3772 [DllImport(VERSION.dll)]
3773 private static extern RESULT FMOD5_Reverb3D_SetProperties (IntPtr reverb3d, ref REVERB_PROPERTIES properties);
3774 [DllImport(VERSION.dll)]
3775 private static extern RESULT FMOD5_Reverb3D_GetProperties (IntPtr reverb3d, ref REVERB_PROPERTIES properties);
3776 [DllImport(VERSION.dll)]
3777 private static extern RESULT FMOD5_Reverb3D_SetActive (IntPtr reverb3d, bool active);
3778 [DllImport(VERSION.dll)]
3779 private static extern RESULT FMOD5_Reverb3D_GetActive (IntPtr reverb3d, out bool active);
3780 [DllImport(VERSION.dll)]
3781 private static extern RESULT FMOD5_Reverb3D_SetUserData (IntPtr reverb3d, IntPtr userdata);
3782 [DllImport(VERSION.dll)]
3783 private static extern RESULT FMOD5_Reverb3D_GetUserData (IntPtr reverb3d, out IntPtr userdata);
3784 #endregion
3785
3786 #region wrapperinternal
3787
3788 public IntPtr handle;
3789
3790 public Reverb3D(IntPtr ptr) { this.handle = ptr; }
3791 public bool hasHandle() { return this.handle != IntPtr.Zero; }
3792 public void clearHandle() { this.handle = IntPtr.Zero; }
3793
3794 #endregion
3795 }
3796
3797 #region Helper Functions
3798 [StructLayout(LayoutKind.Sequential)]
3799 public struct StringWrapper
3800 {
3801 IntPtr nativeUtf8Ptr;
3802
3803 public StringWrapper(IntPtr ptr)
3804 {
3805 nativeUtf8Ptr = ptr;
3806 }
3807
3808 public static implicit operator string(StringWrapper fstring)
3809 {
3810 using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
3811 {
3812 return encoder.stringFromNative(fstring.nativeUtf8Ptr);
3813 }
3814 }
3815 }
3816
3817 static class StringHelper
3818 {
3819 public class ThreadSafeEncoding : IDisposable
3820 {
3821 UTF8Encoding encoding = new UTF8Encoding();
3822 byte[] encodedBuffer = new byte[128];
3823 char[] decodedBuffer = new char[128];
3824 bool inUse;
3825 GCHandle gcHandle;
3826
3827 public bool InUse() { return inUse; }
3828 public void SetInUse() { inUse = true; }
3829
3830 private int roundUpPowerTwo(int number)
3831 {
3832 int newNumber = 1;
3833 while (newNumber <= number)
3834 {
3835 newNumber *= 2;
3836 }
3837
3838 return newNumber;
3839 }
3840
3841 public byte[] byteFromStringUTF8(string s)
3842 {
3843 if (s == null)
3844 {
3845 return null;
3846 }
3847
3848 int maximumLength = encoding.GetMaxByteCount(s.Length) + 1; // +1 for null terminator
3849 if (maximumLength > encodedBuffer.Length)
3850 {
3851 int encodedLength = encoding.GetByteCount(s) + 1; // +1 for null terminator
3852 if (encodedLength > encodedBuffer.Length)
3853 {
3854 encodedBuffer = new byte[roundUpPowerTwo(encodedLength)];
3855 }
3856 }
3857
3858 int byteCount = encoding.GetBytes(s, 0, s.Length, encodedBuffer, 0);
3859 encodedBuffer[byteCount] = 0; // Apply null terminator
3860
3861 return encodedBuffer;
3862 }
3863
3864 public IntPtr intptrFromStringUTF8(string s)
3865 {
3866 if (s == null)
3867 {
3868 return IntPtr.Zero;
3869 }
3870
3871 gcHandle = GCHandle.Alloc(byteFromStringUTF8(s), GCHandleType.Pinned);
3872 return gcHandle.AddrOfPinnedObject();
3873 }
3874
3875 public string stringFromNative(IntPtr nativePtr)
3876 {
3877 if (nativePtr == IntPtr.Zero)
3878 {
3879 return "";
3880 }
3881
3882 int nativeLen = 0;
3883 while (Marshal.ReadByte(nativePtr, nativeLen) != 0)
3884 {
3885 nativeLen++;
3886 }
3887
3888 if (nativeLen == 0)
3889 {
3890 return "";
3891 }
3892
3893 if (nativeLen > encodedBuffer.Length)
3894 {
3895 encodedBuffer = new byte[roundUpPowerTwo(nativeLen)];
3896 }
3897
3898 Marshal.Copy(nativePtr, encodedBuffer, 0, nativeLen);
3899
3900 int maximumLength = encoding.GetMaxCharCount(nativeLen);
3901 if (maximumLength > decodedBuffer.Length)
3902 {
3903 int decodedLength = encoding.GetCharCount(encodedBuffer, 0, nativeLen);
3904 if (decodedLength > decodedBuffer.Length)
3905 {
3906 decodedBuffer = new char[roundUpPowerTwo(decodedLength)];
3907 }
3908 }
3909
3910 int charCount = encoding.GetChars(encodedBuffer, 0, nativeLen, decodedBuffer, 0);
3911
3912 return new String(decodedBuffer, 0, charCount);
3913 }
3914
3915 public void Dispose()
3916 {
3917 if (gcHandle.IsAllocated)
3918 {
3919 gcHandle.Free();
3920 }
3921 lock (encoders)
3922 {
3923 inUse = false;
3924 }
3925 }
3926 }
3927
3928 static List<ThreadSafeEncoding> encoders = new List<ThreadSafeEncoding>(1);
3929
3930 public static ThreadSafeEncoding GetFreeHelper()
3931 {
3932 lock (encoders)
3933 {
3934 ThreadSafeEncoding helper = null;
3935 // Search for not in use helper
3936 for (int i = 0; i < encoders.Count; i++)
3937 {
3938 if (!encoders[i].InUse())
3939 {
3940 helper = encoders[i];
3941 break;
3942 }
3943 }
3944 // Otherwise create another helper
3945 if (helper == null)
3946 {
3947 helper = new ThreadSafeEncoding();
3948 encoders.Add(helper);
3949 }
3950 helper.SetInUse();
3951 return helper;
3952 }
3953 }
3954 }
3955
3956 // Some of the Marshal functions were marked as deprecated / obsolete, however that decision was reversed: https://github.com/dotnet/corefx/pull/10541
3957 // Use the old syntax (non-generic) to ensure maximum compatibility (especially with Unity) ignoring the warnings
3958 public static class MarshalHelper
3959 {
3960#pragma warning disable 618
3961 public static int SizeOf(Type t)
3962 {
3963 return Marshal.SizeOf(t); // Always use Type version, never Object version as it boxes causes GC allocations
3964 }
3965
3966 public static object PtrToStructure(IntPtr ptr, Type structureType)
3967 {
3968 return Marshal.PtrToStructure(ptr, structureType);
3969 }
3970#pragma warning restore 618
3971 }
3972
3973 #endregion
3974}