mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-25 18:05:37 +00:00
Initial commit of OpenTK.OpenAL.
This commit is contained in:
parent
1af4b016f0
commit
59456c6a6f
598
Source/OpenTK/OpenAL/AlFunctions.cs
Normal file
598
Source/OpenTK/OpenAL/AlFunctions.cs
Normal file
|
@ -0,0 +1,598 @@
|
|||
#region --- OpenTK.OpenAL License ---
|
||||
/* AlFunctions.cs
|
||||
* C header: \OpenAL 1.1 SDK\include\Al.h
|
||||
* Spec: http://www.openal.org/openal_webstf/specs/OpenAL11Specification.pdf
|
||||
* Copyright (c) 2008 Christoph Brandtner and Stefanos Apostolopoulos
|
||||
* See license.txt for license details (MIT)
|
||||
* http://www.OpenTK.net
|
||||
*/
|
||||
|
||||
/* Version History:
|
||||
* 0.1
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
using OpenTK.Math;
|
||||
|
||||
/* Type Mapping
|
||||
// 8-bit boolean
|
||||
typedef char ALboolean;
|
||||
* byte
|
||||
// character
|
||||
typedef char ALchar;
|
||||
* byte
|
||||
// signed 8-bit 2's complement integer
|
||||
typedef char ALbyte;
|
||||
* byte
|
||||
|
||||
// unsigned 8-bit integer
|
||||
typedef unsigned char ALubyte;
|
||||
* ubyte
|
||||
|
||||
// signed 16-bit 2's complement integer
|
||||
typedef short ALshort;
|
||||
* short
|
||||
|
||||
// unsigned 16-bit integer
|
||||
typedef unsigned short ALushort;
|
||||
* ushort
|
||||
|
||||
// unsigned 32-bit integer
|
||||
typedef unsigned int ALuint;
|
||||
* uint
|
||||
|
||||
// signed 32-bit 2's complement integer
|
||||
typedef int ALint;
|
||||
* int
|
||||
// non-negative 32-bit binary integer size
|
||||
typedef int ALsizei;
|
||||
* int
|
||||
// enumerated 32-bit value
|
||||
typedef int ALenum;
|
||||
* int
|
||||
|
||||
// 32-bit IEEE754 floating-point
|
||||
typedef float ALfloat;
|
||||
* float
|
||||
|
||||
// 64-bit IEEE754 floating-point
|
||||
typedef double ALdouble;
|
||||
* double
|
||||
|
||||
// void type (for opaque pointers only)
|
||||
typedef void ALvoid;
|
||||
* void
|
||||
*/
|
||||
|
||||
namespace OpenTK.OpenAL
|
||||
{
|
||||
// Al = Audio Library
|
||||
public static class Al
|
||||
{
|
||||
#region Constants
|
||||
public const string Lib = "OpenAL32.dll";
|
||||
private const CallingConvention Style = CallingConvention.Cdecl;
|
||||
#endregion Constants
|
||||
|
||||
#region Type Helpers
|
||||
/// <summary>An IntPtr.Zero that can be used as Al.Null, for convenience.</summary>
|
||||
public static readonly IntPtr Null = IntPtr.Zero; // do NOT touch.
|
||||
|
||||
/// <summary>OpenAL 8-Bit Boolean char, can either be True or False.</summary>
|
||||
public enum Bool : byte
|
||||
{
|
||||
///<summary>Boolean False.</summary>
|
||||
False = 0,
|
||||
///<summary>Boolean True.</summary>
|
||||
True = 1,
|
||||
}
|
||||
#endregion Type Helpers
|
||||
|
||||
#region Renderer State management
|
||||
[DllImport( Al.Lib, EntryPoint = "alEnable", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void Enable( Enums.AlCapability capability );
|
||||
//AL_API void AL_APIENTRY alEnable( ALenum capability );
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alDisable", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void Disable( Enums.AlCapability capability );
|
||||
// AL_API void AL_APIENTRY alDisable( ALenum capability );
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alIsEnabled", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern Al.Bool IsEnabled( Enums.AlCapability capability );
|
||||
// AL_API ALboolean AL_APIENTRY alIsEnabled( ALenum capability );
|
||||
#endregion Renderer State management
|
||||
|
||||
#region State retrieval
|
||||
[DllImport( Al.Lib, EntryPoint = "alGetString", ExactSpelling = true, CallingConvention = Al.Style, CharSet = CharSet.Ansi ), SuppressUnmanagedCodeSecurity( )]
|
||||
private static extern IntPtr GetStringInternal( int param ); // accepts the enums Enums.AlError, Enums.AlContextString
|
||||
// AL_API const ALchar* AL_APIENTRY alGetString( ALenum param );
|
||||
|
||||
internal static string GetString( int param )
|
||||
{
|
||||
return Marshal.PtrToStringAnsi( GetStringInternal( param ) );
|
||||
}
|
||||
|
||||
/* no functions return more than 1 result ..
|
||||
// AL_API void AL_APIENTRY alGetBooleanv( ALenum param, ALboolean* data );
|
||||
// AL_API void AL_APIENTRY alGetIntegerv( ALenum param, ALint* data );
|
||||
// AL_API void AL_APIENTRY alGetFloatv( ALenum param, ALfloat* data );
|
||||
// AL_API void AL_APIENTRY alGetDoublev( ALenum param, ALdouble* data );
|
||||
*/
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alGetBoolean", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern Al.Bool alGetBoolean( Enums.AlGlobalTweakage param );
|
||||
// AL_API ALboolean AL_APIENTRY alGetBoolean( ALenum param );
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alGetInteger", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern int GetInteger( Enums.AlGlobalTweakage param );
|
||||
// AL_API ALint AL_APIENTRY alGetInteger( ALenum param );
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alGetFloat", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern float GetFloat( Enums.AlGlobalTweakage param );
|
||||
// AL_API ALfloat AL_APIENTRY alGetFloat( ALenum param );
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alGetDouble", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern double GetDouble( Enums.AlGlobalTweakage param );
|
||||
// AL_API ALdouble AL_APIENTRY alGetDouble( ALenum param );
|
||||
|
||||
/// <summary>Error support. Obtain the most recent error generated in the AL state machine. When an error is detected by AL, a flag is set and the error code is recorded. Further errors, if they occur, do not affect this recorded code. When alGetError is called, the code is returned and the flag is cleared, so that a further error will again record its code.</summary>
|
||||
/// <returns>The first error that occured. can be used with Al.GetString</returns>
|
||||
[DllImport( Al.Lib, EntryPoint = "alGetError", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern Enums.AlError GetError( );
|
||||
// AL_API ALenum AL_APIENTRY alGetError( void );
|
||||
#endregion State retrieval
|
||||
|
||||
#region Extension support.
|
||||
// Query for the presence of an extension, and obtain any appropriate function pointers and enum values.
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alIsExtensionPresent", ExactSpelling = true, CallingConvention = Al.Style, CharSet = CharSet.Ansi ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern Al.Bool IsExtensionPresent( [In] string extname );
|
||||
// AL_API ALboolean AL_APIENTRY alIsExtensionPresent( const ALchar* extname );
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alGetProcAddress", ExactSpelling = true, CallingConvention = Al.Style, CharSet = CharSet.Ansi ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern IntPtr GetProcAddress( [In] string fname );
|
||||
// AL_API void* AL_APIENTRY alGetProcAddress( const ALchar* fname );
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alGetEnumValue", ExactSpelling = true, CallingConvention = Al.Style, CharSet = CharSet.Ansi ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern int GetEnumValue( [In] string ename );
|
||||
// AL_API ALenum AL_APIENTRY alGetEnumValue( const ALchar* ename );
|
||||
#endregion Extension support.
|
||||
|
||||
/*
|
||||
* Listener
|
||||
* Listener represents the location and orientation of the
|
||||
* 'user' in 3D-space.
|
||||
*
|
||||
* Properties include: -
|
||||
*
|
||||
* Gain AL_GAIN ALfloat
|
||||
* Position AL_POSITION ALfloat[3]
|
||||
* Velocity AL_VELOCITY ALfloat[3]
|
||||
* Orientation AL_ORIENTATION ALfloat[6] (Forward then Up vectors)
|
||||
*/
|
||||
|
||||
#region Set Listener parameters
|
||||
|
||||
// AL_API void AL_APIENTRY alListenerf( ALenum param, ALfloat value );
|
||||
[DllImport( Al.Lib, EntryPoint = "alListenerf", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void Listenerf( Enums.AlListenerf param, float value );
|
||||
|
||||
// AL_API void AL_APIENTRY alListener3f( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
[DllImport( Al.Lib, EntryPoint = "alListener3f", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void Listener3f( Enums.AlListener3f param, float value1, float value2, float value3 );
|
||||
|
||||
internal static void Listener3f( Enums.AlListener3f param, Vector3 value )
|
||||
{
|
||||
Listener3f( param, value.X, value.Y, value.Z );
|
||||
}
|
||||
|
||||
// AL_API void AL_APIENTRY alListenerfv( ALenum param, const ALfloat* values );
|
||||
[DllImport( Al.Lib, EntryPoint = "alListenerfv", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
unsafe private static extern void Listenerfv( Enums.AlListenerfv param, float* values );
|
||||
|
||||
internal static void Listenerfv( Enums.AlListenerfv param, ref float[] values )
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed ( float* ptr = &values[0] )
|
||||
{
|
||||
Listenerfv( param, ptr );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// AL_API void AL_APIENTRY alListeneri( ALenum param, ALint value );
|
||||
// AL_API void AL_APIENTRY alListener3i( ALenum param, ALint value1, ALint value2, ALint value3 );
|
||||
// AL_API void AL_APIENTRY alListeneriv( ALenum param, const ALint* values );
|
||||
#endregion Set Listener parameters
|
||||
|
||||
#region Get Listener parameters
|
||||
|
||||
// AL_API void AL_APIENTRY alGetListenerf( ALenum param, ALfloat* value );
|
||||
[DllImport( Al.Lib, EntryPoint = "alGetListenerf", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
unsafe internal static extern void GetListenerf( Enums.AlListenerf param, float* value );
|
||||
|
||||
// AL_API void AL_APIENTRY alGetListener3f( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 );
|
||||
[DllImport( Al.Lib, EntryPoint = "alGetListener3f", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
unsafe internal static extern void GetListener3f( Enums.AlListener3f param, float* value1, float* value2, float* value3 );
|
||||
|
||||
// AL_API void AL_APIENTRY alGetListenerfv( ALenum param, ALfloat* values );
|
||||
[DllImport( Al.Lib, EntryPoint = "alGetListenerfv", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
unsafe internal static extern void GetListenerfv( Enums.AlListenerfv param, float* values );
|
||||
|
||||
// AL_API void AL_APIENTRY alGetListeneri( ALenum param, ALint* value );
|
||||
// AL_API void AL_APIENTRY alGetListener3i( ALenum param, ALint *value1, ALint *value2, ALint *value3 );
|
||||
// AL_API void AL_APIENTRY alGetListeneriv( ALenum param, ALint* values );
|
||||
#endregion Get Listener parameters
|
||||
|
||||
/*
|
||||
* Source
|
||||
* Sources represent individual sound objects in 3D-space.
|
||||
* Sources take the PCM data provided in the specified Buffer,
|
||||
* apply Source-specific modifications, and then
|
||||
* submit them to be mixed according to spatial arrangement etc.
|
||||
*
|
||||
* Properties include: -
|
||||
*
|
||||
|
||||
* Position AL_POSITION ALfloat[3]
|
||||
* Velocity AL_VELOCITY ALfloat[3]
|
||||
* Direction AL_DIRECTION ALfloat[3]
|
||||
|
||||
* Head Relative Mode AL_SOURCE_RELATIVE ALint (AL_TRUE or AL_FALSE)
|
||||
* Looping AL_LOOPING ALint (AL_TRUE or AL_FALSE)
|
||||
*
|
||||
* Reference Distance AL_REFERENCE_DISTANCE ALfloat
|
||||
* Max Distance AL_MAX_DISTANCE ALfloat
|
||||
* RollOff Factor AL_ROLLOFF_FACTOR ALfloat
|
||||
* Pitch AL_PITCH ALfloat
|
||||
* Gain AL_GAIN ALfloat
|
||||
* Min Gain AL_MIN_GAIN ALfloat
|
||||
* Max Gain AL_MAX_GAIN ALfloat
|
||||
* Inner Angle AL_CONE_INNER_ANGLE ALint or ALfloat
|
||||
* Outer Angle AL_CONE_OUTER_ANGLE ALint or ALfloat
|
||||
* Cone Outer Gain AL_CONE_OUTER_GAIN ALint or ALfloat
|
||||
*
|
||||
* MS Offset AL_MSEC_OFFSET ALint or ALfloat
|
||||
* Byte Offset AL_BYTE_OFFSET ALint or ALfloat
|
||||
* Sample Offset AL_SAMPLE_OFFSET ALint or ALfloat
|
||||
* Attached Buffer AL_BUFFER ALint
|
||||
*
|
||||
* State (Query only) AL_SOURCE_STATE ALint
|
||||
* Buffers Queued (Query only) AL_BUFFERS_QUEUED ALint
|
||||
* Buffers Processed (Query only) AL_BUFFERS_PROCESSED ALint
|
||||
*/
|
||||
|
||||
#region Create Source objects
|
||||
[DllImport( Al.Lib, EntryPoint = "alGenSources", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
unsafe private static extern void GenSourcesInternal( int n, [Out] uint* sources );
|
||||
// AL_API void AL_APIENTRY alGenSources( ALsizei n, ALuint* Sources );
|
||||
|
||||
internal static void GenSources( int n, [Out] out uint sources )
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed ( uint* ptr = &sources )
|
||||
{
|
||||
GenSourcesInternal( n, (uint*) ptr );
|
||||
sources = *ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alDeleteSources", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
unsafe private static extern void DeleteSourcesInternal( int n, [In] uint* sources ); // Delete Source objects
|
||||
// AL_API void AL_APIENTRY alDeleteSources( ALsizei n, const ALuint* Sources );
|
||||
|
||||
internal static void DeleteSources( int n, uint[] sources )
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed ( uint* ptr = sources )
|
||||
{
|
||||
DeleteSourcesInternal( n, (uint*) ptr );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alIsSource", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern Al.Bool IsSource( uint sid ); // Verify a handle is a valid Source
|
||||
// AL_API ALboolean AL_APIENTRY alIsSource( ALuint sid );
|
||||
#endregion Create Source objects
|
||||
|
||||
#region Set Source parameters
|
||||
[DllImport( Al.Lib, EntryPoint = "alSourcef", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void Sourcef( uint sid, Enums.AlSourcef param, float value );
|
||||
// AL_API void AL_APIENTRY alSourcef( ALuint sid, ALenum param, ALfloat value );
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alSource3f", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void Source3f( uint sid, Enums.AlSource3f param, float value1, float value2, float value3 );
|
||||
// AL_API void AL_APIENTRY alSource3f( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
|
||||
internal static void Sourcev3( uint sid, Enums.AlSource3f param, ref Vector3 values )
|
||||
{
|
||||
Source3f( sid, param, values.X, values.Y, values.Z );
|
||||
}
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alSourcei", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void alSourcei( uint sid, Enums.AlSourcei param, int value );
|
||||
// AL_API void AL_APIENTRY alSourcei( ALuint sid, ALenum param, ALint value );
|
||||
|
||||
internal static void alSourceBool( uint sid, Enums.AlSourceBool param, bool value )
|
||||
{
|
||||
alSourcei( sid, (Enums.AlSourcei) param, ( value ) ? 1 : 0 );
|
||||
}
|
||||
|
||||
// AL_API void AL_APIENTRY alSourcefv( ALuint sid, ALenum param, const ALfloat* values );
|
||||
// AL_API void AL_APIENTRY alSource3i( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 );
|
||||
// AL_API void AL_APIENTRY alSourceiv( ALuint sid, ALenum param, const ALint* values );
|
||||
#endregion Set Source parameters
|
||||
|
||||
#region Get Source parameters
|
||||
[DllImport( Al.Lib, EntryPoint = "alGetSourcef", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void GetSourcef( uint sid, Enums.AlSourcef param, [Out] out float value );
|
||||
// AL_API void AL_APIENTRY alGetSourcef( ALuint sid, ALenum param, ALfloat* value );
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alGetSource3f", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void GetSource3f( uint sid, Enums.AlSource3f param, [Out] out float value1, [Out] out float value2, [Out] out float value3 );
|
||||
// AL_API void AL_APIENTRY alGetSource3f( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
|
||||
|
||||
internal static void GetSource3f( uint sid, Enums.AlSource3f param, out Vector3 values )
|
||||
{
|
||||
GetSource3f( sid, param, out values.X, out values.Y, out values.Z );
|
||||
}
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alGetSourcei", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void GetSourcei( uint sid, Enums.AlSourceiGet param, [Out] out int value );
|
||||
// AL_API void AL_APIENTRY alGetSourcei( ALuint sid, ALenum param, ALint* value );
|
||||
|
||||
public static void GetSourceBool( uint sid, Enums.AlSourceBool param, [Out] out bool value )
|
||||
{
|
||||
int result;
|
||||
GetSourcei( sid, (Enums.AlSourceiGet) param, out result );
|
||||
if ( result == 1 )
|
||||
value = true;
|
||||
else
|
||||
value = false;
|
||||
}
|
||||
|
||||
// AL_API void AL_APIENTRY alGetSourcefv( ALuint sid, ALenum param, ALfloat* values );
|
||||
// AL_API void AL_APIENTRY alGetSource3i( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3);
|
||||
// AL_API void AL_APIENTRY alGetSourceiv( ALuint sid, ALenum param, ALint* values );
|
||||
#endregion Get Source parameters
|
||||
|
||||
#region Source vector based playback calls
|
||||
// Play, replay, or resume (if paused) a list of Sources
|
||||
// AL_API void AL_APIENTRY alSourcePlayv( ALsizei ns, const ALuint *sids );
|
||||
|
||||
// Stop a list of Sources
|
||||
// AL_API void AL_APIENTRY alSourceStopv( ALsizei ns, const ALuint *sids );
|
||||
|
||||
// Rewind a list of Sources
|
||||
// AL_API void AL_APIENTRY alSourceRewindv( ALsizei ns, const ALuint *sids );
|
||||
|
||||
// Pause a list of Sources
|
||||
// AL_API void AL_APIENTRY alSourcePausev( ALsizei ns, const ALuint *sids );
|
||||
#endregion Source vector based playback calls
|
||||
|
||||
#region Source based playback calls
|
||||
[DllImport( Al.Lib, EntryPoint = "alSourcePlay", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void SourcePlay( uint sid );// Play, replay, or resume a Source
|
||||
// AL_API void AL_APIENTRY alSourcePlay( ALuint sid );
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alSourceStop", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void SourceStop( uint sid ); // Stop a Source
|
||||
// AL_API void AL_APIENTRY alSourceStop( ALuint sid );
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alSourceRewind", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void SourceRewind( uint sid );// Rewind a Source (set playback postiton to beginning)
|
||||
// AL_API void AL_APIENTRY alSourceRewind( ALuint sid );
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alSourcePause", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void SourcePause( uint sid ); // Pause a Source
|
||||
// AL_API void AL_APIENTRY alSourcePause( ALuint sid );
|
||||
#endregion Source based playback calls
|
||||
|
||||
#region Source Queuing
|
||||
// AL_API void AL_APIENTRY alSourceQueueBuffers( ALuint sid, ALsizei numEntries, const ALuint *bids );
|
||||
|
||||
// AL_API void AL_APIENTRY alSourceUnqueueBuffers( ALuint sid, ALsizei numEntries, ALuint *bids );
|
||||
|
||||
#endregion Source Queuing
|
||||
|
||||
/*
|
||||
* Buffer
|
||||
* Buffer objects are storage space for sample data.
|
||||
* Buffers are referred to by Sources. One Buffer can be used
|
||||
* by multiple Sources.
|
||||
*
|
||||
* Properties include: -
|
||||
*
|
||||
* Frequency (Query only) AL_FREQUENCY ALint
|
||||
* Size (Query only) AL_SIZE ALint
|
||||
* Bits (Query only) AL_BITS ALint
|
||||
* Channels (Query only) AL_CHANNELS ALint
|
||||
*/
|
||||
|
||||
#region Buffer objects
|
||||
[DllImport( Al.Lib, EntryPoint = "alGenBuffers", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
unsafe private static extern void GenBuffersInternal( int n, [Out] uint* buffers );
|
||||
// AL_API void AL_APIENTRY alGenBuffers( ALsizei n, ALuint* Buffers );
|
||||
|
||||
internal static void GenBuffers( int n, [Out] out uint buffers )
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed ( uint* ptr = &buffers )
|
||||
{
|
||||
GenBuffersInternal( n, (uint*) ptr );
|
||||
buffers = *ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alDeleteBuffers", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
unsafe private static extern void DeleteBuffersInternal( int n, [In] uint* buffers ); // Delete Buffer objects
|
||||
// AL_API void AL_APIENTRY alDeleteBuffers( ALsizei n, const ALuint* Buffers );
|
||||
|
||||
internal static void DeleteBuffers( int n, uint[] buffers )
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed ( uint* ptr = buffers )
|
||||
{
|
||||
DeleteBuffersInternal( n, (uint*) ptr );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify a handle is a valid Buffer
|
||||
/// </summary>
|
||||
/// <param name="bid">a buffer previously allocated with <see cref="Al.GenBuffers"/>.</param>
|
||||
/// <returns>success</returns>
|
||||
[DllImport( Al.Lib, EntryPoint = "alIsBuffer", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern Al.Bool IsBuffer( uint bid );
|
||||
// AL_API ALboolean AL_APIENTRY alIsBuffer( ALuint bid );
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alBufferData", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void BufferData( uint bid, Enums.AlFormat format, IntPtr data, int size, int freq ); // Specify the data to be copied into a Buffer
|
||||
// AL_API void AL_APIENTRY alBufferData( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq );
|
||||
#endregion Buffer objects
|
||||
|
||||
#region Set Buffer parameters (currently parameters can only be read)
|
||||
// AL_API void AL_APIENTRY alBufferf( ALuint bid, ALenum param, ALfloat value );
|
||||
|
||||
// AL_API void AL_APIENTRY alBuffer3f( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
/* [DllImport( Al.Lib, EntryPoint = "alBuffer3f", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void Buffer3f( uint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
|
||||
internal static void Bufferv3( uint bid, Alenum param, ref Vector3 values )
|
||||
{
|
||||
Buffer3f( bid, param, values.X, values.Y, values.Z );
|
||||
}*/
|
||||
|
||||
// AL_API void AL_APIENTRY alBufferfv( ALuint bid, ALenum param, const ALfloat* values );
|
||||
// AL_API void AL_APIENTRY alBufferi( ALuint bid, ALenum param, ALint value );
|
||||
// AL_API void AL_APIENTRY alBuffer3i( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 );
|
||||
// AL_API void AL_APIENTRY alBufferiv( ALuint bid, ALenum param, const ALint* values );
|
||||
#endregion Set Buffer parameters
|
||||
|
||||
#region Get Buffer parameters
|
||||
[DllImport( Al.Lib, EntryPoint = "alGetBufferi", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern Al.Bool alGetBufferi( uint bid, Enums.AlBufferAttribute param, [Out] out float value );
|
||||
// AL_API void AL_APIENTRY alGetBufferi( ALuint bid, ALenum param, ALint* value );
|
||||
|
||||
|
||||
// AL_API void AL_APIENTRY alGetBufferf( ALuint bid, ALenum param, ALfloat* value );
|
||||
// AL_API void AL_APIENTRY alGetBuffer3f( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
|
||||
// AL_API void AL_APIENTRY alGetBufferfv( ALuint bid, ALenum param, ALfloat* values );
|
||||
// AL_API void AL_APIENTRY alGetBuffer3i( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3);
|
||||
// AL_API void AL_APIENTRY alGetBufferiv( ALuint bid, ALenum param, ALint* values );
|
||||
#endregion Get Buffer parameters
|
||||
|
||||
#region Global Parameters
|
||||
[DllImport( Al.Lib, EntryPoint = "alDopplerFactor", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void DopplerFactor( float value );
|
||||
// AL_API void AL_APIENTRY alDopplerFactor( ALfloat value );
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alDopplerVelocity", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void DopplerVelocity( float value );
|
||||
// AL_API void AL_APIENTRY alDopplerVelocity( ALfloat value );
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alSpeedOfSound", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void SpeedOfSound( float value );
|
||||
// AL_API void AL_APIENTRY alSpeedOfSound( ALfloat value );
|
||||
|
||||
[DllImport( Al.Lib, EntryPoint = "alDistanceModel", ExactSpelling = true, CallingConvention = Al.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void DistanceModel( Enums.AlDistanceModels distancemodel );
|
||||
// AL_API void AL_APIENTRY alDistanceModel( ALenum distanceModel );
|
||||
#endregion Global Parameters
|
||||
|
||||
/*
|
||||
#else // AL_NO_PROTOTYPES
|
||||
|
||||
typedef void (AL_APIENTRY *LPALENABLE)( ALenum capability );
|
||||
typedef void (AL_APIENTRY *LPALDISABLE)( ALenum capability );
|
||||
typedef ALboolean (AL_APIENTRY *LPALISENABLED)( ALenum capability );
|
||||
typedef const ALchar* (AL_APIENTRY *LPALGETSTRING)( ALenum param );
|
||||
typedef void (AL_APIENTRY *LPALGETBOOLEANV)( ALenum param, ALboolean* data );
|
||||
typedef void (AL_APIENTRY *LPALGETINTEGERV)( ALenum param, ALint* data );
|
||||
typedef void (AL_APIENTRY *LPALGETFLOATV)( ALenum param, ALfloat* data );
|
||||
typedef void (AL_APIENTRY *LPALGETDOUBLEV)( ALenum param, ALdouble* data );
|
||||
typedef ALboolean (AL_APIENTRY *LPALGETBOOLEAN)( ALenum param );
|
||||
typedef ALint (AL_APIENTRY *LPALGETINTEGER)( ALenum param );
|
||||
typedef ALfloat (AL_APIENTRY *LPALGETFLOAT)( ALenum param );
|
||||
typedef ALdouble (AL_APIENTRY *LPALGETDOUBLE)( ALenum param );
|
||||
typedef ALenum (AL_APIENTRY *LPALGETERROR)( void );
|
||||
typedef ALboolean (AL_APIENTRY *LPALISEXTENSIONPRESENT)(const ALchar* extname );
|
||||
typedef void* (AL_APIENTRY *LPALGETPROCADDRESS)( const ALchar* fname );
|
||||
typedef ALenum (AL_APIENTRY *LPALGETENUMVALUE)( const ALchar* ename );
|
||||
typedef void (AL_APIENTRY *LPALListenerF)( ALenum param, ALfloat value );
|
||||
typedef void (AL_APIENTRY *LPALListener3F)( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
typedef void (AL_APIENTRY *LPALListenerFV)( ALenum param, const ALfloat* values );
|
||||
typedef void (AL_APIENTRY *LPALListenerI)( ALenum param, ALint value );
|
||||
typedef void (AL_APIENTRY *LPALListener3I)( ALenum param, ALint value1, ALint value2, ALint value3 );
|
||||
typedef void (AL_APIENTRY *LPALListenerIV)( ALenum param, const ALint* values );
|
||||
typedef void (AL_APIENTRY *LPALGETListenerF)( ALenum param, ALfloat* value );
|
||||
typedef void (AL_APIENTRY *LPALGETListener3F)( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 );
|
||||
typedef void (AL_APIENTRY *LPALGETListenerFV)( ALenum param, ALfloat* values );
|
||||
typedef void (AL_APIENTRY *LPALGETListenerI)( ALenum param, ALint* value );
|
||||
typedef void (AL_APIENTRY *LPALGETListener3I)( ALenum param, ALint *value1, ALint *value2, ALint *value3 );
|
||||
typedef void (AL_APIENTRY *LPALGETListenerIV)( ALenum param, ALint* values );
|
||||
typedef void (AL_APIENTRY *LPALGENSourceS)( ALsizei n, ALuint* Sources );
|
||||
typedef void (AL_APIENTRY *LPALDELETESourceS)( ALsizei n, const ALuint* Sources );
|
||||
typedef ALboolean (AL_APIENTRY *LPALISSource)( ALuint sid );
|
||||
typedef void (AL_APIENTRY *LPALSourceF)( ALuint sid, ALenum param, ALfloat value);
|
||||
typedef void (AL_APIENTRY *LPALSource3F)( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
typedef void (AL_APIENTRY *LPALSourceFV)( ALuint sid, ALenum param, const ALfloat* values );
|
||||
typedef void (AL_APIENTRY *LPALSourceI)( ALuint sid, ALenum param, ALint value);
|
||||
typedef void (AL_APIENTRY *LPALSource3I)( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 );
|
||||
typedef void (AL_APIENTRY *LPALSourceIV)( ALuint sid, ALenum param, const ALint* values );
|
||||
typedef void (AL_APIENTRY *LPALGETSourceF)( ALuint sid, ALenum param, ALfloat* value );
|
||||
typedef void (AL_APIENTRY *LPALGETSource3F)( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
|
||||
typedef void (AL_APIENTRY *LPALGETSourceFV)( ALuint sid, ALenum param, ALfloat* values );
|
||||
typedef void (AL_APIENTRY *LPALGETSourceI)( ALuint sid, ALenum param, ALint* value );
|
||||
typedef void (AL_APIENTRY *LPALGETSource3I)( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3);
|
||||
typedef void (AL_APIENTRY *LPALGETSourceIV)( ALuint sid, ALenum param, ALint* values );
|
||||
typedef void (AL_APIENTRY *LPALSourcePLAYV)( ALsizei ns, const ALuint *sids );
|
||||
typedef void (AL_APIENTRY *LPALSourceSTOPV)( ALsizei ns, const ALuint *sids );
|
||||
typedef void (AL_APIENTRY *LPALSourceREWINDV)( ALsizei ns, const ALuint *sids );
|
||||
typedef void (AL_APIENTRY *LPALSourcePAUSEV)( ALsizei ns, const ALuint *sids );
|
||||
typedef void (AL_APIENTRY *LPALSourcePLAY)( ALuint sid );
|
||||
typedef void (AL_APIENTRY *LPALSourceSTOP)( ALuint sid );
|
||||
typedef void (AL_APIENTRY *LPALSourceREWIND)( ALuint sid );
|
||||
typedef void (AL_APIENTRY *LPALSourcePAUSE)( ALuint sid );
|
||||
typedef void (AL_APIENTRY *LPALSourceQUEUEBufferS)(ALuint sid, ALsizei numEntries, const ALuint *bids );
|
||||
typedef void (AL_APIENTRY *LPALSourceUNQUEUEBufferS)(ALuint sid, ALsizei numEntries, ALuint *bids );
|
||||
typedef void (AL_APIENTRY *LPALGENBufferS)( ALsizei n, ALuint* Buffers );
|
||||
typedef void (AL_APIENTRY *LPALDELETEBufferS)( ALsizei n, const ALuint* Buffers );
|
||||
typedef ALboolean (AL_APIENTRY *LPALISBuffer)( ALuint bid );
|
||||
typedef void (AL_APIENTRY *LPALBufferDATA)( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq );
|
||||
typedef void (AL_APIENTRY *LPALBufferF)( ALuint bid, ALenum param, ALfloat value);
|
||||
typedef void (AL_APIENTRY *LPALBuffer3F)( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
typedef void (AL_APIENTRY *LPALBufferFV)( ALuint bid, ALenum param, const ALfloat* values );
|
||||
typedef void (AL_APIENTRY *LPALBufferI)( ALuint bid, ALenum param, ALint value);
|
||||
typedef void (AL_APIENTRY *LPALBuffer3I)( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 );
|
||||
typedef void (AL_APIENTRY *LPALBufferIV)( ALuint bid, ALenum param, const ALint* values );
|
||||
typedef void (AL_APIENTRY *LPALGETBufferF)( ALuint bid, ALenum param, ALfloat* value );
|
||||
typedef void (AL_APIENTRY *LPALGETBuffer3F)( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
|
||||
typedef void (AL_APIENTRY *LPALGETBufferFV)( ALuint bid, ALenum param, ALfloat* values );
|
||||
typedef void (AL_APIENTRY *LPALGETBufferI)( ALuint bid, ALenum param, ALint* value );
|
||||
typedef void (AL_APIENTRY *LPALGETBuffer3I)( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3);
|
||||
typedef void (AL_APIENTRY *LPALGETBufferIV)( ALuint bid, ALenum param, ALint* values );
|
||||
typedef void (AL_APIENTRY *LPALDOPPLERFACTOR)( ALfloat value );
|
||||
typedef void (AL_APIENTRY *LPALDOPPLERVELOCITY)( ALfloat value );
|
||||
typedef void (AL_APIENTRY *LPALSPEEDOFSOUND)( ALfloat value );
|
||||
typedef void (AL_APIENTRY *LPALDISTANCEMODEL)( ALenum distanceModel );
|
||||
*/
|
||||
}
|
||||
}
|
271
Source/OpenTK/OpenAL/AlTokens.cs
Normal file
271
Source/OpenTK/OpenAL/AlTokens.cs
Normal file
|
@ -0,0 +1,271 @@
|
|||
#region --- OpenTK.OpenAL License ---
|
||||
/* AlTokens.cs
|
||||
* C header: \OpenAL 1.1 SDK\include\Al.h
|
||||
* Spec: http://www.openal.org/openal_webstf/specs/OpenAL11Specification.pdf
|
||||
* Copyright (c) 2008 Christoph Brandtner and Stefanos Apostolopoulos
|
||||
* See license.txt for license details (MIT)
|
||||
* http://www.OpenTK.net
|
||||
*/
|
||||
|
||||
/* Version History:
|
||||
* 0.1
|
||||
* - Tokens AL_TRUE and AL_FALSE removed, created new type. see Al.Bool
|
||||
*
|
||||
*
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenTK.OpenAL
|
||||
{
|
||||
public partial class Enums
|
||||
{
|
||||
public enum AlCapability : int
|
||||
{
|
||||
///<summary>Currently no state toggles exist for vanilla OpenAL.</summary>
|
||||
Invalid = -1,
|
||||
}
|
||||
|
||||
public enum AlListenerf : int
|
||||
{
|
||||
///<summary>Indicate the gain (volume amplification) applied. Type: float. Range: [0.0f - ? ] A value of 1.0 means un-attenuated/unchanged. Each division by 2 equals an attenuation of -6dB. Each multiplicaton with 2 equals an amplification of +6dB. A value of 0.0f is meaningless with respect to a logarithmic scale; it is interpreted as zero volume - the channel is effectively disabled.</summary>
|
||||
Gain = 0x100A,
|
||||
}
|
||||
|
||||
public enum AlListener3f : int
|
||||
{
|
||||
///<summary>Specify the current location in three dimensional space. OpenAL, like OpenGL, uses a right handed coordinate system, where in a frontal default view X (thumb) points right, Y points up (index finger), and Z points towards the viewer/camera (middle finger). To switch from a left handed coordinate system, flip the sign on the Z coordinate. Listener position is always in the world coordinate system.</summary>
|
||||
Position = 0x1004,
|
||||
|
||||
///<summary>Specify the current velocity in three dimensional space.</summary>
|
||||
Velocity = 0x1006,
|
||||
}
|
||||
|
||||
public enum AlListenerfv : int
|
||||
{
|
||||
///<summary>Indicate Listener orientation. (at/up)</summary>
|
||||
Orientation = 0x100F,
|
||||
}
|
||||
|
||||
public enum AlSourcef : int
|
||||
{
|
||||
///<summary>Source specific reference distance. Type: float Range: [0.0f - float.PositiveInfinity] At 0.0f, no distance attenuation occurs. Default is 1.0.</summary>
|
||||
ReferenceDistance = 0x1020,
|
||||
|
||||
///<summary>Indicate distance above which Sources are not attenuated using the inverse clamped distance model. Default: float.PositiveInfinity Type: ALfloat Range: [0.0f - float.PositiveInfinity]</summary>
|
||||
MaxDistance = 0x1023,
|
||||
|
||||
///<summary>Source specific rolloff factor. Type: float Range: [0.0f - float.PositiveInfinity]</summary>
|
||||
RolloffFactor = 0x1021,
|
||||
|
||||
///<summary>Specify the pitch to be applied, either at Source, or on mixer results, at Listener. Range: [0.5f - 2.0f] Default: 1.0f</summary>
|
||||
Pitch = 0x1003,
|
||||
|
||||
///<summary>Indicate the gain (volume amplification) applied. Type: float. Range: [0.0f - ? ] A value of 1.0 means un-attenuated/unchanged. Each division by 2 equals an attenuation of -6dB. Each multiplicaton with 2 equals an amplification of +6dB. A value of 0.0f is meaningless with respect to a logarithmic scale; it is interpreted as zero volume - the channel is effectively disabled.</summary>
|
||||
Gain = 0x100A,
|
||||
|
||||
///<summary>Indicate minimum Source attenuation. Type: float Range: [0.0f - 1.0f] (Logarthmic)</summary>
|
||||
MinGain = 0x100D,
|
||||
|
||||
///<summary>Indicate maximum Source attenuation. Type: float Range: [0.0f - 1.0f] (Logarthmic)</summary>
|
||||
MaxGain = 0x100E,
|
||||
|
||||
///<summary>Directional Source, inner cone angle, in degrees. Range: [0-360] Default: 360</summary>
|
||||
ConeInnerAngle = 0x1001,
|
||||
|
||||
///<summary>Directional Source, outer cone angle, in degrees. Range: [0-360] Default: 360</summary>
|
||||
ConeOuterAngle = 0x1002,
|
||||
|
||||
///<summary>Directional Source, outer cone gain. Default: 0.0f Range: [0.0f - 1.0] (Logarithmic)</summary>
|
||||
ConeOuterGain = 0x1022,
|
||||
}
|
||||
|
||||
public enum AlSource3f : int
|
||||
{
|
||||
///<summary>Specify the current location in three dimensional space. OpenAL, like OpenGL, uses a right handed coordinate system, where in a frontal default view X (thumb) points right, Y points up (index finger), and Z points towards the viewer/camera (middle finger). To switch from a left handed coordinate system, flip the sign on the Z coordinate. Listener position is always in the world coordinate system.</summary>
|
||||
Position = 0x1004,
|
||||
|
||||
///<summary>Specify the current velocity in three dimensional space.</summary>
|
||||
Velocity = 0x1006,
|
||||
|
||||
///<summary>Specify the current direction.</summary>
|
||||
Direction = 0x1005,
|
||||
}
|
||||
|
||||
public enum AlSourcei : int
|
||||
{
|
||||
// Source Buffer position information
|
||||
MiliSecOffset = 0x1024, // AL_EXT_OFFSET extension.
|
||||
ByteOffset = 0x1026, // AL_EXT_OFFSET extension.
|
||||
SampleOffset = 0x1025, // AL_EXT_OFFSET extension.
|
||||
|
||||
///<summary>Indicate the Buffer to provide sound samples. Type: uint Range: any valid Buffer id.</summary>
|
||||
Buffer = 0x1009,
|
||||
}
|
||||
|
||||
public enum AlSourceBool : int
|
||||
{
|
||||
///<summary>Indicate Source has relative coordinates.</summary>
|
||||
SourceRelative = 0x202,
|
||||
|
||||
///<summary>Indicate whether Source is looping. Type: Alboolean Range: [True, False] Default: False.</summary>
|
||||
Looping = 0x1007,
|
||||
}
|
||||
|
||||
public enum AlSourceiGet : int
|
||||
{
|
||||
// Source Buffer position information
|
||||
MiliSecOffset = 0x1024, // AL_EXT_OFFSET extension.
|
||||
ByteOffset = 0x1026, // AL_EXT_OFFSET extension.
|
||||
SampleOffset = 0x1025, // AL_EXT_OFFSET extension.
|
||||
|
||||
///<summary>Indicate the Buffer to provide sound samples. Type: uint Range: any valid Buffer id.</summary>
|
||||
Buffer = 0x1009,
|
||||
|
||||
SourceState = 0x1010,
|
||||
BuffersQueued = 0x1015,
|
||||
BuffersProcessed = 0x1016,
|
||||
}
|
||||
|
||||
|
||||
public enum AlSourceParameterszzzzzzzzzzzzzzzzzz : int
|
||||
{
|
||||
|
||||
///<summary>Specify the channel mask. (Creative) Type: uint Range: [0 - 255]</summary>
|
||||
ChannelMask = 0x3000,
|
||||
}
|
||||
|
||||
///<summary>Source state information.</summary>
|
||||
public enum AlSourcestate : int
|
||||
{
|
||||
Initial = 0x1011,
|
||||
Playing = 0x1012,
|
||||
Paused = 0x1013,
|
||||
Stopped = 0x1014,
|
||||
}
|
||||
|
||||
// AL_EXT_OFFSET extension.
|
||||
public enum AlSourceBufferPos : int
|
||||
{
|
||||
|
||||
///<summary>Source type (Static, Streaming or undetermined)</summary>
|
||||
SourceType = 0x1027,
|
||||
}
|
||||
|
||||
///<summary>Source type (Static, Streaming or undetermined)</summary>
|
||||
public enum AlSourceType : int
|
||||
{
|
||||
///<summary>Source is Static if a Buffer has been attached using AL_Buffer</summary>
|
||||
Static = 0x1028,
|
||||
///<summary>Source is Streaming if one or more Buffers have been attached using alSourceQueueBuffers</summary>
|
||||
Streaming = 0x1029,
|
||||
///<summary>Source is undetermined when it has the NULL Buffer attached</summary>
|
||||
Undetermined = 0x1030,
|
||||
}
|
||||
|
||||
///<summary>Sound samples: Format specifier.</summary>
|
||||
public enum AlFormat : int
|
||||
{
|
||||
///<summary>1 Channel, 8 Bit.</summary>
|
||||
FormatMono8 = 0x1100,
|
||||
|
||||
///<summary>1 Channel, 16 Bit.</summary>
|
||||
FormatMono16 = 0x1101,
|
||||
|
||||
///<summary>2 Channels, 8 Bit each.</summary>
|
||||
FormatStereo8 = 0x1102,
|
||||
|
||||
///<summary>2 Channels, 16 Bit each.</summary>
|
||||
FormatStereo16 = 0x1103,
|
||||
}
|
||||
|
||||
public enum AlBufferAttribute : int
|
||||
{
|
||||
///<summary>Sound samples: frequency, in units of Hertz [Hz]. This is the number of samples per second. Half of the sample frequency marks the maximum significant frequency component.</summary>
|
||||
Frequency = 0x2001,
|
||||
Bits = 0x2002,
|
||||
Channels = 0x2003,
|
||||
Size = 0x2004,
|
||||
}
|
||||
|
||||
///<summary>Buffer state. Not supported for public use (yet).</summary>
|
||||
public enum AlBufferState : int
|
||||
{
|
||||
///<summary>Buffer state. Not supported for public use (yet).</summary>
|
||||
Unused = 0x2010,
|
||||
///<summary>Buffer state. Not supported for public use (yet).</summary>
|
||||
Pending = 0x2011,
|
||||
///<summary>Buffer state. Not supported for public use (yet).</summary>
|
||||
Processed = 0x2012,
|
||||
}
|
||||
|
||||
public enum AlError : int // alGetString
|
||||
{
|
||||
///<summary>No OpenAL Error.</summary>
|
||||
NoError = 0,
|
||||
|
||||
///<summary>Invalid Name paramater passed to OpenAL call.</summary>
|
||||
InvalidName = 0xA001,
|
||||
|
||||
///<summary>Invalid parameter passed to OpenAL call.</summary>
|
||||
IllegalEnum = 0xA002,
|
||||
///<summary>Invalid parameter passed to OpenAL call.</summary>
|
||||
InvalidEnum = 0xA002,
|
||||
|
||||
///<summary>Invalid OpenAL enum parameter value.</summary>
|
||||
InvalidValue = 0xA003,
|
||||
|
||||
///<summary>Illegal OpenAL call.</summary>
|
||||
IllegalCommand = 0xA004,
|
||||
///<summary>Illegal OpenAL call.</summary>
|
||||
InvalidOperation = 0xA004,
|
||||
|
||||
///<summary>No mojo. No OpenAL Memory left.</summary>
|
||||
OutOfMemory = 0xA005,
|
||||
}
|
||||
|
||||
public enum AlContextString : int // alGetString
|
||||
{// Context strings: Vendor Name.
|
||||
Vendor = 0xB001,
|
||||
Version = 0xB002,
|
||||
Renderer = 0xB003,
|
||||
Extensions = 0xB004,
|
||||
}
|
||||
|
||||
public enum AlGlobalTweakage : int // alGetBool/Int/Float/Double
|
||||
{// Global tweakage.
|
||||
///<summary>Doppler scale. Default 1.0</summary>
|
||||
DopplerFactor = 0xC000,
|
||||
|
||||
///<summary>Tweaks speed of propagation.</summary>
|
||||
DopplerVelocity = 0xC001, // TODO : Verify!
|
||||
|
||||
///<summary>Speed of Sound in units per second. default value 343.3f</summary>
|
||||
SpeedOfSound = 0xC003,
|
||||
|
||||
/// <see cref="AlDistanceModels"/>
|
||||
DistanceModel = 0xD000,
|
||||
}
|
||||
|
||||
// ALenum distanceModel
|
||||
public enum AlDistanceModels : int// used in conjunction with DistanceModel
|
||||
{
|
||||
///<summary>bypasses all distance attenuation calculation for all sources.</summary>
|
||||
None = 0,
|
||||
|
||||
///<summary>InverseDistance is equivalent to the IASIG I3DL2 model with the exception that AL_REFERENCE_DISTANCE does not imply any clamping.</summary>
|
||||
InverseDistance = 0xD001,
|
||||
///<summary>InverseDistanceClamped is the IASIG I3DL2 model, with AL_REFERENCE_DISTANCE indicating both the reference distance and the distance below which gain will be clamped.</summary>
|
||||
InverseDistanceClamped = 0xD002,
|
||||
///<summary></summary>
|
||||
LinearDistance = 0xD003, // AL_EXT_LINEAR_DISTANCE extension.
|
||||
///<summary></summary>
|
||||
LinearDistanceClamped = 0xD004, // AL_EXT_LINEAR_DISTANCE extension.
|
||||
///<summary></summary>
|
||||
ExponentDistance = 0xD005, // AL_EXT_EXPONENT_DISTANCE extension.
|
||||
///<summary></summary>
|
||||
ExponentDistanceClamped = 0xD006, // AL_EXT_EXPONENT_DISTANCE extension.
|
||||
}
|
||||
}
|
||||
}
|
218
Source/OpenTK/OpenAL/AlcFunctions.cs
Normal file
218
Source/OpenTK/OpenAL/AlcFunctions.cs
Normal file
|
@ -0,0 +1,218 @@
|
|||
#region --- OpenTK.OpenAL License ---
|
||||
/* AlcFunctions.cs
|
||||
* C header: \OpenAL 1.1 SDK\include\Alc.h
|
||||
* Spec: http://www.openal.org/openal_webstf/specs/OpenAL11Specification.pdf
|
||||
* Copyright (c) 2008 Christoph Brandtner and Stefanos Apostolopoulos
|
||||
* See license.txt for license details (MIT)
|
||||
* http://www.OpenTK.net
|
||||
*/
|
||||
|
||||
/* Version History:
|
||||
* 0.1
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
/* Type Mapping
|
||||
// 8-bit boolean
|
||||
typedef char ALCboolean;
|
||||
* byte
|
||||
// character
|
||||
typedef char ALCchar;
|
||||
* byte
|
||||
// signed 8-bit 2's complement integer
|
||||
typedef char ALCbyte;
|
||||
* byte
|
||||
|
||||
// unsigned 8-bit integer
|
||||
typedef unsigned char ALCubyte;
|
||||
* ubyte
|
||||
|
||||
// signed 16-bit 2's complement integer
|
||||
typedef short ALCshort;
|
||||
* short
|
||||
|
||||
// unsigned 16-bit integer
|
||||
typedef unsigned short ALCushort;
|
||||
* ushort
|
||||
|
||||
// unsigned 32-bit integer
|
||||
typedef unsigned int ALCuint;
|
||||
* uint
|
||||
|
||||
// signed 32-bit 2's complement integer
|
||||
typedef int ALCint;
|
||||
* int
|
||||
// non-negative 32-bit binary integer size
|
||||
typedef int ALCsizei;
|
||||
* int
|
||||
// enumerated 32-bit value
|
||||
typedef int ALCenum;
|
||||
* int
|
||||
|
||||
// 32-bit IEEE754 floating-point
|
||||
typedef float ALCfloat;
|
||||
* float
|
||||
|
||||
// 64-bit IEEE754 floating-point
|
||||
typedef double ALCdouble;
|
||||
* double
|
||||
|
||||
// void type (for opaque pointers only)
|
||||
typedef void ALCvoid;
|
||||
* void
|
||||
|
||||
* ALCdevice
|
||||
* ALCcontext *context
|
||||
* IntPtr
|
||||
*/
|
||||
|
||||
namespace OpenTK.OpenAL
|
||||
{
|
||||
/// <summary>Alc = Audio Library Context</summary>
|
||||
public static class Alc
|
||||
{
|
||||
#region Constants
|
||||
private const string Lib = Al.Lib;
|
||||
private const CallingConvention Style = CallingConvention.Cdecl;
|
||||
#endregion Constants
|
||||
|
||||
#region Context Management
|
||||
// ALC_API ALCcontext * ALC_APIENTRY alcCreateContext( ALCdevice *device, const ALCint* attrlist );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcCreateContext", ExactSpelling = true, CallingConvention = Alc.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern IntPtr CreateContext( [In] IntPtr device, [In] IntPtr attrlist );
|
||||
|
||||
// ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent( ALCcontext *context );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcMakeContextCurrent", ExactSpelling = true, CallingConvention = Alc.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern Al.Bool MakeContextCurrent( [In] IntPtr context );
|
||||
|
||||
// ALC_API void ALC_APIENTRY alcProcessContext( ALCcontext *context );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcProcessContext", ExactSpelling = true, CallingConvention = Alc.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void ProcessContext( [In] IntPtr context );
|
||||
|
||||
// ALC_API void ALC_APIENTRY alcSuspendContext( ALCcontext *context );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcSuspendContext", ExactSpelling = true, CallingConvention = Alc.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void SuspendContext( [In] IntPtr context );
|
||||
|
||||
|
||||
// ALC_API void ALC_APIENTRY alcDestroyContext( ALCcontext *context );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcDestroyContext", ExactSpelling = true, CallingConvention = Alc.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void DestroyContext( [In] IntPtr context );
|
||||
|
||||
// ALC_API ALCcontext * ALC_APIENTRY alcGetCurrentContext( void );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcGetCurrentContext", ExactSpelling = true, CallingConvention = Alc.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern IntPtr GetCurrentContext( );
|
||||
|
||||
// ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice( ALCcontext *context );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcGetContextsDevice", ExactSpelling = true, CallingConvention = Alc.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern IntPtr GetContextsDevice( [In] IntPtr context );
|
||||
#endregion Context Management
|
||||
|
||||
#region Device Management
|
||||
// ALC_API ALCdevice * ALC_APIENTRY alcOpenDevice( const ALCchar *devicename );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcOpenDevice", ExactSpelling = true, CallingConvention = Alc.Style, CharSet = CharSet.Ansi ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern IntPtr OpenDevice( [In] string devicename );
|
||||
|
||||
// ALC_API ALCboolean ALC_APIENTRY alcCloseDevice( ALCdevice *device );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcCloseDevice", ExactSpelling = true, CallingConvention = Alc.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern Al.Bool CloseDevice( [In] IntPtr device );
|
||||
#endregion Device Management
|
||||
|
||||
#region Error support.
|
||||
// Obtain the most recent Context error
|
||||
|
||||
// ALC_API ALCenum ALC_APIENTRY alcGetError( ALCdevice *device );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcGetError", ExactSpelling = true, CallingConvention = Alc.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern Enums.AlcError GetError( [In] IntPtr device );
|
||||
#endregion Error support.
|
||||
|
||||
#region Extension support.
|
||||
// Query for the presence of an extension, and obtain any appropriate function pointers and enum values.
|
||||
|
||||
// ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent( ALCdevice *device, const ALCchar *extname );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcIsExtensionPresent", ExactSpelling = true, CallingConvention = Alc.Style, CharSet = CharSet.Ansi ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern Al.Bool IsExtensionPresent( [In] IntPtr device, [In] string extname );
|
||||
|
||||
// ALC_API void * ALC_APIENTRY alcGetProcAddress( ALCdevice *device, const ALCchar *funcname );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcGetProcAddress", ExactSpelling = true, CallingConvention = Alc.Style, CharSet = CharSet.Ansi ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern IntPtr GetProcAddress( [In] IntPtr device, [In] string funcname );
|
||||
|
||||
// ALC_API ALCenum ALC_APIENTRY alcGetEnumValue( ALCdevice *device, const ALCchar *enumname );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcGetEnumValue", ExactSpelling = true, CallingConvention = Alc.Style, CharSet = CharSet.Ansi ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern int GetEnumValue( [In] IntPtr device, [In] string enumname );
|
||||
#endregion Extension support.
|
||||
|
||||
#region Query functions
|
||||
// ALC_API const ALCchar * ALC_APIENTRY alcGetString( ALCdevice *device, ALCenum param );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcGetString", ExactSpelling = true, CallingConvention = Alc.Style, CharSet = CharSet.Ansi ), SuppressUnmanagedCodeSecurity( )]
|
||||
private static extern IntPtr GetStringInternal( [In] IntPtr device, Enums.AlcGetString param );
|
||||
|
||||
internal static string GetString( IntPtr device, Enums.AlcGetString param )
|
||||
{
|
||||
return Marshal.PtrToStringAnsi( GetStringInternal( device, param ) );
|
||||
}
|
||||
|
||||
internal static string GetStringDevices( )
|
||||
{
|
||||
return Marshal.PtrToStringBSTR( GetStringInternal( Al.Null, Enums.AlcGetString.DeviceSpecifier ));
|
||||
}
|
||||
|
||||
// ALC_API void ALC_APIENTRY alcGetIntegerv( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *data );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcGetIntegerv", ExactSpelling = true, CallingConvention = Alc.Style, CharSet = CharSet.Ansi ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void GetInteger( [In] IntPtr device, Enums.AlcGetInteger param, int sizeofdatainbytes, [Out] out int data );
|
||||
#endregion Query functions
|
||||
|
||||
#region Capture functions
|
||||
// ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcCaptureOpenDevice", ExactSpelling = true, CallingConvention = Alc.Style, CharSet = CharSet.Ansi ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern IntPtr CaptureOpenDevice( string devicename, uint frequency, Enums.AlFormat format, int buffersize );
|
||||
|
||||
// ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice( ALCdevice *device );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcCaptureCloseDevice", ExactSpelling = true, CallingConvention = Alc.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern Al.Bool CaptureCloseDevice( [In] IntPtr device );
|
||||
|
||||
// ALC_API void ALC_APIENTRY alcCaptureStart( ALCdevice *device );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcCaptureStart", ExactSpelling = true, CallingConvention = Alc.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void CaptureStart( [In] IntPtr device );
|
||||
|
||||
// ALC_API void ALC_APIENTRY alcCaptureStop( ALCdevice *device );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcCaptureStop", ExactSpelling = true, CallingConvention = Alc.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void CaptureStop( [In] IntPtr device );
|
||||
|
||||
// ALC_API void ALC_APIENTRY alcCaptureSamples( ALCdevice *device, ALCvoid *buffer, ALCsizei samples );
|
||||
[DllImport( Alc.Lib, EntryPoint = "alcCaptureSamples", ExactSpelling = true, CallingConvention = Alc.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern void CaptureSamples( [In] IntPtr device, [Out] out IntPtr buffer, [Out] out int samples );
|
||||
#endregion Capture functions
|
||||
|
||||
/* delegates
|
||||
// Pointer-to-function types, useful for dynamically getting ALC entry points.
|
||||
|
||||
typedef ALCcontext * (ALC_APIENTRY *LPALCCREATECONTEXT) (ALCdevice *device, const ALCint *attrlist);
|
||||
typedef ALCboolean (ALC_APIENTRY *LPALCMAKECONTEXTCURRENT)( ALCcontext *context );
|
||||
typedef void (ALC_APIENTRY *LPALCPROCESSCONTEXT)( ALCcontext *context );
|
||||
typedef void (ALC_APIENTRY *LPALCSUSPENDCONTEXT)( ALCcontext *context );
|
||||
typedef void (ALC_APIENTRY *LPALCDESTROYCONTEXT)( ALCcontext *context );
|
||||
typedef ALCcontext * (ALC_APIENTRY *LPALCGETCURRENTCONTEXT)( void );
|
||||
typedef ALCdevice * (ALC_APIENTRY *LPALCGETCONTEXTSDEVICE)( ALCcontext *context );
|
||||
typedef ALCdevice * (ALC_APIENTRY *LPALCOPENDEVICE)( const ALCchar *devicename );
|
||||
typedef ALCboolean (ALC_APIENTRY *LPALCCLOSEDEVICE)( ALCdevice *device );
|
||||
typedef ALCenum (ALC_APIENTRY *LPALCGETERROR)( ALCdevice *device );
|
||||
typedef ALCboolean (ALC_APIENTRY *LPALCISEXTENSIONPRESENT)( ALCdevice *device, const ALCchar *extname );
|
||||
typedef void * (ALC_APIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname );
|
||||
typedef ALCenum (ALC_APIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname );
|
||||
typedef const ALCchar* (ALC_APIENTRY *LPALCGETSTRING)( ALCdevice *device, ALCenum param );
|
||||
typedef void (ALC_APIENTRY *LPALCGETINTEGERV)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest );
|
||||
typedef ALCdevice * (ALC_APIENTRY *LPALCCAPTUREOPENDEVICE)( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei Buffersize );
|
||||
typedef ALCboolean (ALC_APIENTRY *LPALCCAPTURECLOSEDEVICE)( ALCdevice *device );
|
||||
typedef void (ALC_APIENTRY *LPALCCAPTURESTART)( ALCdevice *device );
|
||||
typedef void (ALC_APIENTRY *LPALCCAPTURESTOP)( ALCdevice *device );
|
||||
typedef void (ALC_APIENTRY *LPALCCAPTURESAMPLES)( ALCdevice *device, ALCvoid *Buffer, ALCsizei samples );
|
||||
*/
|
||||
}
|
||||
}
|
104
Source/OpenTK/OpenAL/AlcTokens.cs
Normal file
104
Source/OpenTK/OpenAL/AlcTokens.cs
Normal file
|
@ -0,0 +1,104 @@
|
|||
#region --- OpenTK.OpenAL License ---
|
||||
/* AlcTokens.cs
|
||||
* C header: \OpenAL 1.1 SDK\include\Alc.h
|
||||
* Spec: http://www.openal.org/openal_webstf/specs/OpenAL11Specification.pdf
|
||||
* Copyright (c) 2008 Christoph Brandtner and Stefanos Apostolopoulos
|
||||
* See license.txt for license details (MIT)
|
||||
* http://www.OpenTK.net
|
||||
*/
|
||||
|
||||
/* Version History:
|
||||
* 0.1
|
||||
* - Tokens ALC_TRUE and ALC_FALSE removed, created new type. see Al.Bool
|
||||
*
|
||||
*
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenTK.OpenAL
|
||||
{
|
||||
public partial class Enums
|
||||
{
|
||||
public enum AlcContextAttributes : int
|
||||
{
|
||||
///<summary>followed by <int> Hz</summary>
|
||||
Frequency = 0x1007,
|
||||
|
||||
///<summary>followed by <int> Hz</summary>
|
||||
Refresh = 0x1008,
|
||||
|
||||
///<summary>followed by AlBoolean.True, or AlBoolean.False</summary>
|
||||
Sync = 0x1009,
|
||||
|
||||
///<summary>followed by <int> Num of requested Mono (3D) Sources</summary>
|
||||
MonoSources = 0x1010,
|
||||
|
||||
///<summary>followed by <int> Num of requested Stereo Sources</summary>
|
||||
StereoSources = 0x1011,
|
||||
}
|
||||
|
||||
public enum AlcError : int // errors
|
||||
{
|
||||
///<summary>There is no current error.</summary>
|
||||
NoError = 0,
|
||||
|
||||
///<summary>No Device. The device handle or specifier names an inaccessible driver/server.</summary>
|
||||
InvalidDevice = 0xA001,
|
||||
|
||||
///<summary>Invalid context ID. The Context argument does not name a valid context.</summary>
|
||||
InvalidContext = 0xA002,
|
||||
|
||||
///<summary>Bad enum. A token used is not valid, or not applicable.</summary>
|
||||
InvalidEnum = 0xA003,
|
||||
|
||||
///<summary>Bad value. A value (e.g. Attribute) is not valid, or not applicable.</summary>
|
||||
InvalidValue = 0xA004,
|
||||
|
||||
///<summary>Out of memory. Unable to allocate memory.</summary>
|
||||
OutOfMemory = 0xA005,
|
||||
}
|
||||
|
||||
public enum AlcGetString : int
|
||||
{
|
||||
///<summary>The specifier string for the default device</summary>
|
||||
DefaultDeviceSpecifier = 0x1004,
|
||||
|
||||
///<summary>The specifier string for the device</summary>
|
||||
DeviceSpecifier = 0x1005,
|
||||
|
||||
///<summary>A list of available context extensions separated by spaces.</summary>
|
||||
Extensions = 0x1006,
|
||||
|
||||
///<summary>The name of the default capture device</summary>
|
||||
CaptureDefaultDeviceSpecifier = 0x311, // ALC_EXT_CAPTURE extension.
|
||||
|
||||
///<summary>The name of the specified capture device, or a list of all available capture devices if no capture device is specified.</summary>
|
||||
CaptureDeviceSpecifier = 0x310, // ALC_EXT_CAPTURE extension.
|
||||
}
|
||||
|
||||
public enum AlcGetInteger : int
|
||||
{
|
||||
///<summary>The specification revision for this implementation (major version). NULL is an acceptable device.</summary>
|
||||
MajorVersion = 0x1000,
|
||||
///<summary>The specification revision for this implementation (minor version). NULL is an acceptable device.</summary>
|
||||
MinorVersion = 0x1001,
|
||||
|
||||
///<summary>The size (number of ALCint values) required for a zero-terminated attributes list, for the current context. NULL is an invalid device.</summary>
|
||||
AttributesSize = 0x1002,
|
||||
///<summary>Expects a destination of ALC_ATTRIBUTES_SIZE, and provides an attribute list for the current context of the specified device. NULL is an invalid device.</summary>
|
||||
AllAttributes = 0x1003,
|
||||
|
||||
///<summary>The number of capture samples available. NULL is an invalid device.</summary>
|
||||
CaptureSamples = 0x312,
|
||||
}
|
||||
|
||||
// ALC_ENUMERATE_ALL_EXT token
|
||||
public enum AlcEnumerateAll : int
|
||||
{
|
||||
DefaultAllDevicesSpecifier = 0x1012,
|
||||
AllDevicesSpecifier = 0x1013,
|
||||
}
|
||||
}
|
||||
}
|
167
Source/OpenTK/OpenAL/AlutFunctions.cs
Normal file
167
Source/OpenTK/OpenAL/AlutFunctions.cs
Normal file
|
@ -0,0 +1,167 @@
|
|||
#region --- OpenTK.OpenAL License ---
|
||||
/* AlutFunctions.cs
|
||||
* C header: \freealut-1.1.0-src\include\AL\Alut.h
|
||||
* Spec: http://www.openal.org/openal_webstf/specs/alut.html
|
||||
* Copyright (c) 2008 Christoph Brandtner and Stefanos Apostolopoulos
|
||||
* See license.txt for license details (MIT)
|
||||
* http://www.OpenTK.net
|
||||
*/
|
||||
|
||||
/* Version History:
|
||||
* 0.1
|
||||
* - The following functions are not bound/imported. Issue of undoing C malloc to prevent memory leaks.
|
||||
* "alutLoadMemoryFromFile, alutLoadMemoryFromFileImage, alutLoadMemoryHelloWorld, alutLoadMemoryWaveform"
|
||||
* Please use Alut.CreateBuffer* functions instead, which have similar functionality and return a Buffer Handle instead.
|
||||
*
|
||||
*
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace OpenTK.OpenAL
|
||||
{
|
||||
/// <summary>Alut, FreeAlut = Free Audio Library Utilities</summary>
|
||||
public static class Alut
|
||||
{
|
||||
#region Constants
|
||||
private const string Lib = "Alut.dll";
|
||||
private const CallingConvention Style = CallingConvention.Cdecl;
|
||||
#endregion Constants
|
||||
|
||||
#region Init/Exit
|
||||
/// <summary>Alut.Init initializes the ALUT internals and creates an OpenAL context on the default device and makes it the current OpenAL context. If you want something more complex than that (e.g. running on a non-default device or opening multiple contexts on multiple devices), you can use alutInitWithoutContext instead. alutInit examines the commandline arguments passed to it and remove those it recognizes. It is acceptable to pass two NULL pointers in settings where no useful information can be obtained from argc and argv.</summary>
|
||||
/// <param name="argcp">Application Main Parameters</param>
|
||||
/// <param name="argv">Application Main Parameters</param>
|
||||
/// <returns>Success.</returns>
|
||||
[DllImport( Alut.Lib, EntryPoint = "alutInit", ExactSpelling = true, CallingConvention = Alut.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern Al.Bool Init( [In] IntPtr argcp, [In] IntPtr argv );
|
||||
// ALUT_API ALboolean ALUT_APIENTRY alutInit (int *argcp, char **argv);
|
||||
|
||||
/// <summary>Parameterless function for convenience. Internally passes IntPtr.Zero as parameters.</summary>
|
||||
/// <returns>Success.</returns>
|
||||
internal static Al.Bool Init( ) // overload for convenience
|
||||
{
|
||||
return Init( IntPtr.Zero, IntPtr.Zero );
|
||||
}
|
||||
|
||||
/// <summary>Alut.InitWithoutContext initializes the ALUT internals. It does not create any OpenAL context or device, so this has to be done via the usual ALC calls. alutInitWithoutContext examines the commandline arguments passed to it and remove those it recognizes. It is acceptable to pass two NULL pointers in settings where no useful information can be obtained from argc and argv.</summary>
|
||||
/// <param name="argcp">Application Main Parameters</param>
|
||||
/// <param name="argv">Application Main Parameters</param>
|
||||
/// <returns>Success.</returns>
|
||||
[DllImport( Alut.Lib, EntryPoint = "alutInitWithoutContext", ExactSpelling = true, CallingConvention = Alut.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern Al.Bool InitWithoutContext( [In] IntPtr argcp, [In] IntPtr argv );
|
||||
// ALUT_API ALboolean ALUT_APIENTRY alutInitWithoutContext (int *argcp, char **argv);
|
||||
|
||||
internal static Al.Bool InitWithoutContext( ) // overload for convenience
|
||||
{
|
||||
return InitWithoutContext( IntPtr.Zero, IntPtr.Zero );
|
||||
}
|
||||
|
||||
/// <summary>When the application has finished playing audio, it should shut down ALUT using Alut.Exit. This closes any OpenAL device/context that ALUT may have created in alutInit (but not any that the application created using ALC). After calling alutExit, you may subsequently call alutInit or alutInitWithoutContext again. Note that under well-behaved operating systems, it should be acceptable to simply exit from your program without bothering to call alutExit, relying on the OS to clean up after you. However, it is dangerous to rely on this behavior if portable operation is expected.</summary>
|
||||
/// <returns>Success.</returns>
|
||||
[DllImport( Alut.Lib, EntryPoint = "alutExit", ExactSpelling = true, CallingConvention = Alut.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern Al.Bool Exit( );
|
||||
// ALUT_API ALboolean ALUT_APIENTRY alutExit (void);
|
||||
#endregion Init/Exit
|
||||
|
||||
#region Error Checking
|
||||
/// <summary>Any ALUT routine that fails will return AL_FALSE / AL_NONE / NULL and set the global error state. If a subsequent error occurs while there is still an error recorded internally, the second error will simply be ignored. Calling alutGetError will reset the error code to ALUT_ERROR_NO_ERROR. Note that the error state is not cleared by other successful ALUT calls. Alut.GetError can be called in any ALUT state and will never fail.</summary>
|
||||
/// <returns><see cref="Enums.AlutError"/></returns>
|
||||
[DllImport( Alut.Lib, EntryPoint = "alutGetError", ExactSpelling = true, CallingConvention = Alut.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern Enums.AlutError GetError( );
|
||||
// ALUT_API ALenum ALUT_APIENTRY alutGetError (void);
|
||||
|
||||
[DllImport( Alut.Lib, EntryPoint = "alutGetErrorString", ExactSpelling = true, CallingConvention = Alut.Style, CharSet = CharSet.Ansi ), SuppressUnmanagedCodeSecurity( )]
|
||||
private static extern IntPtr GetErrorStringInternal( Enums.AlutError error );
|
||||
// ALUT_API const char *ALUT_APIENTRY alutGetErrorString (ALenum error);
|
||||
|
||||
/// <summary>Alut.GetErrorString can be used to convert an error code into a human-readable description. The precise text of these descriptions may vary from implementation to implementation and should not be relied upon by the application.</summary>
|
||||
/// <param name="error">Retrieve first occured error with Alut.GetError</param>
|
||||
/// <returns>A human-readable description of the Error.</returns>
|
||||
internal static string GetErrorString( Enums.AlutError error )
|
||||
{
|
||||
return Marshal.PtrToStringAnsi( GetErrorStringInternal( error ) );
|
||||
}
|
||||
#endregion Error Checking
|
||||
|
||||
#region File Loading
|
||||
/// <summary>Alut.CreateBufferFromFile tries to guess the sound data format by looking at the filename and/or the file contents and loads the sound data into an OpenAL buffer.</summary>
|
||||
/// <param name="filename">The file to be loaded</param>
|
||||
/// <returns>OpenAL Buffer, 0 on failure.</returns>
|
||||
[DllImport( Alut.Lib, EntryPoint = "alutCreateBufferFromFile", ExactSpelling = true, CallingConvention = Alut.Style, CharSet = CharSet.Ansi ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern uint CreateBufferFromFile( [In] string filename );
|
||||
// ALUT_API ALuint ALUT_APIENTRY alutCreateBufferFromFile (const char *fileName);
|
||||
|
||||
/// <summary>Alut.CreateBufferFromFileImage tries to guess the sound data format by looking at the contents of the memory region given as parameters and loads the sound data into an OpenAL buffer.</summary>
|
||||
/// <param name="data">A Pointer to the sound data in memory.</param>
|
||||
/// <param name="length">Size in Bytes of the sound data.</param>
|
||||
/// <returns>OpenAL Buffer, 0 on failure.</returns>
|
||||
[DllImport( Alut.Lib, EntryPoint = "alutCreateBufferFromFileImage", ExactSpelling = true, CallingConvention = Alut.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern uint CreateBufferFromFileImage( [In] IntPtr data, int length );
|
||||
// ALUT_API ALuint ALUT_APIENTRY alutCreateBufferFromFileImage (const ALvoid *data, ALsizei length);
|
||||
|
||||
|
||||
/// <summary>Alut.CreateBufferHelloWorld returns a handle to an OpenAL buffer containing the sound of someone saying 'Hello, world!'.</summary>
|
||||
/// <returns>OpenAL Buffer, 0 on failure.</returns>
|
||||
[DllImport( Alut.Lib, EntryPoint = "alutCreateBufferHelloWorld", ExactSpelling = true, CallingConvention = Alut.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern uint CreateBufferHelloWorld( );
|
||||
//ALUT_API ALuint ALUT_APIENTRY alutCreateBufferHelloWorld (void);
|
||||
|
||||
/// <summary>Alut.CreateBufferWaveform returns a handle to an OpenAL buffer containing a snippet of audio with the specified waveshape at the specified frequency (in Hertz), phase (in degrees: -180 to +180) and duration (in seconds).</summary>
|
||||
/// <param name="waveshape"></param>
|
||||
/// <param name="frequency">Frequency in Hertz [Hz].</param>
|
||||
/// <param name="phase">Phase (in degrees: -180 to +180)</param>
|
||||
/// <param name="duration">Duration (in seconds)</param>
|
||||
/// <returns>OpenAL Buffer, 0 on failure.</returns>
|
||||
[DllImport( Alut.Lib, EntryPoint = "alutCreateBufferWaveform", ExactSpelling = true, CallingConvention = Alut.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern uint CreateBufferWaveform( Enums.AlutWaveform waveshape, float frequency, float phase, float duration );
|
||||
// ALUT_API ALuint ALUT_APIENTRY alutCreateBufferWaveform (ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration);
|
||||
|
||||
// Warning: these leak memory if not properly free'd
|
||||
// ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryFromFile (const char *fileName, ALenum *format, ALsizei *size, ALfloat *frequency);
|
||||
// ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryFromFileImage (const ALvoid *data, ALsizei length, ALenum *format, ALsizei *size, ALfloat *frequency);
|
||||
// ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryHelloWorld (ALenum *format, ALsizei *size, ALfloat *frequency);
|
||||
// ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryWaveform (ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration, ALenum *format, ALsizei *size, ALfloat *freq);
|
||||
#endregion File Loading
|
||||
|
||||
#region Misc
|
||||
[DllImport( Alut.Lib, EntryPoint = "alutGetMIMETypes", ExactSpelling = true, CallingConvention = Alut.Style, CharSet = CharSet.Ansi ), SuppressUnmanagedCodeSecurity( )]
|
||||
private static extern IntPtr GetMIMETypesInternal( Enums.AlutLoader loader );
|
||||
// ALUT_API const char *ALUT_APIENTRY alutGetMIMETypes (ALenum loader);
|
||||
|
||||
/// <summary>Alut.GetMIMETypes returns a comma-separated list of supported MIME types for the given loader type, e.g. something like "audio/basic,audio/mpeg,audio/x-wav".
|
||||
/// It is possible that Enums.AlutLoader.Memory loaders will be unable to support some file types that Enums.AlutLoader.Buffer loaders can support (although the reverse is never the case). Furthermore, it is possible that for some file types (notably audio/x-wav) the support may be only for a few sub-formats. For example, an implementation may advertise that audio/x-wav is supported when in fact it only supports uncompressed (i.e. PCM) WAV files and not any of the compressed subformats. In this event, the various ALUT loaders may return an error and set ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE rather than ALUT_ERROR_UNSUPPORTED_FILE_TYPE which would indicate that no files of this type are allowed.
|
||||
/// </summary>
|
||||
/// <param name="loader"><see cref="Enums.AlutLoader"/></param>
|
||||
/// <returns>A comma-separated list of supported MIME types.</returns>
|
||||
internal static string GetMIMETypes( Enums.AlutLoader loader )
|
||||
{
|
||||
return Marshal.PtrToStringAnsi( GetMIMETypesInternal( loader ) );
|
||||
}
|
||||
|
||||
/// <summary>Alut.GetMajorVersion returns the major version number of the ALUT in use, which will match the major version number of the corresponding ALUT specification document. Can be compared using Enums.AlutVersions.</summary>
|
||||
/// <returns>Major Version Number.</returns>
|
||||
[DllImport( Alut.Lib, EntryPoint = "alutGetMajorVersion", ExactSpelling = true, CallingConvention = Alut.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern int GetMajorVersion( );
|
||||
// ALUT_API ALint ALUT_APIENTRY alutGetMajorVersion (void);
|
||||
|
||||
/// <summary>Alut.GetMinorVersion returns the minor version number of the ALUT in use, which will match the minor version number of the corresponding ALUT specification document. Can be compared using Enums.AlutVersions.</summary>
|
||||
/// <returns>Minor Version Number.</returns>
|
||||
[DllImport( Alut.Lib, EntryPoint = "alutGetMinorVersion", ExactSpelling = true, CallingConvention = Alut.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern int GetMinorVersion( );
|
||||
// ALUT_API ALint ALUT_APIENTRY alutGetMinorVersion (void);
|
||||
|
||||
/// <summary>Alut.Sleep will delay the execution of the current thread for at least the given amount of seconds. It will only return earlier if a signal has been delivered to the thread, but this does not count as an error. Note that sleeping for zero seconds will give other runnable threads a chance to run.
|
||||
/// Having a general utility function like the following in an audio-related toolkit might seem strange at first, but sleeping is a common task in a lot of audio demos and it can't be done portably without cluttering the source code with #ifdefs.
|
||||
/// </summary>
|
||||
/// <param name="duration">Number of seconds. May not be negative.</param>
|
||||
/// <returns>Success.</returns>
|
||||
[DllImport( Alut.Lib, EntryPoint = "alutSleep", ExactSpelling = true, CallingConvention = Alut.Style ), SuppressUnmanagedCodeSecurity( )]
|
||||
internal static extern Al.Bool Sleep( float duration );
|
||||
// ALUT_API ALboolean ALUT_APIENTRY alutSleep (ALfloat duration);
|
||||
#endregion Misc
|
||||
}
|
||||
}
|
91
Source/OpenTK/OpenAL/AlutTokens.cs
Normal file
91
Source/OpenTK/OpenAL/AlutTokens.cs
Normal file
|
@ -0,0 +1,91 @@
|
|||
#region --- OpenTK.OpenAL License ---
|
||||
/* AlutTokens.cs
|
||||
* C header: \freealut-1.1.0-src\include\AL\Alut.h
|
||||
* Spec: http://www.openal.org/openal_webstf/specs/alut.html
|
||||
* Copyright (c) 2008 Christoph Brandtner and Stefanos Apostolopoulos
|
||||
* See license.txt for license details (MIT)
|
||||
* http://www.OpenTK.net
|
||||
*/
|
||||
|
||||
/* Version History:
|
||||
* 0.1
|
||||
* - Tokens AL_TRUE and AL_FALSE removed, created new type. see Al.Bool
|
||||
*
|
||||
*
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenTK.OpenAL
|
||||
{
|
||||
public partial class Enums
|
||||
{
|
||||
public enum AlutVersions : int
|
||||
{
|
||||
/// <summary>Defines the A in OpenAL A.B</summary>
|
||||
ApiMajorVersion = 1,
|
||||
/// <summary>Defines the B in OpenAL A.B</summary>
|
||||
ApiMinorVersion = 1,
|
||||
}
|
||||
|
||||
public enum AlutError : int
|
||||
{
|
||||
/// <summary>No ALUT error found.</summary>
|
||||
NoError = 0,
|
||||
/// <summary>ALUT ran out of memory.</summary>
|
||||
OutOfMemory = 0x200,
|
||||
/// <summary>ALUT was given an invalid enumeration token.</summary>
|
||||
InvalidEnum = 0x201,
|
||||
/// <summary>ALUT was given an invalid value.</summary>
|
||||
InvalidValue = 0x202,
|
||||
/// <summary>The operation is invalid in the current ALUT state.</summary>
|
||||
InvalidOperation = 0x203,
|
||||
/// <summary>There is no current AL context.</summary>
|
||||
NoCurrentContext = 0x204,
|
||||
/// <summary>There was already an AL error on entry to an ALUT function.</summary>
|
||||
AlErrorOnEntry = 0x205,
|
||||
/// <summary>There was already an ALC error on entry to an ALUT function.</summary>
|
||||
AlcErrorOnEntry = 0x206,
|
||||
/// <summary>There was an error opening the ALC device.</summary>
|
||||
OpenDevice = 0x207,
|
||||
/// <summary>There was an error closing the ALC device.</summary>
|
||||
CloseDevice = 0x208,
|
||||
/// <summary>There was an error creating an ALC context.</summary>
|
||||
CreateContext = 0x209,
|
||||
/// <summary>Could not change the current ALC context.</summary>
|
||||
MakeContextCurrent = 0x20A,
|
||||
/// <summary>There was an error destroying the ALC context.</summary>
|
||||
DestroyContext = 0x20B,
|
||||
/// <summary>There was an error generating an AL buffer.</summary>
|
||||
GenBuffers = 0x20C,
|
||||
/// <summary>There was an error passing buffer data to AL.</summary>
|
||||
BufferData = 0x20D,
|
||||
/// <summary>I/O error, consult errno for more details.</summary>
|
||||
IoError = 0x20E,
|
||||
/// <summary>Unsupported file type.</summary>
|
||||
UnsupportedFileType = 0x20F,
|
||||
/// <summary>Unsupported mode within an otherwise usable file type.</summary>
|
||||
UnsupportedFileSubtype = 0x210,
|
||||
/// <summary>The sound data was corrupt or truncated.</summary>
|
||||
CorruptOrTruncatedData = 0x211,
|
||||
}
|
||||
|
||||
public enum AlutWaveform : int
|
||||
{
|
||||
Sine = 0x100,
|
||||
Square = 0x101,
|
||||
SawTooth = 0x102,
|
||||
WhiteNoise = 0x103,
|
||||
Impulse = 0x104,
|
||||
}
|
||||
|
||||
public enum AlutLoader : int
|
||||
{
|
||||
///<summary>For the loaders returning sound data in an OpenAL buffer, e.g. Alut.CreateBufferFromFile and Alut.CreateBufferFromFileImage</summary>
|
||||
Buffer = 0x300,
|
||||
///<summary>For the loaders returning sound data in a newly allocated memory region, e.g. Alut.LoadMemoryFromFile and Alut.LoadMemoryFromFileImage.</summary>
|
||||
Memory = 0x301,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue