-
Notifications
You must be signed in to change notification settings - Fork 0
/
Soloud.cs
1469 lines (1211 loc) · 34.2 KB
/
Soloud.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
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System.Numerics;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
using SoLoud.Interop;
namespace SoLoud;
public enum SoloudBackendType
{
Auto = 0,
SDL1,
SDL2,
PortAudio,
WinMM,
XAudio2,
WASAPI,
ALSA,
Jack,
OSS,
OpenAL,
CoreAudio,
OpenSLES,
VitaHomebrew,
MiniAudio,
NoSound,
NullDriver,
BackendMax
}
public enum SoloudResultType
{
None = 0,
InvalidParameter = 1,
FileNotFound = 2,
FileLoadFailed = 3,
DllNotFound = 4,
OutOfMemory = 5,
NotImplemented = 6,
Unknown = 7
}
[Flags]
public enum SoloudFlag
{
ClipRoundoff = 1,
EnableVisualization = 2,
LeftHanded3d = 4,
NoFpuRegisterChange = 8
}
[Flags]
public enum AudioSourceInstanceFlag
{
Looping = 1,
Protected = 2,
Paused = 4,
Process3d = 8,
ListenerRelative = 16,
Inaudible = 32,
InaudibleKill = 64,
InaudibleTick = 128,
DisableAutostop = 256
}
[Flags]
public enum AudioSourceFlag
{
ShouldLoop = 1,
SingleInstance = 2,
VisualizationData = 4,
Process3d = 8,
ListenerRelative = 16,
DistanceDleay = 32,
InaudibleKill = 64,
InaudibleTick = 128,
DisableAutostop = 256
}
public enum WaveFormType
{
Square = 0,
Saw,
Sin,
Triangle,
Bounce,
Jaws,
Humps,
FSquare,
FSaw
}
public enum ResamplerType
{
Point = 0,
Linear = 1,
CatmullRom = 2
}
public enum AttenuationModelType
{
None = 0,
InverseDistance,
LinearDistance,
ExponentialDistance
}
public enum FilterParamType
{
Float = 0,
Int,
Bool
}
/// <summary>
/// An internal safe wrapper for a Souloud object not resident in managed memory.
/// It's safe; it allows implementing code to know if the handle is valid.
/// It's smart; it introduces reliable cleanup.
/// It's robust; it type-safely implements how the stored pointer decays
/// for lower level generics.
/// </summary>
internal sealed unsafe class SafeSoloudContext : SafeHandleZeroOrMinusOneIsInvalid
{
internal SafeSoloudContext(IntPtr ptr)
: base(true)
{
SetHandle(ptr);
}
internal RefSoloud* Acquire() => (RefSoloud*) DangerousGetHandle();
public static implicit operator RefSoloud*(SafeSoloudContext ctx) => (RefSoloud*) ctx.Acquire();
protected override bool ReleaseHandle()
{
SoloudInterop.Soloud_destroy((RefSoloud*) this.handle);
return true;
}
}
/// <summary>
/// An internal safe wrapper for a Souloud object not resident in managed memory.
/// It's safe; it allows implementing code to know if the handle is valid.
/// It's smart; it introduces reliable cleanup.
/// It's robust; it type-safely implements how the stored pointer decays
/// for lower level generics.
/// </summary>
internal sealed unsafe class SafeWavContext : SafeHandleZeroOrMinusOneIsInvalid
{
internal SafeWavContext(IntPtr ptr)
: base(true)
{
SetHandle(ptr);
}
internal RefWav* Acquire() => (RefWav*) DangerousGetHandle();
public static implicit operator RefAudioSource*(SafeWavContext ctx) => (RefAudioSource*) ctx.Acquire();
public static implicit operator RefWav*(SafeWavContext ctx) => (RefWav*) ctx.Acquire();
protected override bool ReleaseHandle()
{
SoloudInterop.Wav_destroy((RefWav*) this.handle);
return true;
}
}
/// <summary>
/// An internal safe wrapper for a Souloud object not resident in managed memory.
/// It's safe; it allows implementing code to know if the handle is valid.
/// It's smart; it introduces reliable cleanup.
/// It's robust; it type-safely implements how the stored pointer decays
/// for lower level generics.
/// </summary>
internal sealed unsafe class SafeWavStreamContext : SafeHandleZeroOrMinusOneIsInvalid
{
internal SafeWavStreamContext(IntPtr ptr)
: base(true)
{
SetHandle(ptr);
}
internal RefWavStream* Acquire() => (RefWavStream*) DangerousGetHandle();
public static implicit operator RefAudioSource*(SafeWavStreamContext ctx) => (RefAudioSource*) ctx.Acquire();
public static implicit operator RefWavStream*(SafeWavStreamContext ctx) => (RefWavStream*) ctx.Acquire();
protected override bool ReleaseHandle()
{
SoloudInterop.WavStream_destroy((RefWavStream*) this.handle);
return true;
}
}
/// <summary>
/// An internal safe wrapper for a Souloud object not resident in managed memory.
/// It's safe; it allows implementing code to know if the handle is valid.
/// It's smart; it introduces reliable cleanup.
/// It's robust; it type-safely implements how the stored pointer decays
/// for lower level generics.
/// </summary>
internal sealed unsafe class SafeAyContext : SafeHandleZeroOrMinusOneIsInvalid
{
internal SafeAyContext(IntPtr ptr)
: base(true)
{
SetHandle(ptr);
}
internal RefAy* Acquire() => (RefAy*) DangerousGetHandle();
public static implicit operator RefAy*(SafeAyContext ctx) => (RefAy*) ctx.Acquire();
protected override bool ReleaseHandle()
{
SoloudInterop.Ay_destroy((RefAy*) this.handle);
return true;
}
}
/// <summary>
/// An internal safe wrapper for a Souloud object not resident in managed memory.
/// It's safe; it allows implementing code to know if the handle is valid.
/// It's smart; it introduces reliable cleanup.
/// It's robust; it type-safely implements how the stored pointer decays
/// for lower level generics.
/// </summary>
internal sealed unsafe class SafeBusContext : SafeHandleZeroOrMinusOneIsInvalid
{
internal SafeBusContext(IntPtr ptr)
: base(true)
{
SetHandle(ptr);
}
internal RefBus* Acquire() => (RefBus*) DangerousGetHandle();
public static implicit operator RefBus*(SafeBusContext ctx) => (RefBus*) ctx.Acquire();
protected override bool ReleaseHandle()
{
SoloudInterop.Bus_destroy((RefBus*) this.handle);
return true;
}
}
/// <summary>
/// A voice handle is a Soloud internal voice handle.
/// It is weak because the internal handle can be cleaned up at any time.
/// It is proper to check if a handle is valid before using it.
/// By default, a voice handle will become invalid when the it has stopped.
/// </summary>
public class VoiceHandle
{
private Soloud _ctx;
internal readonly uint Handle;
public VoiceHandle(Soloud ctx, uint handle)
{
_ctx = ctx;
Handle = handle;
}
public bool IsValidVoiceHandle()
{
return _ctx.IsValidVoiceHandle(this);
}
}
/// <summary>
/// A voice handle is a Soloud internal voice handle.
/// It is termed weak because the internal handle can be cleaned up at any time.
/// It is proper to check if a handle is valid before using it.
/// By default, a voice handle will become invalid when the it has stopped.
/// </summary>
public class BusHandle
{
private Bus _ctx;
internal readonly uint Handle;
public BusHandle(Bus ctx, uint handle)
{
_ctx = ctx;
Handle = handle;
}
}
public sealed unsafe class Soloud : IDisposable
{
private bool _disposed;
public bool IsDisposed => _disposed;
/// <summary>
/// Safely retrieves handle to the unmanaged state.
/// See also: <see cref="SafeSoloudContext" />
/// </summary>
/// <exception cref="ObjectDisposedException">Thrown on attempt to access while invalid state.</exception>
private SafeSoloudContext _handle;
internal SafeSoloudContext Handle
{
get
{
ThrowIfDisposed();
return _handle;
}
}
public Soloud()
{
RefSoloud* ctx = SoloudInterop.Soloud_create();
_handle = new SafeSoloudContext((IntPtr) ctx);
}
public Soloud(bool autoinit)
: this()
{
if (autoinit)
{
Init();
}
}
public void Dispose()
{
Handle.Dispose();
_disposed = true;
}
public void ThrowIfDisposed()
{
if (_disposed || _handle.IsInvalid)
throw new ObjectDisposedException(GetType().FullName, "Attempt to use Soloud when it's cleaned up.");
}
public SoloudResultType Init()
{
return (SoloudResultType) SoloudInterop.Soloud_init(Handle);
}
public SoloudResultType InitEx(SoloudFlag flags, SoloudBackendType backend, uint samplerate, uint bufferSize, uint channels)
{
return (SoloudResultType) SoloudInterop.Soloud_initEx(Handle, (uint) flags, (uint) backend, samplerate, bufferSize, channels);
}
public void Deinit()
{
SoloudInterop.Soloud_deinit(Handle);
}
public SoloudResultType Pause()
{
return (SoloudResultType) SoloudInterop.Soloud_pause(Handle);
}
public SoloudResultType Resume()
{
return (SoloudResultType) SoloudInterop.Soloud_resume(Handle);
}
public uint GetVersion()
{
return SoloudInterop.Soloud_getVersion(Handle);
}
public string GetErrorString(SoloudResultType errorCode)
{
sbyte* error = SoloudInterop.Soloud_getErrorString(Handle, (int) errorCode);
return Marshal.PtrToStringAnsi((IntPtr) error) ?? string.Empty;
}
public SoloudBackendType GetBackendType()
{
return (SoloudBackendType) SoloudInterop.Soloud_getBackendId(Handle);
}
public string GetBackendString()
{
sbyte* str = SoloudInterop.Soloud_getBackendString(Handle);
return Marshal.PtrToStringAnsi((IntPtr) str) ?? string.Empty;
}
public uint GetBackendChannels()
{
return SoloudInterop.Soloud_getBackendChannels(Handle);
}
public uint GetBackendSamplerate()
{
return SoloudInterop.Soloud_getBackendSamplerate(Handle);
}
public uint GetBackendBufferSize()
{
return SoloudInterop.Soloud_getBackendBufferSize(Handle);
}
public SoloudResultType SetSpeakerPosition(uint channel, float x, float y, float z)
{
return (SoloudResultType) SoloudInterop.Soloud_setSpeakerPosition(Handle, channel, x, y, z);
}
public SoloudResultType GetSpeakerPosition(uint channel, out float x, out float y, out float z)
{
fixed (float* _x = &x, _y = &y, _z = &z)
{
SoloudResultType result = (SoloudResultType) SoloudInterop.Soloud_getSpeakerPosition(Handle, channel, _x, _y, _z);
x = *_x;
y = *_y;
z = *_z;
return result;
}
}
public SoloudResultType GetSpeakerPosition(uint channel, out Vector3 position)
{
float x, y, z;
SoloudResultType result = GetSpeakerPosition(channel, out x, out y, out z);
position = new Vector3(x, y, z);
return result;
}
public VoiceHandle Play(Wav sound, float volume = -1.0f, float pan = 0.0f, bool paused = false, uint bus = 0)
{
uint handle = SoloudInterop.Soloud_playEx(Handle, sound.Handle, volume, pan, paused ? 1 : 0, bus);
return new VoiceHandle(this, handle);
}
public VoiceHandle PlayClocked(double soundTime, Wav sound, float volume = -1.0f, float pan = 0.0f, uint bus = 0)
{
uint handle = SoloudInterop.Soloud_playClockedEx(Handle, soundTime, sound.Handle, volume, pan, bus);
return new VoiceHandle(this, handle);
}
public VoiceHandle Play3D(Wav sound, float posX, float posY, float posZ, float velX = 0.0f, float velY = 0.0f, float velZ = 0.0f, float volume = 1.0f, bool paused = false, uint bus = 0)
{
uint handle = SoloudInterop.Soloud_play3dEx(Handle, sound.Handle, posX, posY, posZ, velX, velY, velZ, volume, paused ? 1 : 0, bus);
return new VoiceHandle(this, handle);
}
public VoiceHandle Play3DClocked(double soundTime, Wav sound, float posX, float posY, float posZ, float velX = 0.0f, float velY = 0.0f, float velZ = 0.0f, float volume = 1.0f, uint bus = 0)
{
uint handle = SoloudInterop.Soloud_play3dClockedEx(Handle, soundTime, sound.Handle, posX, posY, posZ, velX, velY, velZ, volume, bus);
return new VoiceHandle(this, handle);
}
public VoiceHandle PlayBackground(Wav sound, float volume = -1.0f, bool paused = false, uint bus = 0)
{
uint handle = SoloudInterop.Soloud_playBackgroundEx(Handle, sound.Handle, volume, paused ? 1 : 0, bus);
return new VoiceHandle(this, handle);
}
public SoloudResultType Seek(VoiceHandle voice, double seconds)
{
return (SoloudResultType) SoloudInterop.Soloud_seek(Handle, voice.Handle, seconds);
}
public void Stop(VoiceHandle voice)
{
SoloudInterop.Soloud_stop(Handle, voice.Handle);
}
public void StopAll()
{
SoloudInterop.Soloud_stopAll(Handle);
}
public void StopAudioSource(Wav sound)
{
SoloudInterop.Soloud_stopAudioSource(Handle, sound.Handle);
}
public int CountAudioSource(Wav sound)
{
return SoloudInterop.Soloud_countAudioSource(Handle, sound.Handle);
}
public void SetFilterParameter()
{
throw new NotImplementedException();
}
public float GetFilterParameter()
{
throw new NotImplementedException();
}
public void FadeFilterParameter()
{
throw new NotImplementedException();
}
public void OscillateFilterParameter()
{
throw new NotImplementedException();
}
public double GetStreamTime(VoiceHandle voice)
{
return SoloudInterop.Soloud_getStreamTime(Handle, voice.Handle);
}
public double GetStreamPosition(VoiceHandle voice)
{
return SoloudInterop.Soloud_getStreamPosition(Handle, voice.Handle);
}
public bool GetPause(VoiceHandle voice)
{
return SoloudInterop.Soloud_getPause(Handle, voice.Handle) > 0;
}
public float GetVolume(VoiceHandle voice)
{
return SoloudInterop.Soloud_getVolume(Handle, voice.Handle);
}
public float GetOverallVolume(VoiceHandle voice)
{
return SoloudInterop.Soloud_getOverallVolume(Handle, voice.Handle);
}
public float GetPan(VoiceHandle voice)
{
return SoloudInterop.Soloud_getPan(Handle, voice.Handle);
}
public float GetSamplerate(VoiceHandle voice)
{
return SoloudInterop.Soloud_getSamplerate(Handle, voice.Handle);
}
// TODO: unsure if this is a bool
public int GetProtectVoice(VoiceHandle voice)
{
return SoloudInterop.Soloud_getProtectVoice(Handle, voice.Handle);
}
public uint GetActiveVoiceCount()
{
return SoloudInterop.Soloud_getActiveVoiceCount(Handle);
}
public uint GetVoiceCount()
{
return SoloudInterop.Soloud_getVoiceCount(Handle);
}
public bool IsValidVoiceHandle(VoiceHandle voice)
{
return SoloudInterop.Soloud_isValidVoiceHandle(Handle, voice.Handle) > 0;
}
public float GetRelativePlaySpeed(VoiceHandle voice)
{
return SoloudInterop.Soloud_getRelativePlaySpeed(Handle, voice.Handle);
}
public float GetPostClipScaler()
{
return SoloudInterop.Soloud_getPostClipScaler(Handle);
}
// TODO: unsure of the return type
public uint GetMainResampler()
{
return SoloudInterop.Soloud_getMainResampler(Handle);
}
public float GetGlobalVolume()
{
return SoloudInterop.Soloud_getGlobalVolume(Handle);
}
public uint GetMaxActiveVoiceCount()
{
return SoloudInterop.Soloud_getMaxActiveVoiceCount(Handle);
}
public bool GetLooping(VoiceHandle voice)
{
return SoloudInterop.Soloud_getLooping(Handle, voice.Handle) > 0;
}
public bool GetAutoStop(VoiceHandle voice)
{
return SoloudInterop.Soloud_getAutoStop(Handle, voice.Handle) > 0;
}
public double GetLoopPoint(VoiceHandle voice)
{
return SoloudInterop.Soloud_getLoopPoint(Handle, voice.Handle);
}
public void SetLoopPoint(VoiceHandle voice, double loopPoint)
{
SoloudInterop.Soloud_setLoopPoint(Handle, voice.Handle, loopPoint);
}
public void SetLooping(VoiceHandle voice, bool looping)
{
SoloudInterop.Soloud_setLooping(Handle, voice.Handle, looping ? 1 : 0);
}
public void SetAutoStop(VoiceHandle voice, bool autoStop)
{
SoloudInterop.Soloud_setAutoStop(Handle, voice.Handle, autoStop ? 1 : 0);
}
public SoloudResultType SetMaxActiveVoiceCount(uint voiceCount)
{
return (SoloudResultType) SoloudInterop.Soloud_setMaxActiveVoiceCount(Handle, voiceCount);
}
public void SetInaudibleBehavior(VoiceHandle voice, bool mustTick, bool kill)
{
SoloudInterop.Soloud_setInaudibleBehavior(Handle, voice.Handle, mustTick ? 1 : 0, kill ? 1 : 0);
}
public void SetGlobalVolume(float volume)
{
SoloudInterop.Soloud_setGlobalVolume(Handle, volume);
}
public void SetPostClipScaler(float scaler)
{
SoloudInterop.Soloud_setPostClipScaler(Handle, scaler);
}
// TODO: unknown type resampler
public void SetMainResampler(uint resampler)
{
SoloudInterop.Soloud_setMainResampler(Handle, resampler);
}
public void SetPause(VoiceHandle voice, bool pause)
{
SoloudInterop.Soloud_setPause(Handle, voice.Handle, pause ? 1 : 0);
}
public void SetPauseAll(bool pause)
{
SoloudInterop.Soloud_setPauseAll(Handle, pause ? 1 : 0);
}
public SoloudResultType SetRelativePlaySpeed(VoiceHandle voice, float speed)
{
return (SoloudResultType) SoloudInterop.Soloud_setRelativePlaySpeed(Handle, voice.Handle, speed);
}
public void SetProtectVoice(VoiceHandle voice, bool protect)
{
SoloudInterop.Soloud_setProtectVoice(Handle, voice.Handle, protect ? 1 : 0);
}
public void SetSamplerate(VoiceHandle voice, float samplerate)
{
SoloudInterop.Soloud_setSamplerate(Handle, voice.Handle, samplerate);
}
public void SetPan(VoiceHandle voice, float pan)
{
SoloudInterop.Soloud_setPan(Handle, voice.Handle, pan);
}
public void SetPanAbsolute(VoiceHandle voice, float lVolume, float rVolume)
{
SoloudInterop.Soloud_setPanAbsolute(Handle, voice.Handle, lVolume, rVolume);
}
public void SetChannelVolume(VoiceHandle voice, uint channel, float volume)
{
SoloudInterop.Soloud_setChannelVolume(Handle, voice.Handle, channel, volume);
}
public void SetVolume(VoiceHandle voice, float volume)
{
SoloudInterop.Soloud_setVolume(Handle, voice.Handle, volume);
}
// TODO: unknown type samples
public void SetDelaySamples(VoiceHandle voice, uint samples)
{
SoloudInterop.Soloud_setDelaySamples(Handle, voice.Handle, samples);
}
public void FadeVolume(VoiceHandle voice, float to, double time)
{
SoloudInterop.Soloud_fadeVolume(Handle, voice.Handle, to, time);
}
public void FadePan(VoiceHandle voice, float to, double time)
{
SoloudInterop.Soloud_fadePan(Handle, voice.Handle, to, time);
}
public void FadeRelativePlaySpeed(VoiceHandle voice, float to, double time)
{
SoloudInterop.Soloud_fadeRelativePlaySpeed(Handle, voice.Handle, to, time);
}
public void FadeGlobalVolume(float to, double time)
{
SoloudInterop.Soloud_fadeGlobalVolume(Handle, to, time);
}
public void SchedulePause(VoiceHandle voice, double time)
{
SoloudInterop.Soloud_schedulePause(Handle, voice.Handle, time);
}
public void ScheduleStop(VoiceHandle voice, double time)
{
SoloudInterop.Soloud_scheduleStop(Handle, voice.Handle, time);
}
public void OscillateVolume(VoiceHandle voice, float from, float to, double time)
{
SoloudInterop.Soloud_oscillateVolume(Handle, voice.Handle, from, to, time);
}
public void OscillatePan(VoiceHandle voice, float from, float to, double time)
{
SoloudInterop.Soloud_oscillatePan(Handle, voice.Handle, from, to, time);
}
public void OscillateRelativePlaySpeed(VoiceHandle voice, float from, float to, double time)
{
SoloudInterop.Soloud_oscillateRelativePlaySpeed(Handle, voice.Handle, from, to, time);
}
public void OscillateGlobalVolume(float from, float to, double time)
{
SoloudInterop.Soloud_oscillateGlobalVolume(Handle, from, to, time);
}
public void SetGlobalFilter()
{
throw new NotImplementedException();
}
public void SetVisualizationEnable(bool enable)
{
SoloudInterop.Soloud_setVisualizationEnable(Handle, enable ? 1 : 0);
}
public float* CalcFFT()
{
throw new NotImplementedException();
}
public float* GetWave()
{
throw new NotImplementedException();
}
// TODO: unknown type channel
public float GetApproximateVolume(uint channel)
{
return SoloudInterop.Soloud_getApproximateVolume(Handle, channel);
}
public uint GetLoopCount(VoiceHandle voice)
{
return SoloudInterop.Soloud_getLoopCount(Handle, voice.Handle);
}
public float GetInfo(VoiceHandle voice, uint infoKey)
{
throw new NotImplementedException();
}
// TODO: not sure return type
public uint CreateVoiceGroup()
{
throw new NotImplementedException();
}
// TODO: not sure return type
public int DestroyVoiceGroup()
{
throw new NotImplementedException();
}
// TODO: not sure return type
public int AddVoiceToGroup()
{
throw new NotImplementedException();
}
public int IsVoiceGrouo()
{
throw new NotImplementedException();
}
public int IsVoiceGroupEmpty()
{
throw new NotImplementedException();
}
public void Update3DAudio()
{
SoloudInterop.Soloud_update3dAudio(Handle);
}
public SoloudResultType Set3DSoundSpeed(float speed)
{
return (SoloudResultType) SoloudInterop.Soloud_set3dSoundSpeed(Handle, speed);
}
public float Get3DSoundSpeed()
{
return SoloudInterop.Soloud_get3dSoundSpeed(Handle);
}
public void Set3DListenerParameters(float posX, float posY, float posZ, float atX, float atY, float atZ, float upX, float upY, float upZ, float velX = 0.0f, float velY = 0.0f, float velZ = 0.0f)
{
SoloudInterop.Soloud_set3dListenerParametersEx(Handle, posX, posY, posZ, atX, atY, atZ, upX, upY, upZ, velX, velY, velZ);
}
public void Set3DListenerPosition(float posX, float posY, float posZ)
{
SoloudInterop.Soloud_set3dListenerPosition(Handle, posX, posY, posZ);
}
public void Set3DListenerAt(float atX, float atY, float atZ)
{
SoloudInterop.Soloud_set3dListenerAt(Handle, atX, atY, atZ);
}
public void Set3DListenerUp(float upX, float upY, float upZ)
{
SoloudInterop.Soloud_set3dListenerUp(Handle, upX, upY, upZ);
}
public void Set3DListenerVelocity(float velX, float velY, float velZ)
{
SoloudInterop.Soloud_set3dListenerVelocity(Handle, velX, velY, velZ);
}
public void Set3DSourceParameters(VoiceHandle voice, float posX, float posY, float posZ, float velX = 0.0f, float velY = 0.0f, float velZ = 0.0f)
{
SoloudInterop.Soloud_set3dSourceParametersEx(Handle, voice.Handle, posX, posY, posZ, velX, velY, velZ);
}
public void Set3DSourcePosition(VoiceHandle voice, float posX, float posY, float posZ)
{
SoloudInterop.Soloud_set3dSourcePosition(Handle, voice.Handle, posX, posY, posZ);
}
public void Set3dSourceVelocity(VoiceHandle voice, float velX, float velY, float velZ)
{
SoloudInterop.Soloud_set3dSourceVelocity(Handle, voice.Handle, velX, velY, velZ);
}
public void Set3DSourceMinMaxDistance(VoiceHandle voice, float minDist, float maxDist)
{
SoloudInterop.Soloud_set3dSourceMinMaxDistance(Handle, voice.Handle, minDist, maxDist);
}
public void Set3DSourceAttenuation(VoiceHandle voice, AttenuationModelType attenuationModel, float rolloffFactor)
{
SoloudInterop.Soloud_set3dSourceAttenuation(Handle, voice.Handle, (uint) attenuationModel, rolloffFactor);
}
public void Set3DSourceDopplerFactor(VoiceHandle voice, float dopplerFactor)
{
SoloudInterop.Soloud_set3dSourceDopplerFactor(Handle, voice.Handle, dopplerFactor);
}
public void Mix()
{
throw new NotImplementedException();
}
public void MixSigned16()
{
throw new NotImplementedException();
}
}
public sealed unsafe class Ay : IDisposable
{
private bool _disposed;
public bool IsDisposed => _disposed;
private SafeAyContext _handle;
internal SafeAyContext Handle
{
get
{
ThrowIfDisposed();
return _handle;
}
}
public Ay()
{
RefAy* ctx = SoloudInterop.Ay_create();
_handle = new SafeAyContext((IntPtr) ctx);
}
public void Dispose()
{
Handle.Dispose();
_disposed = true;
}
public void ThrowIfDisposed()
{
if (_disposed || _handle.IsInvalid)
throw new ObjectDisposedException(GetType().FullName, "Attempt to use Ay when it's cleaned up.");
}
public void SetVolume(float volume)
{
SoloudInterop.Ay_setVolume(Handle, volume);
}
public void SetLooping(bool loop)
{
SoloudInterop.Ay_setLooping(Handle, loop ? 1 : 0);
}
public void SetAutoStop(bool autoStop)
{
SoloudInterop.Ay_setAutoStop(Handle, autoStop ? 1 : 0);
}
public void Set3DMinMaxDistance(float minDist, float maxDist)
{
SoloudInterop.Ay_set3dMinMaxDistance(Handle, minDist, maxDist);
}
public void Set3DAttenuation(AttenuationModelType attenuationModel, float rolloffFactor)
{
SoloudInterop.Ay_set3dAttenuation(Handle, (uint) attenuationModel, rolloffFactor);
}
public void Set3DDopplerFactor(float dopplerFactor)
{
SoloudInterop.Ay_set3dDopplerFactor(Handle, dopplerFactor);
}
public void Set3DListenerRelative()
{
throw new NotImplementedException();
}
public void Set3DDistanceDelay(int distanceDelay)
{
SoloudInterop.Ay_set3dDistanceDelay(Handle, distanceDelay);
}
public void Set3DCollider()
{
throw new NotImplementedException();
}
public void Set3DAttenuator()
{
throw new NotImplementedException();
}
public void SetInaudibleBehavior(bool mustTick, bool kill)
{
SoloudInterop.Ay_setInaudibleBehavior(Handle, mustTick ? 1 : 0, kill ? 1 : 0);
}
public void SetLoopPoint(double loopPoint)
{
SoloudInterop.Ay_setLoopPoint(Handle, loopPoint);
}
public double GetLoopPoint()
{
return SoloudInterop.Ay_getLoopPoint(Handle);
}
public void SetFilter()
{
throw new NotImplementedException();
}
public void Stop()
{
SoloudInterop.Ay_stop(Handle);
}
}
public class Filter
{
}
public class AudioCollider
{
}
public class AudioAttenuator
{
}