Merged with OpenAL branch.

This commit is contained in:
the_fiddler 2008-01-15 00:24:15 +00:00
parent 3a786679af
commit 1f3288a50c
8 changed files with 1496 additions and 793 deletions

File diff suppressed because it is too large Load diff

View file

@ -3,37 +3,28 @@
* C header: \OpenAL 1.1 SDK\include\Al.h * C header: \OpenAL 1.1 SDK\include\Al.h
* Spec: http://www.openal.org/openal_webstf/specs/OpenAL11Specification.pdf * Spec: http://www.openal.org/openal_webstf/specs/OpenAL11Specification.pdf
* Copyright (c) 2008 Christoph Brandtner and Stefanos Apostolopoulos * Copyright (c) 2008 Christoph Brandtner and Stefanos Apostolopoulos
* See license.txt for license details (MIT) * See license.txt for license details
* http://www.OpenTK.net * http://www.OpenTK.net */
*/
/* Version History:
* 0.1
* - Tokens AL_TRUE and AL_FALSE removed, created new type. see Al.Bool
*
*
*/
#endregion #endregion
using System; using System;
namespace OpenTK.OpenAL namespace OpenTK.OpenAL.Enums
{ {
public partial class Enums
{ public enum ALCapability : int
public enum AlCapability : int
{ {
///<summary>Currently no state toggles exist for vanilla OpenAL.</summary> ///<summary>Currently no state toggles exist for vanilla OpenAL.</summary>
Invalid = -1, Invalid = -1,
} }
public enum AlListenerf : int 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> ///<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, Gain = 0x100A,
} }
public enum AlListener3f : int 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> ///<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, Position = 0x1004,
@ -42,13 +33,13 @@ namespace OpenTK.OpenAL
Velocity = 0x1006, Velocity = 0x1006,
} }
public enum AlListenerfv : int public enum ALListenerfv : int
{ {
///<summary>Indicate Listener orientation. (at/up)</summary> ///<summary>Indicate Listener orientation. (at/up)</summary>
Orientation = 0x100F, Orientation = 0x100F,
} }
public enum AlSourcef : int 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> ///<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, ReferenceDistance = 0x1020,
@ -79,9 +70,12 @@ namespace OpenTK.OpenAL
///<summary>Directional Source, outer cone gain. Default: 0.0f Range: [0.0f - 1.0] (Logarithmic)</summary> ///<summary>Directional Source, outer cone gain. Default: 0.0f Range: [0.0f - 1.0] (Logarithmic)</summary>
ConeOuterGain = 0x1022, ConeOuterGain = 0x1022,
/// <summary>The playback position, expressed in seconds.</summary>
SecOffset = 0x1024, // AL_EXT_OFFSET extension.
} }
public enum AlSource3f : int 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> ///<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, Position = 0x1004,
@ -89,72 +83,79 @@ namespace OpenTK.OpenAL
///<summary>Specify the current velocity in three dimensional space.</summary> ///<summary>Specify the current velocity in three dimensional space.</summary>
Velocity = 0x1006, Velocity = 0x1006,
///<summary>Specify the current direction.</summary> ///<summary>Specify the current direction vector.</summary>
Direction = 0x1005, Direction = 0x1005,
} }
public enum AlSourcei : int public enum ALSourceb : 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> ///<summary>Indicate Source has relative coordinates.</summary>
SourceRelative = 0x202, SourceRelative = 0x202,
///<summary>Indicate whether Source is looping. Type: Alboolean Range: [True, False] Default: False.</summary> ///<summary>Indicate whether Source is looping. Type: Al.Bool Range: [True, False] Default: False.</summary>
Looping = 0x1007, Looping = 0x1007,
} }
public enum AlSourceiGet : int public enum ALSourcei : int
{ {
// Source Buffer position information ///<summary>The playback position, expressed in bytes.</summary>
MiliSecOffset = 0x1024, // AL_EXT_OFFSET extension.
ByteOffset = 0x1026, // AL_EXT_OFFSET extension. ByteOffset = 0x1026, // AL_EXT_OFFSET extension.
///<summary>The playback position, expressed in samples.</summary>
SampleOffset = 0x1025, // 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> ///<summary>Indicate the Buffer to provide sound samples. Type: uint Range: any valid Buffer id.</summary>
Buffer = 0x1009, Buffer = 0x1009,
SourceState = 0x1010, ///<summary>Source type (Static, Streaming or undetermined). Use enum AlSourceType for comparison</summary>
BuffersQueued = 0x1015, SourceType = 0x1027,
BuffersProcessed = 0x1016,
} }
public enum ALSourceiGet : int
public enum AlSourceParameterszzzzzzzzzzzzzzzzzz : int
{ {
///<summary>The playback position, expressed in bytes.</summary>
ByteOffset = 0x1026, // AL_EXT_OFFSET extension.
///<summary>Specify the channel mask. (Creative) Type: uint Range: [0 - 255]</summary> ///<summary>The playback position, expressed in samples.</summary>
SampleOffset = 0x1025, // AL_EXT_OFFSET extension.
///<summary>Indicate the Buffer to provide sound samples. Type: uint Range: any valid Buffer id.</summary>
Buffer = 0x1009,
/// <summary>The state of the source (Stopped, Playing, etc.) Use the enum AlSourceState for comparison.</summary>
SourceState = 0x1010,
/// <summary>The number of buffers queued on this source.</summary>
BuffersQueued = 0x1015,
/// <summary>The number of buffers in the queue that have been processed.</summary>
BuffersProcessed = 0x1016,
///<summary>Source type (Static, Streaming or undetermined). Use enum AlSourceType for comparison.</summary>
SourceType = 0x1027,
}
public enum ALDeprecated : int
{
///<summary>Deprecated. Specify the channel mask. (Creative) Type: uint Range: [0 - 255]</summary>
ChannelMask = 0x3000, ChannelMask = 0x3000,
} }
///<summary>Source state information.</summary> ///<summary>Source state information.</summary>
public enum AlSourcestate : int public enum ALSourceState : int
{ {
///<summary>Default State when loaded, can be manually set with Al.SourceRewind().</summary>
Initial = 0x1011, Initial = 0x1011,
///<summary>The source is currently playing.</summary>
Playing = 0x1012, Playing = 0x1012,
///<summary>The source has paused playback.</summary>
Paused = 0x1013, Paused = 0x1013,
///<summary>The source is not playing.</summary>
Stopped = 0x1014, Stopped = 0x1014,
} }
// AL_EXT_OFFSET extension.
public enum AlSourceBufferPos : int
{
///<summary>Source type (Static, Streaming or undetermined)</summary> ///<summary>Source type (Static, Streaming or undetermined)</summary>
SourceType = 0x1027, public enum ALSourceType : int
}
///<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> ///<summary>Source is Static if a Buffer has been attached using AL_Buffer</summary>
Static = 0x1028, Static = 0x1028,
@ -165,7 +166,7 @@ namespace OpenTK.OpenAL
} }
///<summary>Sound samples: Format specifier.</summary> ///<summary>Sound samples: Format specifier.</summary>
public enum AlFormat : int public enum ALFormat : int
{ {
///<summary>1 Channel, 8 Bit.</summary> ///<summary>1 Channel, 8 Bit.</summary>
FormatMono8 = 0x1100, FormatMono8 = 0x1100,
@ -180,17 +181,22 @@ namespace OpenTK.OpenAL
FormatStereo16 = 0x1103, FormatStereo16 = 0x1103,
} }
public enum AlBufferAttribute : int public enum ALGetBufferi : 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> ///<summary>Sound sample's 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, Frequency = 0x2001,
/// <summary>Bit depth of buffer. Should be 8 or 16.</summary>
Bits = 0x2002, Bits = 0x2002,
/// <summary>Number of channels in buffer. > 1 is valid, but buffer wont be positioned when played. 1 for Mono, 2 for Stereo.</summary>
Channels = 0x2003, Channels = 0x2003,
/// <summary>size of buffer in bytes</summary>
Size = 0x2004, Size = 0x2004,
// From Manual, not in header: AL_DATA ( i, iv ) original location where data was copied from generally useless, as was probably freed after buffer creation
} }
///<summary>Buffer state. Not supported for public use (yet).</summary> ///<summary>Buffer state. Not supported for public use (yet).</summary>
public enum AlBufferState : int public enum ALBufferState : int
{ {
///<summary>Buffer state. Not supported for public use (yet).</summary> ///<summary>Buffer state. Not supported for public use (yet).</summary>
Unused = 0x2010, Unused = 0x2010,
@ -200,7 +206,7 @@ namespace OpenTK.OpenAL
Processed = 0x2012, Processed = 0x2012,
} }
public enum AlError : int // alGetString public enum ALError : int // alGetString
{ {
///<summary>No OpenAL Error.</summary> ///<summary>No OpenAL Error.</summary>
NoError = 0, NoError = 0,
@ -225,31 +231,40 @@ namespace OpenTK.OpenAL
OutOfMemory = 0xA005, OutOfMemory = 0xA005,
} }
public enum AlContextString : int // alGetString public enum ALGetString : int // alGetString
{// Context strings: Vendor Name. {
/// <summary>Gets the Vendor name.</summary>
Vendor = 0xB001, Vendor = 0xB001,
/// <summary>Gets the driver version.</summary>
Version = 0xB002, Version = 0xB002,
/// <summary>Gets the renderer mode.</summary>
Renderer = 0xB003, Renderer = 0xB003,
/// <summary>Gets a list of all available Extensions, separated with spaces.</summary>
Extensions = 0xB004, Extensions = 0xB004,
} }
public enum AlGlobalTweakage : int // alGetBool/Int/Float/Double public enum ALGetFloat : int
{// Global tweakage. {
///<summary>Doppler scale. Default 1.0</summary> ///<summary>Doppler scale. Default 1.0f</summary>
DopplerFactor = 0xC000, DopplerFactor = 0xC000,
///<summary>Tweaks speed of propagation.</summary> ///<summary>Tweaks speed of propagation. This functionality is deprecated.</summary>
DopplerVelocity = 0xC001, // TODO : Verify! DopplerVelocity = 0xC001,
///<summary>Speed of Sound in units per second. default value 343.3f</summary> ///<summary>Speed of Sound in units per second. default value 343.3f</summary>
SpeedOfSound = 0xC003, SpeedOfSound = 0xC003,
}
/// <see cref="AlDistanceModels"/> public enum ALGetInteger : int
{
///<summary>See enum AlDistanceModel.</summary><see cref="AlDistanceModels"/>
DistanceModel = 0xD000, DistanceModel = 0xD000,
} }
// ALenum distanceModel public enum ALDistanceModel : int // used in conjunction with Al.DistanceModel
public enum AlDistanceModels : int// used in conjunction with DistanceModel
{ {
///<summary>bypasses all distance attenuation calculation for all sources.</summary> ///<summary>bypasses all distance attenuation calculation for all sources.</summary>
None = 0, None = 0,
@ -267,5 +282,5 @@ namespace OpenTK.OpenAL
///<summary></summary> ///<summary></summary>
ExponentDistanceClamped = 0xD006, // AL_EXT_EXPONENT_DISTANCE extension. ExponentDistanceClamped = 0xD006, // AL_EXT_EXPONENT_DISTANCE extension.
} }
}
} }

View file

@ -3,19 +3,12 @@
* C header: \OpenAL 1.1 SDK\include\Alc.h * C header: \OpenAL 1.1 SDK\include\Alc.h
* Spec: http://www.openal.org/openal_webstf/specs/OpenAL11Specification.pdf * Spec: http://www.openal.org/openal_webstf/specs/OpenAL11Specification.pdf
* Copyright (c) 2008 Christoph Brandtner and Stefanos Apostolopoulos * Copyright (c) 2008 Christoph Brandtner and Stefanos Apostolopoulos
* See license.txt for license details (MIT) * See license.txt for license details
* http://www.OpenTK.net * http://www.OpenTK.net */
*/
/* Version History:
* 0.1
*
*
*
*/
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security; using System.Security;
@ -75,144 +68,224 @@ typedef void ALCvoid;
namespace OpenTK.OpenAL namespace OpenTK.OpenAL
{ {
/// <summary>Alc = Audio Library Context</summary> /// <summary>Alc = Audio Library Context</summary>
public static class Alc public static class Alc
{ {
#region Constants #region Constants
private const string Lib = Al.Lib;
private const string Lib = AL.Lib;
private const CallingConvention Style = CallingConvention.Cdecl; private const CallingConvention Style = CallingConvention.Cdecl;
#endregion Constants #endregion Constants
#region Context Management #region Context Management
// ALC_API ALCcontext * ALC_APIENTRY alcCreateContext( ALCdevice *device, const ALCint* attrlist );
/// <summary>This function creates a context using a specified device.</summary>
/// <param name="device">a pointer to a device</param>
/// <param name="attrlist">a pointer to a set of attributes: ALC_FREQUENCY, ALC_MONO_SOURCES, ALC_REFRESH, ALC_STEREO_SOURCES, ALC_SYNC</param>
/// <returns>Returns a pointer to the new context (NULL on failure). The attribute list can be NULL, or a zero terminated list of integer pairs composed of valid ALC attribute tokens and requested values.</returns>
[DllImport(Alc.Lib, EntryPoint = "alcCreateContext", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alc.Lib, EntryPoint = "alcCreateContext", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()]
internal static extern IntPtr CreateContext( [In] IntPtr device, [In] IntPtr attrlist ); public static extern IntPtr CreateContext([In] IntPtr device, [In] IntPtr attrlist);
// ALC_API ALCcontext * ALC_APIENTRY alcCreateContext( ALCdevice *device, const ALCint* attrlist );
// ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent( ALCcontext *context ); /// <summary>This function makes a specified context the current context.</summary>
/// <param name="context">A pointer to the new context.</param>
/// <returns>Returns True on success, or False on failure.</returns>
[DllImport(Alc.Lib, EntryPoint = "alcMakeContextCurrent", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alc.Lib, EntryPoint = "alcMakeContextCurrent", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()]
internal static extern Al.Bool MakeContextCurrent( [In] IntPtr context ); public static extern AL.Bool MakeContextCurrent([In] IntPtr context);
// ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent( ALCcontext *context );
// ALC_API void ALC_APIENTRY alcProcessContext( ALCcontext *context ); /// <summary>This function tells a context to begin processing. When a context is suspended, changes in OpenAL state will be accepted but will not be processed. alcSuspendContext can be used to suspend a context, and then all the OpenAL state changes can be applied at once, followed by a call to alcProcessContext to apply all the state changes immediately. In some cases, this procedure may be more efficient than application of properties in a non-suspended state. In some implementations, process and suspend calls are each a NOP.</summary>
/// <param name="context">a pointer to the new context</param>
[DllImport(Alc.Lib, EntryPoint = "alcProcessContext", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alc.Lib, EntryPoint = "alcProcessContext", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()]
internal static extern void ProcessContext( [In] IntPtr context ); public static extern void ProcessContext([In] IntPtr context);
// ALC_API void ALC_APIENTRY alcProcessContext( ALCcontext *context );
// ALC_API void ALC_APIENTRY alcSuspendContext( ALCcontext *context ); /// <summary>This function suspends processing on a specified context. When a context is suspended, changes in OpenAL state will be accepted but will not be processed. A typical use of alcSuspendContext would be to suspend a context, apply all the OpenAL state changes at once, and then call alcProcessContext to apply all the state changes at once. In some cases, this procedure may be more efficient than application of properties in a non-suspended state. In some implementations, process and suspend calls are each a NOP.</summary>
/// <param name="context">a pointer to the context to be suspended.</param>
[DllImport(Alc.Lib, EntryPoint = "alcSuspendContext", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alc.Lib, EntryPoint = "alcSuspendContext", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()]
internal static extern void SuspendContext( [In] IntPtr context ); public static extern void SuspendContext([In] IntPtr context);
// ALC_API void ALC_APIENTRY alcSuspendContext( ALCcontext *context );
/// <summary>This function destroys a context.</summary>
// ALC_API void ALC_APIENTRY alcDestroyContext( ALCcontext *context ); /// <param name="context">a pointer to the new context.</param>
[DllImport(Alc.Lib, EntryPoint = "alcDestroyContext", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alc.Lib, EntryPoint = "alcDestroyContext", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()]
internal static extern void DestroyContext( [In] IntPtr context ); public static extern void DestroyContext([In] IntPtr context);
// ALC_API void ALC_APIENTRY alcDestroyContext( ALCcontext *context );
// ALC_API ALCcontext * ALC_APIENTRY alcGetCurrentContext( void ); /// <summary>This function retrieves the current context.</summary>
/// <returns>Returns a pointer to the current context.</returns>
[DllImport(Alc.Lib, EntryPoint = "alcGetCurrentContext", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alc.Lib, EntryPoint = "alcGetCurrentContext", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()]
internal static extern IntPtr GetCurrentContext( ); public static extern IntPtr GetCurrentContext();
// ALC_API ALCcontext * ALC_APIENTRY alcGetCurrentContext( void );
// ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice( ALCcontext *context ); /// <summary>This function retrieves a context's device pointer.</summary>
/// <param name="context">a pointer to a context.</param>
/// <returns>Returns a pointer to the specified context's device.</returns>
[DllImport(Alc.Lib, EntryPoint = "alcGetContextsDevice", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alc.Lib, EntryPoint = "alcGetContextsDevice", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()]
internal static extern IntPtr GetContextsDevice( [In] IntPtr context ); public static extern IntPtr GetContextsDevice([In] IntPtr context);
// ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice( ALCcontext *context );
#endregion Context Management #endregion Context Management
#region Device 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 ); /// <summary>This function opens a device by name.</summary>
/// <param name="devicename">a null-terminated string describing a device.</param>
/// <returns>Returns a pointer to the opened device. The return value will be NULL if there is an error.</returns>
[DllImport(Alc.Lib, EntryPoint = "alcOpenDevice", ExactSpelling = true, CallingConvention = Alc.Style, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity()]
public static extern IntPtr OpenDevice([In] string devicename);
// ALC_API ALCdevice * ALC_APIENTRY alcOpenDevice( const ALCchar *devicename );
/// <summary>This function closes a device by name.</summary>
/// <param name="device">a pointer to an opened device</param>
/// <returns>True will be returned on success or False on failure. Closing a device will fail if the device contains any contexts or buffers.</returns>
[DllImport(Alc.Lib, EntryPoint = "alcCloseDevice", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alc.Lib, EntryPoint = "alcCloseDevice", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()]
internal static extern Al.Bool CloseDevice( [In] IntPtr device ); public static extern AL.Bool CloseDevice([In] IntPtr device);
// ALC_API ALCboolean ALC_APIENTRY alcCloseDevice( ALCdevice *device );
#endregion Device Management #endregion Device Management
#region Error support. #region Error support.
// Obtain the most recent Context error
// ALC_API ALCenum ALC_APIENTRY alcGetError( ALCdevice *device ); /// <summary>This function retrieves the current context error state.</summary>
/// <param name="device">a pointer to the device to retrieve the error state from</param>
/// <returns>Errorcode Int32.</returns>
[DllImport(Alc.Lib, EntryPoint = "alcGetError", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alc.Lib, EntryPoint = "alcGetError", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()]
internal static extern Enums.AlcError GetError( [In] IntPtr device ); public static extern Enums.AlcError GetError([In] IntPtr device);
// ALC_API ALCenum ALC_APIENTRY alcGetError( ALCdevice *device );
#endregion Error support. #endregion Error support.
#region Extension 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 ); /// <summary>This function queries if a specified context extension is available.</summary>
/// <param name="device">a pointer to the device to be queried for an extension.</param>
/// <param name="extname">a null-terminated string describing the extension.</param>
/// <returns>Returns True if the extension is available, False if the extension is not available.</returns>
[DllImport(Alc.Lib, EntryPoint = "alcIsExtensionPresent", ExactSpelling = true, CallingConvention = Alc.Style, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity()] [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 ); public static extern AL.Bool IsExtensionPresent([In] IntPtr device, [In] string extname);
// ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent( ALCdevice *device, const ALCchar *extname );
// ALC_API void * ALC_APIENTRY alcGetProcAddress( ALCdevice *device, const ALCchar *funcname ); /// <summary>This function retrieves the address of a specified context extension function.</summary>
/// <param name="device">a pointer to the device to be queried for the function.</param>
/// <param name="funcname">a null-terminated string describing the function.</param>
/// <returns>Returns the address of the function, or NULL if it is not found.</returns>
[DllImport(Alc.Lib, EntryPoint = "alcGetProcAddress", ExactSpelling = true, CallingConvention = Alc.Style, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity()] [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 ); public static extern IntPtr GetProcAddress([In] IntPtr device, [In] string funcname);
// ALC_API void * ALC_APIENTRY alcGetProcAddress( ALCdevice *device, const ALCchar *funcname );
// ALC_API ALCenum ALC_APIENTRY alcGetEnumValue( ALCdevice *device, const ALCchar *enumname ); /// <summary>This function retrieves the enum value for a specified enumeration name.</summary>
/// <param name="device">a pointer to the device to be queried.</param>
/// <param name="enumname">a null terminated string describing the enum value.</param>
/// <returns>Returns the enum value described by the enumName string. This is most often used for querying an enum value for an ALC extension.</returns>
[DllImport(Alc.Lib, EntryPoint = "alcGetEnumValue", ExactSpelling = true, CallingConvention = Alc.Style, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity()] [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 ); public static extern int GetEnumValue([In] IntPtr device, [In] string enumname);
// ALC_API ALCenum ALC_APIENTRY alcGetEnumValue( ALCdevice *device, const ALCchar *enumname );
#endregion Extension support. #endregion Extension support.
#region Query functions #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()] [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 ); private static extern IntPtr GetStringPrivate([In] IntPtr device, Enums.AlcGetString param);
// ALC_API const ALCchar * ALC_APIENTRY alcGetString( ALCdevice *device, ALCenum param );
internal static string GetString( IntPtr device, Enums.AlcGetString param ) /// <summary>This function returns pointers to strings related to the context.</summary>
/// <remarks>
/// ALC_DEFAULT_DEVICE_SPECIFIER will return the name of the default output device.
/// ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER will return the name of the default capture device.
/// ALC_DEVICE_SPECIFIER will return the name of the specified output device if a pointer is supplied, or will return a list of all available devices if a NULL device pointer is supplied. A list is a pointer to a series of strings separated by NULL characters, with the list terminated by two NULL characters. See Enumeration Extension for more details.
/// ALC_CAPTURE_DEVICE_SPECIFIER will return the name of the specified capture device if a pointer is supplied, or will return a list of all available devices if a NULL device pointer is supplied.
/// ALC_EXTENSIONS returns a list of available context extensions, with each extension separated by a space and the list terminated by a NULL character.
/// </remarks>
/// <param name="device">a pointer to the device to be queried.</param>
/// <param name="param">an attribute to be retrieved: ALC_DEFAULT_DEVICE_SPECIFIER, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER, ALC_DEVICE_SPECIFIER, ALC_CAPTURE_DEVICE_SPECIFIER, ALC_EXTENSIONS</param>
/// <returns></returns>
public static string GetString(IntPtr device, Enums.AlcGetString param)
{ {
return Marshal.PtrToStringAnsi( GetStringInternal( device, param ) ); return Marshal.PtrToStringAnsi(GetStringPrivate(device, param));
} }
internal static string GetStringDevices( ) public static List<string> GetString(IntPtr device, Enums.AlcGetStringList param)
{ {
return Marshal.PtrToStringBSTR( GetStringInternal( Al.Null, Enums.AlcGetString.DeviceSpecifier )); List<string> result = new List<string>();
IntPtr t = GetStringPrivate(AL.Null, (Enums.AlcGetString)Enums.AlcGetStringList.DeviceSpecifier);
System.Text.StringBuilder sb = new System.Text.StringBuilder();
byte b;
int offset = 0;
do
{
b = Marshal.ReadByte(t, offset++);
if (b != 0) sb.Append((char)b);
else
{
if (Marshal.ReadByte(t, offset + 1) == 0)
break;
else
{
if (sb.Length > 1) result.Add(sb.ToString());
sb.Remove(0, sb.Length);
}
}
} while (true);
return result;
} }
// ALC_API void ALC_APIENTRY alcGetIntegerv( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *data ); /// <summary>This function returns integers related to the context.</summary>
/// <param name="device">a pointer to the device to be queried.</param>
/// <param name="param">an attribute to be retrieved: ALC_MAJOR_VERSION, ALC_MINOR_VERSION, ALC_ATTRIBUTES_SIZE, ALC_ALL_ATTRIBUTES</param>
/// <param name="size">the size of the destination buffer provided. In bytes.</param>
/// <param name="data">a pointer to the data to be returned</param>
[DllImport(Alc.Lib, EntryPoint = "alcGetIntegerv", ExactSpelling = true, CallingConvention = Alc.Style, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity()] [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 ); public static extern void GetInteger([In] IntPtr device, Enums.AlcGetInteger param, int size, [Out] out int data);
// ALC_API void ALC_APIENTRY alcGetIntegerv( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *data );
#endregion Query functions #endregion Query functions
#region Capture functions #region Capture functions
/// <summary>This function opens a capture device by name. </summary>
/// <param name="devicename">a pointer to a device name string</param>
/// <param name="frequency">the frequency that the data should be captured at</param>
/// <param name="format">the requested capture buffer format</param>
/// <param name="buffersize">the size of the capture buffer in bytes</param>
/// <returns>Returns the capture device pointer, or NULL on failure.</returns>
[CLSCompliant(false), DllImport(Alc.Lib, EntryPoint = "alcCaptureOpenDevice", ExactSpelling = true, CallingConvention = Alc.Style, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity()]
public static extern IntPtr CaptureOpenDevice(string devicename, uint frequency, Enums.ALFormat format, int buffersize);
// ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize ); // 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 ); /// <summary>This function closes the specified capture device.</summary>
/// <param name="device">a pointer to a capture device.</param>
/// <returns>Returns True if the close operation was successful, False on failure.</returns>
[DllImport(Alc.Lib, EntryPoint = "alcCaptureCloseDevice", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alc.Lib, EntryPoint = "alcCaptureCloseDevice", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()]
internal static extern Al.Bool CaptureCloseDevice( [In] IntPtr device ); public static extern AL.Bool CaptureCloseDevice([In] IntPtr device);
// ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice( ALCdevice *device );
// ALC_API void ALC_APIENTRY alcCaptureStart( ALCdevice *device ); /// <summary>This function begins a capture operation.</summary>
/// <remarks>alcCaptureStart will begin recording to an internal ring buffer of the size specified when opening the capture device. The application can then retrieve the number of samples currently available using the ALC_CAPTURE_SAPMPLES token with alcGetIntegerv. When the application determines that enough samples are available for processing, then it can obtain them with a call to alcCaptureSamples.</remarks>
/// <param name="device">a pointer to a capture device.</param>
[DllImport(Alc.Lib, EntryPoint = "alcCaptureStart", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alc.Lib, EntryPoint = "alcCaptureStart", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()]
internal static extern void CaptureStart( [In] IntPtr device ); public static extern void CaptureStart([In] IntPtr device);
// ALC_API void ALC_APIENTRY alcCaptureStart( ALCdevice *device );
// ALC_API void ALC_APIENTRY alcCaptureStop( ALCdevice *device ); /// <summary>This function stops a capture operation.</summary>
/// <param name="device">a pointer to a capture device.</param>
[DllImport(Alc.Lib, EntryPoint = "alcCaptureStop", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alc.Lib, EntryPoint = "alcCaptureStop", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()]
internal static extern void CaptureStop( [In] IntPtr device ); public static extern void CaptureStop([In] IntPtr device);
// ALC_API void ALC_APIENTRY alcCaptureStop( ALCdevice *device );
// ALC_API void ALC_APIENTRY alcCaptureSamples( ALCdevice *device, ALCvoid *buffer, ALCsizei samples ); /// <summary>This function completes a capture operation, and does not block.</summary>
/// <param name="device">a pointer to a capture device.</param>
/// <param name="buffer">a pointer to a data buffer, which must be large enough to accommodate samples number of samples.</param>
/// <param name="samples">the number of samples to be retrieved.</param>
[DllImport(Alc.Lib, EntryPoint = "alcCaptureSamples", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()] [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 ); public static extern void CaptureSamples([In] IntPtr device, [Out] out IntPtr buffer, [Out] out int samples);
// ALC_API void ALC_APIENTRY alcCaptureSamples( ALCdevice *device, ALCvoid *buffer, ALCsizei samples );
#endregion Capture functions #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 );
*/
} }
} }

View file

@ -3,24 +3,15 @@
* C header: \OpenAL 1.1 SDK\include\Alc.h * C header: \OpenAL 1.1 SDK\include\Alc.h
* Spec: http://www.openal.org/openal_webstf/specs/OpenAL11Specification.pdf * Spec: http://www.openal.org/openal_webstf/specs/OpenAL11Specification.pdf
* Copyright (c) 2008 Christoph Brandtner and Stefanos Apostolopoulos * Copyright (c) 2008 Christoph Brandtner and Stefanos Apostolopoulos
* See license.txt for license details (MIT) * See license.txt for license details
* http://www.OpenTK.net * http://www.OpenTK.net */
*/
/* Version History:
* 0.1
* - Tokens ALC_TRUE and ALC_FALSE removed, created new type. see Al.Bool
*
*
*/
#endregion #endregion
using System; using System;
namespace OpenTK.OpenAL namespace OpenTK.OpenAL.Enums
{
public partial class Enums
{ {
public enum AlcContextAttributes : int public enum AlcContextAttributes : int
{ {
///<summary>followed by <int> Hz</summary> ///<summary>followed by <int> Hz</summary>
@ -39,7 +30,7 @@ namespace OpenTK.OpenAL
StereoSources = 0x1011, StereoSources = 0x1011,
} }
public enum AlcError : int // errors public enum AlcError : int
{ {
///<summary>There is no current error.</summary> ///<summary>There is no current error.</summary>
NoError = 0, NoError = 0,
@ -62,10 +53,10 @@ namespace OpenTK.OpenAL
public enum AlcGetString : int public enum AlcGetString : int
{ {
///<summary>The specifier string for the default device</summary> ///<summary>The specifier string for the default device.</summary>
DefaultDeviceSpecifier = 0x1004, DefaultDeviceSpecifier = 0x1004,
///<summary>The specifier string for the device</summary> ///<summary>The specifier strings for all available devices.</summary>
DeviceSpecifier = 0x1005, DeviceSpecifier = 0x1005,
///<summary>A list of available context extensions separated by spaces.</summary> ///<summary>A list of available context extensions separated by spaces.</summary>
@ -74,19 +65,33 @@ namespace OpenTK.OpenAL
///<summary>The name of the default capture device</summary> ///<summary>The name of the default capture device</summary>
CaptureDefaultDeviceSpecifier = 0x311, // ALC_EXT_CAPTURE extension. CaptureDefaultDeviceSpecifier = 0x311, // ALC_EXT_CAPTURE extension.
/// <summary>a list of the default devices.</summary>
DefaultAllDevicesSpecifier = 0x1012,
}
public enum AlcGetStringList : int
{
///<summary>The name of the specified capture device, or a list of all available capture devices if no capture device is specified.</summary> ///<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. CaptureDeviceSpecifier = 0x310, // ALC_EXT_CAPTURE extension.
///<summary>The specifier string for the device.</summary>
DeviceSpecifier = 0x1005,
/// <summary>A list of all available devices.</summary>
AllDevicesSpecifier = 0x1013,
} }
public enum AlcGetInteger : int public enum AlcGetInteger : int
{ {
///<summary>The specification revision for this implementation (major version). NULL is an acceptable device.</summary> ///<summary>The specification revision for this implementation (major version). NULL is an acceptable device.</summary>
MajorVersion = 0x1000, MajorVersion = 0x1000,
///<summary>The specification revision for this implementation (minor version). NULL is an acceptable device.</summary> ///<summary>The specification revision for this implementation (minor version). NULL is an acceptable device.</summary>
MinorVersion = 0x1001, 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> ///<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, 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> ///<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, AllAttributes = 0x1003,
@ -94,11 +99,5 @@ namespace OpenTK.OpenAL
CaptureSamples = 0x312, CaptureSamples = 0x312,
} }
// ALC_ENUMERATE_ALL_EXT token
public enum AlcEnumerateAll : int
{
DefaultAllDevicesSpecifier = 0x1012,
AllDevicesSpecifier = 0x1013,
}
}
} }

View file

@ -3,18 +3,8 @@
* C header: \freealut-1.1.0-src\include\AL\Alut.h * C header: \freealut-1.1.0-src\include\AL\Alut.h
* Spec: http://www.openal.org/openal_webstf/specs/alut.html * Spec: http://www.openal.org/openal_webstf/specs/alut.html
* Copyright (c) 2008 Christoph Brandtner and Stefanos Apostolopoulos * Copyright (c) 2008 Christoph Brandtner and Stefanos Apostolopoulos
* See license.txt for license details (MIT) * See license.txt for license details
* http://www.OpenTK.net * 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 #endregion
using System; using System;
@ -23,26 +13,30 @@ using System.Security;
namespace OpenTK.OpenAL namespace OpenTK.OpenAL
{ {
/// <summary>Alut, FreeAlut = Free Audio Library Utilities</summary> /// <summary>Alut, FreeAlut = Free Audio Library Utilities</summary>
public static class Alut public static class Alut
{ {
#region Constants #region Constants
private const string Lib = "Alut.dll";
private const string Lib = "alut.dll";
private const CallingConvention Style = CallingConvention.Cdecl; private const CallingConvention Style = CallingConvention.Cdecl;
#endregion Constants #endregion Constants
#region Init/Exit #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> /// <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="argcp">Application Main Parameters. Can be IntPtr.Zero.</param>
/// <param name="argv">Application Main Parameters</param> /// <param name="argv">Application Main Parameters. Can be IntPtr.Zero.</param>
/// <returns>Success.</returns> /// <returns>Success.</returns>
[DllImport(Alut.Lib, EntryPoint = "alutInit", ExactSpelling = true, CallingConvention = Alut.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alut.Lib, EntryPoint = "alutInit", ExactSpelling = true, CallingConvention = Alut.Style), SuppressUnmanagedCodeSecurity()]
internal static extern Al.Bool Init( [In] IntPtr argcp, [In] IntPtr argv ); public static extern AL.Bool Init([In] IntPtr argcp, [In] IntPtr argv);
// ALUT_API ALboolean ALUT_APIENTRY alutInit (int *argcp, char **argv); // ALUT_API ALboolean ALUT_APIENTRY alutInit (int *argcp, char **argv);
/// <summary>Parameterless function for convenience. Internally passes IntPtr.Zero as parameters.</summary> /// <summary>Parameterless function for convenience. Internally passes IntPtr.Zero as parameters.</summary>
/// <returns>Success.</returns> /// <returns>Success.</returns>
internal static Al.Bool Init( ) // overload for convenience public static AL.Bool Init() // overload for convenience
{ {
return Init(IntPtr.Zero, IntPtr.Zero); return Init(IntPtr.Zero, IntPtr.Zero);
} }
@ -52,10 +46,12 @@ namespace OpenTK.OpenAL
/// <param name="argv">Application Main Parameters</param> /// <param name="argv">Application Main Parameters</param>
/// <returns>Success.</returns> /// <returns>Success.</returns>
[DllImport(Alut.Lib, EntryPoint = "alutInitWithoutContext", ExactSpelling = true, CallingConvention = Alut.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alut.Lib, EntryPoint = "alutInitWithoutContext", ExactSpelling = true, CallingConvention = Alut.Style), SuppressUnmanagedCodeSecurity()]
internal static extern Al.Bool InitWithoutContext( [In] IntPtr argcp, [In] IntPtr argv ); public static extern AL.Bool InitWithoutContext([In] IntPtr argcp, [In] IntPtr argv);
// ALUT_API ALboolean ALUT_APIENTRY alutInitWithoutContext (int *argcp, char **argv); // ALUT_API ALboolean ALUT_APIENTRY alutInitWithoutContext (int *argcp, char **argv);
internal static Al.Bool InitWithoutContext( ) // overload for convenience /// <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>
/// <returns>Success.</returns>
public static AL.Bool InitWithoutContext() // overload for convenience
{ {
return InitWithoutContext(IntPtr.Zero, IntPtr.Zero); return InitWithoutContext(IntPtr.Zero, IntPtr.Zero);
} }
@ -63,51 +59,55 @@ namespace OpenTK.OpenAL
/// <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> /// <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> /// <returns>Success.</returns>
[DllImport(Alut.Lib, EntryPoint = "alutExit", ExactSpelling = true, CallingConvention = Alut.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alut.Lib, EntryPoint = "alutExit", ExactSpelling = true, CallingConvention = Alut.Style), SuppressUnmanagedCodeSecurity()]
internal static extern Al.Bool Exit( ); public static extern AL.Bool Exit();
// ALUT_API ALboolean ALUT_APIENTRY alutExit (void); // ALUT_API ALboolean ALUT_APIENTRY alutExit (void);
#endregion Init/Exit #endregion Init/Exit
#region Error Checking #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> /// <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> /// <returns><see cref="Enums.AlutError"/></returns>
[DllImport(Alut.Lib, EntryPoint = "alutGetError", ExactSpelling = true, CallingConvention = Alut.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alut.Lib, EntryPoint = "alutGetError", ExactSpelling = true, CallingConvention = Alut.Style), SuppressUnmanagedCodeSecurity()]
internal static extern Enums.AlutError GetError( ); public static extern Enums.AlutError GetError();
// ALUT_API ALenum ALUT_APIENTRY alutGetError (void); // ALUT_API ALenum ALUT_APIENTRY alutGetError (void);
[DllImport(Alut.Lib, EntryPoint = "alutGetErrorString", ExactSpelling = true, CallingConvention = Alut.Style, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity()] [DllImport(Alut.Lib, EntryPoint = "alutGetErrorString", ExactSpelling = true, CallingConvention = Alut.Style, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity()]
private static extern IntPtr GetErrorStringInternal( Enums.AlutError error ); private static extern IntPtr GetErrorStringPrivate(Enums.AlutError error);
// ALUT_API const char *ALUT_APIENTRY alutGetErrorString (ALenum 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> /// <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> /// <param name="error">Retrieve first occured error with Alut.GetError</param>
/// <returns>A human-readable description of the Error.</returns> /// <returns>A human-readable description of the Error.</returns>
internal static string GetErrorString( Enums.AlutError error ) public static string GetErrorString(Enums.AlutError error)
{ {
return Marshal.PtrToStringAnsi( GetErrorStringInternal( error ) ); return Marshal.PtrToStringAnsi(GetErrorStringPrivate(error));
} }
#endregion Error Checking #endregion Error Checking
#region File Loading #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> /// <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> /// <param name="filename">The file to be loaded</param>
/// <returns>OpenAL Buffer, 0 on failure.</returns> /// <returns>OpenAL Buffer, 0 on failure.</returns>
[DllImport( Alut.Lib, EntryPoint = "alutCreateBufferFromFile", ExactSpelling = true, CallingConvention = Alut.Style, CharSet = CharSet.Ansi ), SuppressUnmanagedCodeSecurity( )] [CLSCompliant(false), DllImport(Alut.Lib, EntryPoint = "alutCreateBufferFromFile", ExactSpelling = true, CallingConvention = Alut.Style, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity()]
internal static extern uint CreateBufferFromFile( [In] string filename ); public static extern uint CreateBufferFromFile([In] string filename);
// ALUT_API ALuint ALUT_APIENTRY alutCreateBufferFromFile (const char *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> /// <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="data">A Pointer to the sound data in memory.</param>
/// <param name="length">Size in Bytes of the sound data.</param> /// <param name="length">Size in Bytes of the sound data.</param>
/// <returns>OpenAL Buffer, 0 on failure.</returns> /// <returns>OpenAL Buffer, 0 on failure.</returns>
[DllImport( Alut.Lib, EntryPoint = "alutCreateBufferFromFileImage", ExactSpelling = true, CallingConvention = Alut.Style ), SuppressUnmanagedCodeSecurity( )] [CLSCompliant(false), DllImport(Alut.Lib, EntryPoint = "alutCreateBufferFromFileImage", ExactSpelling = true, CallingConvention = Alut.Style), SuppressUnmanagedCodeSecurity()]
internal static extern uint CreateBufferFromFileImage( [In] IntPtr data, int length ); public static extern uint CreateBufferFromFileImage([In] IntPtr data, int length);
// ALUT_API ALuint ALUT_APIENTRY alutCreateBufferFromFileImage (const ALvoid *data, ALsizei 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> /// <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> /// <returns>OpenAL Buffer, 0 on failure.</returns>
[DllImport( Alut.Lib, EntryPoint = "alutCreateBufferHelloWorld", ExactSpelling = true, CallingConvention = Alut.Style ), SuppressUnmanagedCodeSecurity( )] [CLSCompliant(false), DllImport(Alut.Lib, EntryPoint = "alutCreateBufferHelloWorld", ExactSpelling = true, CallingConvention = Alut.Style), SuppressUnmanagedCodeSecurity()]
internal static extern uint CreateBufferHelloWorld( ); public static extern uint CreateBufferHelloWorld();
//ALUT_API ALuint ALUT_APIENTRY alutCreateBufferHelloWorld (void); //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> /// <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>
@ -116,8 +116,8 @@ namespace OpenTK.OpenAL
/// <param name="phase">Phase (in degrees: -180 to +180)</param> /// <param name="phase">Phase (in degrees: -180 to +180)</param>
/// <param name="duration">Duration (in seconds)</param> /// <param name="duration">Duration (in seconds)</param>
/// <returns>OpenAL Buffer, 0 on failure.</returns> /// <returns>OpenAL Buffer, 0 on failure.</returns>
[DllImport( Alut.Lib, EntryPoint = "alutCreateBufferWaveform", ExactSpelling = true, CallingConvention = Alut.Style ), SuppressUnmanagedCodeSecurity( )] [CLSCompliant(false), 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 ); public 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); // ALUT_API ALuint ALUT_APIENTRY alutCreateBufferWaveform (ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration);
// Warning: these leak memory if not properly free'd // Warning: these leak memory if not properly free'd
@ -125,11 +125,12 @@ namespace OpenTK.OpenAL
// ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryFromFileImage (const ALvoid *data, ALsizei length, 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 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); // ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryWaveform (ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration, ALenum *format, ALsizei *size, ALfloat *freq);
#endregion File Loading #endregion File Loading
#region Misc #region Misc
[DllImport(Alut.Lib, EntryPoint = "alutGetMIMETypes", ExactSpelling = true, CallingConvention = Alut.Style, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity()] [DllImport(Alut.Lib, EntryPoint = "alutGetMIMETypes", ExactSpelling = true, CallingConvention = Alut.Style, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity()]
private static extern IntPtr GetMIMETypesInternal( Enums.AlutLoader loader ); private static extern IntPtr GetMIMETypesPrivate(Enums.AlutLoader loader);
// ALUT_API const char *ALUT_APIENTRY alutGetMIMETypes (ALenum 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". /// <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".
@ -137,31 +138,34 @@ namespace OpenTK.OpenAL
/// </summary> /// </summary>
/// <param name="loader"><see cref="Enums.AlutLoader"/></param> /// <param name="loader"><see cref="Enums.AlutLoader"/></param>
/// <returns>A comma-separated list of supported MIME types.</returns> /// <returns>A comma-separated list of supported MIME types.</returns>
internal static string GetMIMETypes( Enums.AlutLoader loader ) public static string GetMIMETypes(Enums.AlutLoader loader)
{ {
return Marshal.PtrToStringAnsi( GetMIMETypesInternal( loader ) ); return Marshal.PtrToStringAnsi(GetMIMETypesPrivate(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> /// <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> /// <returns>Major Version Number.</returns>
[DllImport(Alut.Lib, EntryPoint = "alutGetMajorVersion", ExactSpelling = true, CallingConvention = Alut.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alut.Lib, EntryPoint = "alutGetMajorVersion", ExactSpelling = true, CallingConvention = Alut.Style), SuppressUnmanagedCodeSecurity()]
internal static extern int GetMajorVersion( ); public static extern int GetMajorVersion();
// ALUT_API ALint ALUT_APIENTRY alutGetMajorVersion (void); // 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> /// <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> /// <returns>Minor Version Number.</returns>
[DllImport(Alut.Lib, EntryPoint = "alutGetMinorVersion", ExactSpelling = true, CallingConvention = Alut.Style), SuppressUnmanagedCodeSecurity()] [DllImport(Alut.Lib, EntryPoint = "alutGetMinorVersion", ExactSpelling = true, CallingConvention = Alut.Style), SuppressUnmanagedCodeSecurity()]
internal static extern int GetMinorVersion( ); public static extern int GetMinorVersion();
// ALUT_API ALint ALUT_APIENTRY alutGetMinorVersion (void); // 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. /// <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. /// 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> /// </summary>
/// <param name="duration">Number of seconds. May not be negative.</param> /// <param name="duration">Number of seconds. May not be negative.</param>
/// <returns>Success.</returns> /// <returns>Success.</returns>
[DllImport( Alut.Lib, EntryPoint = "alutSleep", ExactSpelling = true, CallingConvention = Alut.Style ), SuppressUnmanagedCodeSecurity( )] [DllImport( Alut.Lib, EntryPoint = "alutSleep", ExactSpelling = true, CallingConvention = Alut.Style ), SuppressUnmanagedCodeSecurity( )]
internal static extern Al.Bool Sleep( float duration ); public static extern AL.Bool Sleep( float duration );
// ALUT_API ALboolean ALUT_APIENTRY alutSleep (ALfloat duration); // ALUT_API ALboolean ALUT_APIENTRY alutSleep (ALfloat duration);
*/
#endregion Misc #endregion Misc
} }
} }

View file

@ -3,24 +3,15 @@
* C header: \freealut-1.1.0-src\include\AL\Alut.h * C header: \freealut-1.1.0-src\include\AL\Alut.h
* Spec: http://www.openal.org/openal_webstf/specs/alut.html * Spec: http://www.openal.org/openal_webstf/specs/alut.html
* Copyright (c) 2008 Christoph Brandtner and Stefanos Apostolopoulos * Copyright (c) 2008 Christoph Brandtner and Stefanos Apostolopoulos
* See license.txt for license details (MIT) * See license.txt for license details
* http://www.OpenTK.net * http://www.OpenTK.net */
*/
/* Version History:
* 0.1
* - Tokens AL_TRUE and AL_FALSE removed, created new type. see Al.Bool
*
*
*/
#endregion #endregion
using System; using System;
namespace OpenTK.OpenAL namespace OpenTK.OpenAL.Enums
{
public partial class Enums
{ {
public enum AlutVersions : int public enum AlutVersions : int
{ {
/// <summary>Defines the A in OpenAL A.B</summary> /// <summary>Defines the A in OpenAL A.B</summary>
@ -87,5 +78,5 @@ namespace OpenTK.OpenAL
///<summary>For the loaders returning sound data in a newly allocated memory region, e.g. Alut.LoadMemoryFromFile and Alut.LoadMemoryFromFileImage.</summary> ///<summary>For the loaders returning sound data in a newly allocated memory region, e.g. Alut.LoadMemoryFromFile and Alut.LoadMemoryFromFileImage.</summary>
Memory = 0x301, Memory = 0x301,
} }
}
} }

View file

@ -0,0 +1,47 @@
Version History:
0.1 Initial
- Tokens AL_TRUE and AL_FALSE removed, created new type. see AL.Bool
Tokens ALC_TRUE and ALC_FALSE removed, created new type. see AL.Bool
- Added AL.Null for convenience when working with C Manuals.
- Alut: 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.
- AL: Functions not imported:
alListeneri, alListener3i, alListeneriv
alGetListeneri, alGetListener3i, alGetListeneriv
alGetBooleanv, alGetIntegerv, alGetFloatv, alGetDoublev
imported, but currently disabled: alGetBoolean, alGetDouble
alBufferf, alBufferfv, alBufferi, alBuffer3i, alBufferiv
imported, but currently disabled: alBuffer3f
alGetBufferf, alGetBuffer3f, alGetBufferfv, alGetBuffer3i, alGetBufferiv
0.2
- Largely improved documentation, found homes for previously orphaned Tokens.
- The Token AL_DATA is hidden now, as it returns a pointer to unmanaged memory
where the buffer was located previously to calling AL.BufferData(). (It is usually freed after buffering)
- Added Function AL.GetErrorString()
- Added overloads for requesting/deleting a single buffer/source at a time.
- Added Vector3 overloads where applicable.
0.3 - breaks former written examples.
- Using a single changelog now, as the number of issues per file has significantly shrunk.
- Refactored -i -fv -3f functions to be overloads e.g AL.GetSource, AL.GetListener
- Added XRam Extension prototype. Untested, as it requires special hardware.
- Refactored extensively to match OpenTK naming conventions.
- Moved functions into overloads
- Removed all C prototype comments from AL/ALC/ALUT
- Documented Alc properly
0.4
- changed Alc enum GetString/GetStringList
- disabled Alut.Sleep, rather use Thread.Sleep
- DopplerVelocity, ChannelMask are deprecated and marked.
- functions with ushort, uint, ulong marked
0.5 vanilla complete
- Fix Alc.GetString( Enums.AlcGetStringList ) to terminate with 2 null, and split at 1 null
Next Version:
- EFX Extension
- Enums themselves require summaries (do EFX 1st)

View file

@ -0,0 +1,149 @@
#region --- OpenTK.OpenAL License ---
/* XRamExtension.cs
* C header: \OpenAL 1.1 SDK\include\xram.h
* Spec: ?
* Copyright (c) 2008 Christoph Brandtner and Stefanos Apostolopoulos
* See license.txt for license details (MIT)
* http://www.OpenTK.net */
#endregion
using System;
using System.Runtime.InteropServices;
namespace OpenTK.OpenAL
{
public class XRamExtension
{
#region instance state
private bool _valid = false;
/// <summary>Returns True if the X-Ram Extension has been found and could be initialized.</summary>
public bool IsInitialized
{
get { return _valid; }
}
#endregion instance state
#region X-RAM Function pointer definitions
public unsafe delegate AL.Bool SetBufferMode(int n, ref uint buffers, int value);
//typedef ALboolean (__cdecl *EAXSetBufferMode)(ALsizei n, ALuint *buffers, ALint value);
public delegate int GetBufferMode(uint buffer, out int value);
//typedef ALenum (__cdecl *EAXGetBufferMode)(ALuint buffer, ALint *value);
public SetBufferMode EAXSetBufferMode;
public GetBufferMode EAXGetBufferMode;
#endregion X-RAM Function pointer definitions
#region X-RAM Tokens
private int AL_EAX_RAM_SIZE, AL_EAX_RAM_FREE,
AL_STORAGE_AUTOMATIC, AL_STORAGE_HARDWARE, AL_STORAGE_ACCESSIBLE;
#endregion X-RAM Tokens
#region Constructor / Extension Loading
public XRamExtension()
{ // Query if Extension supported and retrieve Tokens/Pointers if it is.
_valid = false;
if (AL.IsExtensionPresent("EAX-RAM") == AL.Bool.False)
return;
AL_EAX_RAM_SIZE = AL.GetEnumValue("AL_EAX_RAM_SIZE");
AL_EAX_RAM_FREE = AL.GetEnumValue("AL_EAX_RAM_FREE");
AL_STORAGE_AUTOMATIC = AL.GetEnumValue("AL_STORAGE_AUTOMATIC");
AL_STORAGE_HARDWARE = AL.GetEnumValue("AL_STORAGE_HARDWARE");
AL_STORAGE_ACCESSIBLE = AL.GetEnumValue("AL_STORAGE_ACCESSIBLE");
Console.WriteLine("RamSize: {0} RamFree: {1} StorageAuto: {2} StorageHW: {3} StorageAccess: {4}", AL_EAX_RAM_SIZE, AL_EAX_RAM_FREE, AL_STORAGE_AUTOMATIC, AL_STORAGE_HARDWARE, AL_STORAGE_ACCESSIBLE);
if (AL_EAX_RAM_SIZE == 0 ||
AL_EAX_RAM_FREE == 0 ||
AL_STORAGE_AUTOMATIC == 0 ||
AL_STORAGE_HARDWARE == 0 ||
AL_STORAGE_ACCESSIBLE == 0)
{
Console.WriteLine("Token values could not be retrieved.");
return;
}
Console.WriteLine("Free Ram: {0} / {1}", GetRamFree(), GetRamSize());
try
{
EAXGetBufferMode = (GetBufferMode)Marshal.GetDelegateForFunctionPointer(AL.GetProcAddress("EAXGetBufferMode"), typeof(GetBufferMode));
EAXSetBufferMode = (SetBufferMode)Marshal.GetDelegateForFunctionPointer(AL.GetProcAddress("EAXSetBufferMode"), typeof(SetBufferMode));
}
catch (Exception e)
{
Console.WriteLine("Attempt to marshal AL.GetProcAddress failed. " + e.ToString());
return;
}
_valid = true;
}
#endregion Constructor / Extension Loading
#region Public Methods
/// <summary>Query total amount of X-RAM.</summary>
public int GetRamSize()
{
return AL.Get((Enums.ALGetInteger)AL_EAX_RAM_SIZE);
}
/// <summary>Query free X-RAM available.</summary>
public int GetRamFree()
{
return AL.Get((Enums.ALGetInteger)AL_EAX_RAM_FREE);
}
public enum XRamStorage : byte
{
/// <summary>Put an Open AL Buffer into X-RAM if memory is available, otherwise use host RAM. This is the default mode.
/// alGenBuffers(1, &uiBuffer);
/// eaxSetBufferMode(1, &uiBuffer, alGetEnumValue("AL_STORAGE_AUTOMATIC"));
/// alBufferData(...);
/// </summary>
Automatic,
/// <summary>Force an Open AL Buffer into X-RAM (good for non-streaming buffers)
// alGenBuffers(1, &uiBuffer);
// eaxSetBufferMode(1, &uiBuffer, alGetEnumValue("AL_STORAGE_HARDWARE"));
// alBufferData(...);
/// </summary>
Hardware = 1,
/// <summary>Force an Open AL Buffer into 'accessible' (currently host) RAM (good for streaming buffers)
/// alGenBuffers(1, &uiBuffer);
/// eaxSetBufferMode(1, &uiBuffer, alGetEnumValue("AL_STORAGE_ACCESSIBLE"));
/// alBufferData(...);
/// </summary>
Acessible = 2,
}
public void _SetBufferMode(ref uint buffer, XRamStorage mode)
{
switch (mode)
{
case XRamStorage.Acessible:
EAXSetBufferMode(1, ref buffer, AL_STORAGE_ACCESSIBLE);
break;
case XRamStorage.Hardware:
EAXSetBufferMode(1, ref buffer, AL_STORAGE_HARDWARE);
break;
default:
EAXSetBufferMode(1, ref buffer, AL_STORAGE_AUTOMATIC);
break;
}
}
#endregion Public Methods
}
}