00001 #region --- OpenTK.OpenAL License ---
00002
00003
00004
00005
00006
00007
00008 #endregion
00009
00010 using System;
00011 using System.Runtime.InteropServices;
00012 using System.Security;
00013
00014 using OpenTK;
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 namespace OpenTK.Audio.OpenAL
00067 {
00071 public static partial class AL
00072 {
00073
00074 #region Constants
00075
00076 internal const string Lib = "openal32.dll";
00077 private const CallingConvention Style = CallingConvention.Cdecl;
00078
00079 #endregion Constants
00080
00081 #region Renderer State management
00082
00085 [DllImport(AL.Lib, EntryPoint = "alEnable", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00086 public static extern void Enable(ALCapability capability);
00087
00088
00091 [DllImport(AL.Lib, EntryPoint = "alDisable", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00092 public static extern void Disable(ALCapability capability);
00093
00094
00098 [DllImport(AL.Lib, EntryPoint = "alIsEnabled", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00099 public static extern bool IsEnabled(ALCapability capability);
00100
00101
00102 #endregion Renderer State management
00103
00104 #region State retrieval
00105
00106 [DllImport(AL.Lib, EntryPoint = "alGetString", ExactSpelling = true, CallingConvention = AL.Style, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity()]
00107 private static extern IntPtr GetStringPrivate(ALGetString param);
00108
00109
00113 public static string Get(ALGetString param)
00114 {
00115 return Marshal.PtrToStringAnsi(GetStringPrivate(param));
00116 }
00117
00121 public static string GetErrorString(ALError param)
00122 {
00123 return Marshal.PtrToStringAnsi(GetStringPrivate((ALGetString)param));
00124 }
00125
00126
00127
00128
00129
00130
00131
00132
00133
00137
00138
00139
00140
00141
00145 [DllImport(AL.Lib, EntryPoint = "alGetInteger", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00146 public static extern int Get(ALGetInteger param);
00147
00148
00152 [DllImport(AL.Lib, EntryPoint = "alGetFloat", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00153 public static extern float Get(ALGetFloat param);
00154
00155
00156
00160
00161
00162
00163
00164
00167 [DllImport(AL.Lib, EntryPoint = "alGetError", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00168 public static extern ALError GetError();
00169
00170
00171 #endregion State retrieval
00172
00173 #region Extension support.
00174
00178 [DllImport(AL.Lib, EntryPoint = "alIsExtensionPresent", ExactSpelling = true, CallingConvention = AL.Style, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity()]
00179 public static extern bool IsExtensionPresent([In] string extname);
00180
00181
00185 [DllImport(AL.Lib, EntryPoint = "alGetProcAddress", ExactSpelling = true, CallingConvention = AL.Style, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity()]
00186 public static extern IntPtr GetProcAddress([In] string fname);
00187
00188
00192 [DllImport(AL.Lib, EntryPoint = "alGetEnumValue", ExactSpelling = true, CallingConvention = AL.Style, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity()]
00193 public static extern int GetEnumValue([In] string ename);
00194
00195
00196 #endregion Extension support.
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 #region Set Listener parameters
00211
00215 [DllImport(AL.Lib, EntryPoint = "alListenerf", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00216 public static extern void Listener(ALListenerf param, float value);
00217
00218
00224 [DllImport(AL.Lib, EntryPoint = "alListener3f", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00225 public static extern void Listener(ALListener3f param, float value1, float value2, float value3);
00226
00227
00231 public static void Listener(ALListener3f param, ref Vector3 values)
00232 {
00233 Listener(param, values.X, values.Y, values.Z);
00234 }
00235
00236 [DllImport(AL.Lib, EntryPoint = "alListenerfv", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00237 unsafe private static extern void ListenerPrivate(ALListenerfv param, float* values);
00238
00239
00243 public static void Listener(ALListenerfv param, ref float[] values)
00244 {
00245 unsafe
00246 {
00247 fixed (float* ptr = &values[0])
00248 {
00249 ListenerPrivate(param, ptr);
00250 }
00251 }
00252 }
00253
00258 public static void Listener(ALListenerfv param, ref Vector3 at, ref Vector3 up)
00259 {
00260 float[] temp = new float[6];
00261
00262 temp[0] = at.X;
00263 temp[1] = at.Y;
00264 temp[2] = at.Z;
00265
00266 temp[3] = up.X;
00267 temp[4] = up.Y;
00268 temp[5] = up.Z;
00269
00270 unsafe
00271 {
00272 fixed (float* ptr = &temp[0])
00273 {
00274 ListenerPrivate(param, ptr);
00275 }
00276 }
00277 }
00278
00279
00280
00281
00282
00283
00284 #endregion Set Listener parameters
00285
00286 #region Get Listener parameters
00287
00291 [DllImport(AL.Lib, EntryPoint = "alGetListenerf", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00292 public static extern void GetListener(ALListenerf param, [Out] out float value);
00293
00294
00300 [DllImport(AL.Lib, EntryPoint = "alGetListener3f", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00301 public static extern void GetListener(ALListener3f param, [Out] out float value1, [Out] out float value2, [Out] out float value3);
00302
00303
00307 public static void GetListener(ALListener3f param, out Vector3 values)
00308 {
00309 GetListener(param, out values.X, out values.Y, out values.Z);
00310 }
00311
00315 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alGetListenerfv", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00316 unsafe public static extern void GetListener(ALListenerfv param, float* values);
00317
00318
00323 public static void GetListener(ALListenerfv param, out Vector3 at, out Vector3 up)
00324 {
00325 float[] pinned = new float[6];
00326 unsafe
00327 {
00328 fixed (float* ptr = &pinned[0])
00329 {
00330 GetListener(param, ptr);
00331
00332 at.X = pinned[0];
00333 at.Y = pinned[1];
00334 at.Z = pinned[2];
00335
00336 up.X = pinned[3];
00337 up.Y = pinned[4];
00338 up.Z = pinned[5];
00339 }
00340 }
00341 }
00342
00343
00344
00345
00346
00347
00348 #endregion Get Listener parameters
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387 #region Create Source objects
00388
00389 #region GenSources()
00390
00391 [DllImport(AL.Lib, EntryPoint = "alGenSources", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00392 unsafe private static extern void GenSourcesPrivate(int n, [Out] uint* sources);
00393
00394
00398 [CLSCompliant(false)]
00399 public static void GenSources(int n, out uint sources)
00400 {
00401 unsafe
00402 {
00403 fixed (uint* sources_ptr = &sources)
00404 {
00405 GenSourcesPrivate(n, sources_ptr);
00406 }
00407 }
00408 }
00409
00413 public static void GenSources(int n, out int sources)
00414 {
00415 unsafe
00416 {
00417 fixed (int* sources_ptr = &sources)
00418 {
00419 GenSourcesPrivate(n, (uint*)sources_ptr);
00420 }
00421 }
00422 }
00423
00426 public static void GenSources(int[] sources)
00427 {
00428 uint[] temp = new uint[sources.Length];
00429 GenSources(temp.Length, out temp[0]);
00430 for (int i = 0; i < temp.Length; i++)
00431 {
00432 sources[i] = (int)temp[i];
00433 }
00434 }
00435
00439 public static int[] GenSources(int n)
00440 {
00441 uint[] temp = new uint[n];
00442 GenSources(temp.Length, out temp[0]);
00443 int[] sources = new int[n];
00444 for (int i = 0; i < temp.Length; i++)
00445 {
00446 sources[i] = (int)temp[i];
00447 }
00448 return sources;
00449 }
00450
00453 public static int GenSource()
00454 {
00455 int temp;
00456 GenSources(1, out temp);
00457 return (int)temp;
00458 }
00459
00462 [CLSCompliant(false)]
00463 public static void GenSource(out uint source)
00464 {
00465 GenSources(1, out source);
00466 }
00467
00468 #endregion GenSources()
00469
00470 #region DeleteSources()
00471
00475 [CLSCompliant(false)]
00476 [DllImport(AL.Lib, EntryPoint = "alDeleteSources", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00477 unsafe public static extern void DeleteSources(int n, [In] uint* sources);
00478
00479
00483 [CLSCompliant(false)]
00484 [DllImport(AL.Lib, EntryPoint = "alDeleteSources", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00485 public static extern void DeleteSources(int n, ref uint sources);
00486
00490 [DllImport(AL.Lib, EntryPoint = "alDeleteSources", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00491 public static extern void DeleteSources(int n, ref int sources);
00492
00495 [CLSCompliant(false)]
00496 public static void DeleteSources(uint[] sources)
00497 {
00498 if (sources == null) throw new ArgumentNullException();
00499 if (sources.Length == 0) throw new ArgumentOutOfRangeException();
00500 DeleteBuffers(sources.Length, ref sources[0]);
00501 }
00502
00505 public static void DeleteSources(int[] sources)
00506 {
00507 if (sources == null) throw new ArgumentNullException();
00508 if (sources.Length == 0) throw new ArgumentOutOfRangeException();
00509 DeleteBuffers(sources.Length, ref sources[0]);
00510 }
00511
00514 [CLSCompliant(false)]
00515 public static void DeleteSource(ref uint source)
00516 {
00517 DeleteSources(1, ref source);
00518 }
00519
00522 public static void DeleteSource(int source)
00523 {
00524 DeleteSources(1, ref source);
00525 }
00526
00527 #endregion DeleteSources()
00528
00529 #region IsSource()
00530
00534 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alIsSource", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00535 public static extern bool IsSource(uint sid);
00536
00537
00541 public static bool IsSource(int sid)
00542 {
00543 return IsSource((uint)sid);
00544 }
00545
00546 #endregion IsSource()
00547
00548 #endregion Create Source objects
00549
00550 #region Set Source parameters
00551
00552 #region Sourcef
00553
00558 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alSourcef", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00559 public static extern void Source(uint sid, ALSourcef param, float value);
00560
00561
00566 public static void Source(int sid, ALSourcef param, float value)
00567 {
00568 Source((uint)sid, param, value);
00569 }
00570
00571 #endregion Sourcef
00572
00573 #region Source3f
00574
00581 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alSource3f", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00582 public static extern void Source(uint sid, ALSource3f param, float value1, float value2, float value3);
00583
00584
00591 public static void Source(int sid, ALSource3f param, float value1, float value2, float value3)
00592 {
00593 Source((uint)sid, param, value1, value2, value3);
00594 }
00595
00600 [CLSCompliant(false)]
00601 public static void Source(uint sid, ALSource3f param, ref Vector3 values)
00602 {
00603 Source(sid, param, values.X, values.Y, values.Z);
00604 }
00605
00610 public static void Source(int sid, ALSource3f param, ref Vector3 values)
00611 {
00612 Source((uint)sid, param, values.X, values.Y, values.Z);
00613 }
00614
00615 #endregion Source3f
00616
00617 #region Sourcei
00618
00623 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alSourcei", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00624 public static extern void Source(uint sid, ALSourcei param, int value);
00625
00626
00631 public static void Source(int sid, ALSourcei param, int value)
00632 {
00633 Source((uint)sid, param, value);
00634 }
00635
00640 [CLSCompliant(false)]
00641 public static void Source(uint sid, ALSourceb param, bool value)
00642 {
00643 Source(sid, (ALSourcei)param, (value) ? 1 : 0);
00644 }
00645
00650 public static void Source(int sid, ALSourceb param, bool value)
00651 {
00652 Source((uint)sid, (ALSourcei)param, (value) ? 1 : 0);
00653 }
00654
00658 [CLSCompliant(false)]
00659 public static void BindBufferToSource(uint source, uint buffer)
00660 {
00661 Source(source, ALSourcei.Buffer, (int)buffer);
00662 }
00663
00667 public static void BindBufferToSource(int source, int buffer)
00668 {
00669 Source((uint)source, ALSourcei.Buffer, buffer);
00670 }
00671
00672 #endregion Sourcei
00673
00674 #region Source3i
00675
00682 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alSource3i", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00683 public static extern void Source(uint sid, ALSource3i param, int value1, int value2, int value3);
00684
00685
00692 public static void Source(int sid, ALSource3i param, int value1, int value2, int value3)
00693 {
00694 Source((uint)sid, param, value1, value2, value3);
00695 }
00696
00697 #endregion Source3i
00698
00699
00700
00701
00702
00703 #endregion Set Source parameters
00704
00705 #region Get Source parameters
00706
00707 #region GetSourcef
00708
00713 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alGetSourcef", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00714 public static extern void GetSource(uint sid, ALSourcef param, [Out] out float value);
00715
00716
00721 public static void GetSource(int sid, ALSourcef param, out float value)
00722 {
00723 GetSource((uint)sid, param, out value);
00724 }
00725
00726 #endregion GetSourcef
00727
00728 #region GetSource3f
00729
00736 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alGetSource3f", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00737 public static extern void GetSource(uint sid, ALSource3f param, [Out] out float value1, [Out] out float value2, [Out] out float value3);
00738
00739
00746 public static void GetSource(int sid, ALSource3f param, out float value1, out float value2, out float value3)
00747 {
00748 GetSource((uint)sid, param, out value1, out value2, out value3);
00749 }
00750
00755 [CLSCompliant(false)]
00756 public static void GetSource(uint sid, ALSource3f param, out Vector3 values)
00757 {
00758 GetSource(sid, param, out values.X, out values.Y, out values.Z);
00759 }
00760
00765 public static void GetSource(int sid, ALSource3f param, out Vector3 values)
00766 {
00767 GetSource((uint)sid, param, out values.X, out values.Y, out values.Z);
00768 }
00769
00770 #endregion GetSource3f
00771
00772 #region GetSourcei
00773
00778 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alGetSourcei", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
00779 public static extern void GetSource(uint sid, ALGetSourcei param, [Out] out int value);
00780
00781
00786 public static void GetSource(int sid, ALGetSourcei param, out int value)
00787 {
00788 GetSource((uint)sid, param, out value);
00789 }
00790
00795 [CLSCompliant(false)]
00796 public static void GetSource(uint sid, ALSourceb param, out bool value)
00797 {
00798 int result;
00799 GetSource(sid, (ALGetSourcei)param, out result);
00800 value = result != 0;
00801 }
00802
00807 public static void GetSource(int sid, ALSourceb param, out bool value)
00808 {
00809 int result;
00810 GetSource((uint)sid, (ALGetSourcei)param, out result);
00811 value = result != 0;
00812 }
00813
00814 #endregion GetSourcei
00815
00816
00817
00818
00819
00820
00821 #endregion Get Source parameters
00822
00823 #region Source vector based playback calls
00824
00825 #region SourcePlay
00826
00830 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alSourcePlayv"), SuppressUnmanagedCodeSecurity]
00831 unsafe public static extern void SourcePlay(int ns, [In] uint* sids);
00832
00833
00837 [CLSCompliant(false)]
00838 public static void SourcePlay(int ns, uint[] sids)
00839 {
00840 unsafe
00841 {
00842 fixed (uint* ptr = sids)
00843 {
00844 SourcePlay(ns, ptr);
00845 }
00846 }
00847 }
00848
00852 public static void SourcePlay(int ns, int[] sids)
00853 {
00854 uint[] temp = new uint[ns];
00855 for (int i = 0; i < ns; i++)
00856 {
00857 temp[i] = (uint)sids[i];
00858 }
00859 SourcePlay(ns, temp);
00860 }
00861
00865 [CLSCompliant(false)]
00866 public static void SourcePlay(int ns, ref uint sids)
00867 {
00868 unsafe
00869 {
00870 fixed (uint* ptr = &sids)
00871 {
00872 SourcePlay(ns, ptr);
00873 }
00874 }
00875 }
00876
00877 #endregion SourcePlay
00878
00879 #region SourceStop
00880
00884 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alSourceStopv"), SuppressUnmanagedCodeSecurity]
00885 unsafe public static extern void SourceStop(int ns, [In] uint* sids);
00886
00887
00891 [CLSCompliant(false)]
00892 public static void SourceStop(int ns, uint[] sids)
00893 {
00894 unsafe
00895 {
00896 fixed (uint* ptr = sids)
00897 {
00898 SourceStop(ns, ptr);
00899 }
00900 }
00901 }
00902
00906 public static void SourceStop(int ns, int[] sids)
00907 {
00908 uint[] temp = new uint[ns];
00909 for (int i = 0; i < ns; i++)
00910 {
00911 temp[i] = (uint)sids[i];
00912 }
00913 SourceStop(ns, temp);
00914 }
00915
00919 [CLSCompliant(false)]
00920 public static void SourceStop(int ns, ref uint sids)
00921 {
00922 unsafe
00923 {
00924 fixed (uint* ptr = &sids)
00925 {
00926 SourceStop(ns, ptr);
00927 }
00928 }
00929 }
00930
00931 #endregion SourceStop
00932
00933 #region SourceRewind
00934
00938 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alSourceRewindv"), SuppressUnmanagedCodeSecurity]
00939 unsafe public static extern void SourceRewind(int ns, [In] uint* sids);
00940
00941
00945 [CLSCompliant(false)]
00946 public static void SourceRewind(int ns, uint[] sids)
00947 {
00948 unsafe
00949 {
00950 fixed (uint* ptr = sids)
00951 {
00952 SourceRewind(ns, ptr);
00953 }
00954 }
00955 }
00956
00960 public static void SourceRewind(int ns, int[] sids)
00961 {
00962 uint[] temp = new uint[ns];
00963 for (int i = 0; i < ns; i++)
00964 {
00965 temp[i] = (uint)sids[i];
00966 }
00967 SourceRewind(ns, temp);
00968 }
00969
00973 [CLSCompliant(false)]
00974 public static void SourceRewind(int ns, ref uint sids)
00975 {
00976 unsafe
00977 {
00978 fixed (uint* ptr = &sids)
00979 {
00980 SourceRewind(ns, ptr);
00981 }
00982 }
00983 }
00984
00985 #endregion SourceRewind
00986
00987 #region SourcePause
00988
00992 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alSourcePausev"), SuppressUnmanagedCodeSecurity]
00993 unsafe public static extern void SourcePause(int ns, [In] uint* sids);
00994
00995
00999 [CLSCompliant(false)]
01000 public static void SourcePause(int ns, uint[] sids)
01001 {
01002 unsafe
01003 {
01004 fixed (uint* ptr = sids)
01005 {
01006 SourcePause(ns, ptr);
01007 }
01008 }
01009 }
01013 public static void SourcePause(int ns, int[] sids)
01014 {
01015 uint[] temp = new uint[ns];
01016 for (int i = 0; i < ns; i++)
01017 {
01018 temp[i] = (uint)sids[i];
01019 }
01020 SourcePause(ns, temp);
01021 }
01022
01026 [CLSCompliant(false)]
01027 public static void SourcePause(int ns, ref uint sids)
01028 {
01029 unsafe
01030 {
01031 fixed (uint* ptr = &sids)
01032 {
01033 SourcePause(ns, ptr);
01034 }
01035 }
01036 }
01037
01038 #endregion SourcePause
01039
01040 #endregion Source vector based playback calls
01041
01042 #region Source based playback calls
01043
01044 #region SourcePlay
01045
01048 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alSourcePlay", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
01049 public static extern void SourcePlay(uint sid);
01050
01051
01054 public static void SourcePlay(int sid)
01055 {
01056 SourcePlay((uint)sid);
01057 }
01058
01059 #endregion SourcePlay
01060
01061 #region SourceStop
01062
01065 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alSourceStop", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
01066 public static extern void SourceStop(uint sid);
01067
01068
01071 public static void SourceStop(int sid)
01072 {
01073 SourceStop((uint)sid);
01074 }
01075
01076 #endregion SourceStop
01077
01078 #region SourceRewind
01079
01082 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alSourceRewind", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
01083 public static extern void SourceRewind(uint sid);
01084
01085
01088 public static void SourceRewind(int sid)
01089 {
01090 SourceRewind((uint)sid);
01091 }
01092
01093 #endregion SourceRewind
01094
01095 #region SourcePause
01096
01099 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alSourcePause", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
01100 public static extern void SourcePause(uint sid);
01101
01102
01105 public static void SourcePause(int sid)
01106 {
01107 SourcePause((uint)sid);
01108 }
01109
01110 #endregion SourcePause
01111
01112 #endregion Source based playback calls
01113
01114 #region Source Queuing
01115
01116 #region SourceQueueBuffers
01117
01122 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alSourceQueueBuffers"), SuppressUnmanagedCodeSecurity]
01123 unsafe public static extern void SourceQueueBuffers(uint sid, int numEntries, [In] uint* bids);
01124
01125
01130 [CLSCompliant(false)]
01131 public static void SourceQueueBuffers(uint sid, int numEntries, uint[] bids)
01132 {
01133 unsafe
01134 {
01135 fixed (uint* ptr = bids)
01136 {
01137 SourceQueueBuffers(sid, numEntries, ptr);
01138 }
01139 }
01140 }
01141
01146 public static void SourceQueueBuffers(int sid, int numEntries, int[] bids)
01147 {
01148 uint[] temp = new uint[numEntries];
01149 for (int i = 0; i < numEntries; i++)
01150 {
01151 temp[i] = (uint)bids[i];
01152 }
01153 SourceQueueBuffers((uint)sid, numEntries, temp);
01154 }
01155
01160 [CLSCompliant(false)]
01161 public static void SourceQueueBuffers(uint sid, int numEntries, ref uint bids)
01162 {
01163 unsafe
01164 {
01165 fixed (uint* ptr = &bids)
01166 {
01167 SourceQueueBuffers(sid, numEntries, ptr);
01168 }
01169 }
01170 }
01171
01175 public static void SourceQueueBuffer(int source, int buffer)
01176 {
01177 unsafe { AL.SourceQueueBuffers((uint)source, 1, (uint*)&buffer); }
01178 }
01179
01180 #endregion SourceQueueBuffers
01181
01182 #region SourceUnqueueBuffers
01183
01188 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alSourceUnqueueBuffers"), SuppressUnmanagedCodeSecurity]
01189 unsafe public static extern void SourceUnqueueBuffers(uint sid, int numEntries, [In] uint* bids);
01190
01191
01196 [CLSCompliant(false)]
01197 [DllImport(AL.Lib, EntryPoint = "alSourceUnqueueBuffers"), SuppressUnmanagedCodeSecurity]
01198 public static extern void SourceUnqueueBuffers(uint sid, int numEntries, [Out] uint[] bids);
01199
01204 [DllImport(AL.Lib, EntryPoint = "alSourceUnqueueBuffers"), SuppressUnmanagedCodeSecurity]
01205 public static extern void SourceUnqueueBuffers(int sid, int numEntries, [Out] int[] bids);
01206
01211 [CLSCompliant(false)]
01212 [DllImport(AL.Lib, EntryPoint = "alSourceUnqueueBuffers"), SuppressUnmanagedCodeSecurity]
01213 public static extern void SourceUnqueueBuffers(uint sid, int numEntries, ref uint bids);
01214
01219 [DllImport(AL.Lib, EntryPoint = "alSourceUnqueueBuffers"), SuppressUnmanagedCodeSecurity]
01220 public static extern void SourceUnqueueBuffers(int sid, int numEntries, ref int bids);
01221
01224 public static int SourceUnqueueBuffer(int sid)
01225 {
01226 uint buf;
01227 unsafe { SourceUnqueueBuffers((uint)sid, 1, &buf); }
01228 return (int)buf;
01229 }
01230
01234 public static int[] SourceUnqueueBuffers(int sid, int numEntries)
01235 {
01236 if (numEntries <= 0) throw new ArgumentOutOfRangeException("numEntries", "Must be greater than zero.");
01237 int[] buf = new int[numEntries];
01238 SourceUnqueueBuffers(sid, numEntries, buf);
01239 return buf;
01240 }
01241
01242 #endregion SourceUnqueueBuffers
01243
01244 #endregion Source Queuing
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260 #region Buffer objects
01261
01262 #region GenBuffers
01263
01267 [CLSCompliant(false)]
01268 [DllImport(AL.Lib, EntryPoint = "alGenBuffers", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity]
01269 unsafe public static extern void GenBuffers(int n, [Out] uint* buffers);
01270
01271
01275 [CLSCompliant(false)]
01276 [DllImport(AL.Lib, EntryPoint = "alGenBuffers", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity]
01277 public static extern void GenBuffers(int n, out uint buffers);
01278
01282 [DllImport(AL.Lib, EntryPoint = "alGenBuffers", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity]
01283 public static extern void GenBuffers(int n, out int buffers);
01284
01288 public static int[] GenBuffers(int n)
01289 {
01290 int[] buffers = new int[n];
01291 GenBuffers(buffers.Length, out buffers[0]);
01292 return buffers;
01293 }
01294
01297 public static int GenBuffer()
01298 {
01299 int temp;
01300 GenBuffers(1, out temp);
01301 return (int)temp;
01302 }
01303
01306 [CLSCompliant(false)]
01307 public static void GenBuffer(out uint buffer)
01308 {
01309 GenBuffers(1, out buffer);
01310 }
01311
01312 #endregion GenBuffers
01313
01314 #region DeleteBuffers
01315
01319 [CLSCompliant(false)]
01320 [DllImport(AL.Lib, EntryPoint = "alDeleteBuffers", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
01321 unsafe public static extern void DeleteBuffers(int n, [In] uint* buffers);
01322
01323
01327 [CLSCompliant(false)]
01328 [DllImport(AL.Lib, EntryPoint = "alDeleteBuffers", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
01329 public static extern void DeleteBuffers(int n, [In] ref uint buffers);
01330
01334 [DllImport(AL.Lib, EntryPoint = "alDeleteBuffers", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
01335 public static extern void DeleteBuffers(int n, [In] ref int buffers);
01336
01339 [CLSCompliant(false)]
01340 public static void DeleteBuffers(uint[] buffers)
01341 {
01342 if (buffers == null) throw new ArgumentNullException();
01343 if (buffers.Length == 0) throw new ArgumentOutOfRangeException();
01344 DeleteBuffers(buffers.Length, ref buffers[0]);
01345 }
01346
01349 public static void DeleteBuffers(int[] buffers)
01350 {
01351 if (buffers == null) throw new ArgumentNullException();
01352 if (buffers.Length == 0) throw new ArgumentOutOfRangeException();
01353 DeleteBuffers(buffers.Length, ref buffers[0]);
01354 }
01355
01358 [CLSCompliant(false)]
01359 public static void DeleteBuffer(ref uint buffer)
01360 {
01361 DeleteBuffers(1, ref buffer);
01362 }
01363
01366 public static void DeleteBuffer(int buffer)
01367 {
01368 DeleteBuffers(1, ref buffer);
01369 }
01370
01371 #endregion DeleteBuffers
01372
01373 #region IsBuffer
01374
01378 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alIsBuffer", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
01379 public static extern bool IsBuffer(uint bid);
01380
01381
01385 public static bool IsBuffer(int bid)
01386 {
01387 uint temp = (uint)bid;
01388 return IsBuffer(temp);
01389 }
01390
01391 #endregion IsBuffer
01392
01393 #region BufferData
01394
01401 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alBufferData", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
01402 public static extern void BufferData(uint bid, ALFormat format, IntPtr buffer, int size, int freq);
01403
01404
01411 public static void BufferData(int bid, ALFormat format, IntPtr buffer, int size, int freq)
01412 {
01413 BufferData((uint)bid, format, buffer, size, freq);
01414 }
01415
01422 public static void BufferData<TBuffer>(int bid, ALFormat format, TBuffer[] buffer, int size, int freq)
01423 where TBuffer : struct
01424 {
01425 if (!BlittableValueType.Check(buffer))
01426 throw new ArgumentException("buffer");
01427
01428 GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
01429 try { BufferData(bid, format, handle.AddrOfPinnedObject(), size, freq); }
01430 finally { handle.Free(); }
01431 }
01432
01433 #endregion BufferData
01434
01435 #endregion Buffer objects
01436
01437 #region Set Buffer parameters (currently parameters can only be read)
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461 #endregion Set Buffer parameters
01462
01463 #region Get Buffer parameters
01464
01465 #region GetBufferi
01466
01471 [CLSCompliant(false), DllImport(AL.Lib, EntryPoint = "alGetBufferi", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
01472 public static extern void GetBuffer(uint bid, ALGetBufferi param, [Out] out int value);
01473
01474
01479 public static void GetBuffer(int bid, ALGetBufferi param, out int value)
01480 {
01481 GetBuffer((uint)bid, param, out value);
01482 }
01483
01484 #endregion GetBufferi
01485
01486
01487
01488
01489
01490
01491
01492 #endregion Get Buffer parameters
01493
01494 #region Global Parameters
01495
01498 [DllImport(AL.Lib, EntryPoint = "alDopplerFactor", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
01499 public static extern void DopplerFactor(float value);
01500
01501
01504 [DllImport(AL.Lib, EntryPoint = "alDopplerVelocity", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
01505 public static extern void DopplerVelocity(float value);
01506
01507
01510 [DllImport(AL.Lib, EntryPoint = "alSpeedOfSound", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
01511 public static extern void SpeedOfSound(float value);
01512
01513
01545 [DllImport(AL.Lib, EntryPoint = "alDistanceModel", ExactSpelling = true, CallingConvention = AL.Style), SuppressUnmanagedCodeSecurity()]
01546 public static extern void DistanceModel(ALDistanceModel distancemodel);
01547
01548
01549 #endregion Global Parameters
01550
01551 #region Helpers
01552
01556 [CLSCompliant(false)]
01557 public static ALSourceState GetSourceState(uint sid)
01558 {
01559 int temp;
01560 AL.GetSource(sid, ALGetSourcei.SourceState, out temp);
01561 return (ALSourceState)temp;
01562 }
01563
01567 public static ALSourceState GetSourceState(int sid)
01568 {
01569 int temp;
01570 AL.GetSource(sid, ALGetSourcei.SourceState, out temp);
01571 return (ALSourceState)temp;
01572 }
01573
01577 [CLSCompliant(false)]
01578 public static ALSourceType GetSourceType(uint sid)
01579 {
01580 int temp;
01581 AL.GetSource(sid, ALGetSourcei.SourceType, out temp);
01582 return (ALSourceType)temp;
01583 }
01584
01588 public static ALSourceType GetSourceType(int sid)
01589 {
01590 int temp;
01591 AL.GetSource(sid, ALGetSourcei.SourceType, out temp);
01592 return (ALSourceType)temp;
01593 }
01594
01599 public static ALDistanceModel GetDistanceModel()
01600 {
01601 return (ALDistanceModel)AL.Get(ALGetInteger.DistanceModel);
01602 }
01603
01604 #endregion Helpers
01605 }
01606 }