-
Notifications
You must be signed in to change notification settings - Fork 2
/
SDL2_mixer.cs
666 lines (556 loc) · 20.9 KB
/
SDL2_mixer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
#region License
/* SDL2# - C# Wrapper for SDL2
*
* Copyright (c) 2013-2021 Ethan Lee.
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from
* the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in a
* product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
* Ethan "flibitijibibo" Lee <flibitijibibo@flibitijibibo.com>
*
*/
#endregion
#region Using Statements
using System;
using System.Runtime.InteropServices;
#endregion
namespace SDL2
{
public static class SDL_mixer
{
#region SDL2# Variables
/* Used by DllImport to load the native library. */
private const string nativeLibName = "SDL2_mixer";
#endregion
#region SDL_mixer.h
/* Similar to the headers, this is the version we're expecting to be
* running with. You will likely want to check this somewhere in your
* program!
*/
public const int SDL_MIXER_MAJOR_VERSION = 2;
public const int SDL_MIXER_MINOR_VERSION = 0;
public const int SDL_MIXER_PATCHLEVEL = 5;
/* In C, you can redefine this value before including SDL_mixer.h.
* We're not going to allow this in SDL2#, since the value of this
* variable is persistent and not dependent on preprocessor ordering.
*/
public const int MIX_CHANNELS = 8;
public static readonly int MIX_DEFAULT_FREQUENCY = 44100;
public static readonly ushort MIX_DEFAULT_FORMAT =
BitConverter.IsLittleEndian ? SDL.AUDIO_S16LSB : SDL.AUDIO_S16MSB;
public static readonly int MIX_DEFAULT_CHANNELS = 2;
public static readonly byte MIX_MAX_VOLUME = 128;
[Flags]
public enum MIX_InitFlags
{
MIX_INIT_FLAC = 0x00000001,
MIX_INIT_MOD = 0x00000002,
MIX_INIT_MP3 = 0x00000008,
MIX_INIT_OGG = 0x00000010,
MIX_INIT_MID = 0x00000020,
MIX_INIT_OPUS = 0x00000040
}
public struct MIX_Chunk
{
public int allocated;
public IntPtr abuf; /* Uint8* */
public uint alen;
public byte volume;
}
public enum Mix_Fading
{
MIX_NO_FADING,
MIX_FADING_OUT,
MIX_FADING_IN
}
public enum Mix_MusicType
{
MUS_NONE,
MUS_CMD,
MUS_WAV,
MUS_MOD,
MUS_MID,
MUS_OGG,
MUS_MP3,
MUS_MP3_MAD_UNUSED,
MUS_FLAC,
MUS_MODPLUG_UNUSED,
MUS_OPUS
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void MixFuncDelegate(
IntPtr udata, // void*
IntPtr stream, // Uint8*
int len
);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void Mix_EffectFunc_t(
int chan,
IntPtr stream, // void*
int len,
IntPtr udata // void*
);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void Mix_EffectDone_t(
int chan,
IntPtr udata // void*
);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void MusicFinishedDelegate();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void ChannelFinishedDelegate(int channel);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int SoundFontDelegate(
IntPtr a, // const char*
IntPtr b // void*
);
public static void SDL_MIXER_VERSION(out SDL.SDL_version X)
{
X.major = SDL_MIXER_MAJOR_VERSION;
X.minor = SDL_MIXER_MINOR_VERSION;
X.patch = SDL_MIXER_PATCHLEVEL;
}
[DllImport(nativeLibName, EntryPoint = "MIX_Linked_Version", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_MIX_Linked_Version();
public static SDL.SDL_version MIX_Linked_Version()
{
SDL.SDL_version result;
IntPtr result_ptr = INTERNAL_MIX_Linked_Version();
result = (SDL.SDL_version) Marshal.PtrToStructure(
result_ptr,
typeof(SDL.SDL_version)
);
return result;
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_Init(MIX_InitFlags flags);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Mix_Quit();
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_OpenAudio(
int frequency,
ushort format,
int channels,
int chunksize
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_AllocateChannels(int numchans);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_QuerySpec(
out int frequency,
out ushort format,
out int channels
);
/* src refers to an SDL_RWops*, IntPtr to a Mix_Chunk* */
/* THIS IS A PUBLIC RWops FUNCTION! */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Mix_LoadWAV_RW(
IntPtr src,
int freesrc
);
/* IntPtr refers to a Mix_Chunk* */
/* This is an RWops macro in the C header. */
public static IntPtr Mix_LoadWAV(string file)
{
IntPtr rwops = SDL.SDL_RWFromFile(file, "rb");
return Mix_LoadWAV_RW(rwops, 1);
}
/* IntPtr refers to a Mix_Music* */
[DllImport(nativeLibName, EntryPoint = "Mix_LoadMUS", CallingConvention = CallingConvention.Cdecl)]
private static extern unsafe IntPtr INTERNAL_Mix_LoadMUS(
byte* file
);
public static unsafe IntPtr Mix_LoadMUS(string file)
{
byte* utf8File = SDL.Utf8EncodeHeap(file);
IntPtr handle = INTERNAL_Mix_LoadMUS(
utf8File
);
Marshal.FreeHGlobal((IntPtr) utf8File);
return handle;
}
/* IntPtr refers to a Mix_Chunk* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Mix_QuickLoad_WAV(
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1)]
byte[] mem
);
/* IntPtr refers to a Mix_Chunk* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Mix_QuickLoad_RAW(
[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 1)]
byte[] mem,
uint len
);
/* chunk refers to a Mix_Chunk* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Mix_FreeChunk(IntPtr chunk);
/* music refers to a Mix_Music* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Mix_FreeMusic(IntPtr music);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_GetNumChunkDecoders();
[DllImport(nativeLibName, EntryPoint = "Mix_GetChunkDecoder", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_Mix_GetChunkDecoder(int index);
public static string Mix_GetChunkDecoder(int index)
{
return SDL.UTF8_ToManaged(
INTERNAL_Mix_GetChunkDecoder(index)
);
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_GetNumMusicDecoders();
[DllImport(nativeLibName, EntryPoint = "Mix_GetMusicDecoder", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_Mix_GetMusicDecoder(int index);
public static string Mix_GetMusicDecoder(int index)
{
return SDL.UTF8_ToManaged(
INTERNAL_Mix_GetMusicDecoder(index)
);
}
/* music refers to a Mix_Music* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Mix_MusicType Mix_GetMusicType(IntPtr music);
/* music refers to a Mix_Music*
* Only available in 2.0.5 or higher.
*/
[DllImport(nativeLibName, EntryPoint = "Mix_GetMusicTitle", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr INTERNAL_Mix_GetMusicTitle(IntPtr music);
public static string Mix_GetMusicTitle(IntPtr music)
{
return SDL.UTF8_ToManaged(
INTERNAL_Mix_GetMusicTitle(music)
);
}
/* music refers to a Mix_Music*
* Only available in 2.0.5 or higher.
*/
[DllImport(nativeLibName, EntryPoint = "Mix_GetMusicTitleTag", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr INTERNAL_Mix_GetMusicTitleTag(IntPtr music);
public static string Mix_GetMusicTitleTag(IntPtr music)
{
return SDL.UTF8_ToManaged(
INTERNAL_Mix_GetMusicTitleTag(music)
);
}
/* music refers to a Mix_Music*
* Only available in 2.0.5 or higher.
*/
[DllImport(nativeLibName, EntryPoint = "Mix_GetMusicArtistTag", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr INTERNAL_Mix_GetMusicArtistTag(IntPtr music);
public static string Mix_GetMusicArtistTag(IntPtr music)
{
return SDL.UTF8_ToManaged(
INTERNAL_Mix_GetMusicArtistTag(music)
);
}
/* music refers to a Mix_Music*
* Only available in 2.0.5 or higher.
*/
[DllImport(nativeLibName, EntryPoint = "Mix_GetMusicAlbumTag", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr INTERNAL_Mix_GetMusicAlbumTag(IntPtr music);
public static string Mix_GetMusicAlbumTag(IntPtr music)
{
return SDL.UTF8_ToManaged(
INTERNAL_Mix_GetMusicAlbumTag(music)
);
}
/* music refers to a Mix_Music*
* Only available in 2.0.5 or higher.
*/
[DllImport(nativeLibName, EntryPoint = "Mix_GetMusicCopyrightTag", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr INTERNAL_Mix_GetMusicCopyrightTag(IntPtr music);
public static string Mix_GetMusicCopyrightTag(IntPtr music)
{
return SDL.UTF8_ToManaged(
INTERNAL_Mix_GetMusicCopyrightTag(music)
);
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Mix_SetPostMix(
MixFuncDelegate mix_func,
IntPtr arg // void*
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Mix_HookMusic(
MixFuncDelegate mix_func,
IntPtr arg // void*
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Mix_HookMusicFinished(
MusicFinishedDelegate music_finished
);
/* IntPtr refers to a void* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Mix_GetMusicHookData();
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Mix_ChannelFinished(
ChannelFinishedDelegate channel_finished
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_RegisterEffect(
int chan,
Mix_EffectFunc_t f,
Mix_EffectDone_t d,
IntPtr arg // void*
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_UnregisterEffect(
int channel,
Mix_EffectFunc_t f
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_UnregisterAllEffects(int channel);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_SetPanning(
int channel,
byte left,
byte right
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_SetPosition(
int channel,
short angle,
byte distance
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_SetDistance(int channel, byte distance);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_SetReverseStereo(int channel, int flip);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_ReserveChannels(int num);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_GroupChannel(int which, int tag);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_GroupChannels(int from, int to, int tag);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_GroupAvailable(int tag);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_GroupCount(int tag);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_GroupOldest(int tag);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_GroupNewer(int tag);
/* chunk refers to a Mix_Chunk* */
public static int Mix_PlayChannel(
int channel,
IntPtr chunk,
int loops
) {
return Mix_PlayChannelTimed(channel, chunk, loops, -1);
}
/* chunk refers to a Mix_Chunk* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_PlayChannelTimed(
int channel,
IntPtr chunk,
int loops,
int ticks
);
/* music refers to a Mix_Music* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_PlayMusic(IntPtr music, int loops);
/* music refers to a Mix_Music* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_FadeInMusic(
IntPtr music,
int loops,
int ms
);
/* music refers to a Mix_Music* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_FadeInMusicPos(
IntPtr music,
int loops,
int ms,
double position
);
/* chunk refers to a Mix_Chunk* */
public static int Mix_FadeInChannel(
int channel,
IntPtr chunk,
int loops,
int ms
) {
return Mix_FadeInChannelTimed(channel, chunk, loops, ms, -1);
}
/* chunk refers to a Mix_Chunk* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_FadeInChannelTimed(
int channel,
IntPtr chunk,
int loops,
int ms,
int ticks
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_Volume(int channel, int volume);
/* chunk refers to a Mix_Chunk* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_VolumeChunk(
IntPtr chunk,
int volume
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_VolumeMusic(int volume);
/* music refers to a Mix_Music*
* Only available in 2.0.5 or higher.
*/
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_GetVolumeMusicStream(IntPtr music);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_HaltChannel(int channel);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_HaltGroup(int tag);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_HaltMusic();
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_ExpireChannel(int channel, int ticks);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_FadeOutChannel(int which, int ms);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_FadeOutGroup(int tag, int ms);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_FadeOutMusic(int ms);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Mix_Fading Mix_FadingMusic();
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Mix_Fading Mix_FadingChannel(int which);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Mix_Pause(int channel);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Mix_Resume(int channel);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_Paused(int channel);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Mix_PauseMusic();
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Mix_ResumeMusic();
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Mix_RewindMusic();
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_PausedMusic();
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_SetMusicPosition(double position);
/* music refers to a Mix_Music*
* Only available in 2.0.5 or higher.
*/
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern double Mix_GetMusicPosition(IntPtr music);
/* music refers to a Mix_Music*
* Only available in 2.0.5 or higher.
*/
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern double Mix_MusicDuration(IntPtr music);
/* music refers to a Mix_Music*
* Only available in 2.0.5 or higher.
*/
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern double Mix_GetMusicLoopStartTime(IntPtr music);
/* music refers to a Mix_Music*
* Only available in 2.0.5 or higher.
*/
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern double Mix_GetMusicLoopEndTime(IntPtr music);
/* music refers to a Mix_Music*
* Only available in 2.0.5 or higher.
*/
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern double Mix_GetMusicLoopLengthTime(IntPtr music);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_Playing(int channel);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_PlayingMusic();
[DllImport(nativeLibName, EntryPoint = "Mix_SetMusicCMD", CallingConvention = CallingConvention.Cdecl)]
private static extern unsafe int INTERNAL_Mix_SetMusicCMD(
byte* command
);
public static unsafe int Mix_SetMusicCMD(string command)
{
byte* utf8Cmd = SDL.Utf8EncodeHeap(command);
int result = INTERNAL_Mix_SetMusicCMD(
utf8Cmd
);
Marshal.FreeHGlobal((IntPtr) utf8Cmd);
return result;
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_SetSynchroValue(int value);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_GetSynchroValue();
[DllImport(nativeLibName, EntryPoint = "Mix_SetSoundFonts", CallingConvention = CallingConvention.Cdecl)]
private static extern unsafe int INTERNAL_Mix_SetSoundFonts(
byte* paths
);
public static unsafe int Mix_SetSoundFonts(string paths)
{
byte* utf8Paths = SDL.Utf8EncodeHeap(paths);
int result = INTERNAL_Mix_SetSoundFonts(
utf8Paths
);
Marshal.FreeHGlobal((IntPtr) utf8Paths);
return result;
}
[DllImport(nativeLibName, EntryPoint = "Mix_GetSoundFonts", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr INTERNAL_Mix_GetSoundFonts();
public static string Mix_GetSoundFonts()
{
return SDL.UTF8_ToManaged(
INTERNAL_Mix_GetSoundFonts()
);
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_EachSoundFont(
SoundFontDelegate function,
IntPtr data // void*
);
/* Only available in 2.0.5 or later. */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int Mix_SetTimidityCfg(
[In()] [MarshalAs(UnmanagedType.LPStr)]
string path
);
/* Only available in 2.0.5 or later. */
[DllImport(nativeLibName, EntryPoint = "Mix_GetTimidityCfg", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr INTERNAL_Mix_GetTimidityCfg();
public static string Mix_GetTimidityCfg()
{
return SDL.UTF8_ToManaged(
INTERNAL_Mix_GetTimidityCfg()
);
}
/* IntPtr refers to a Mix_Chunk* */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Mix_GetChunk(int channel);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Mix_CloseAudio();
public static string Mix_GetError()
{
return SDL.SDL_GetError();
}
public static void Mix_SetError(string fmtAndArglist)
{
SDL.SDL_SetError(fmtAndArglist);
}
public static void Mix_ClearError()
{
SDL.SDL_ClearError();
}
#endregion
}
}