The Open Toolkit library  1.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
OpenTK.Audio.AudioContext Class Reference

Provides methods to instantiate, use and destroy an audio context for playback. Static methods are provided to list available devices known by the driver. More...

Inherits IDisposable.

Public Types

enum  MaxAuxiliarySends : int {
  MaxAuxiliarySends.UseDriverDefault = 0, MaxAuxiliarySends.One = 1, MaxAuxiliarySends.Two = 2, MaxAuxiliarySends.Three = 3,
  MaxAuxiliarySends.Four = 4
}
 May be passed at context construction time to indicate the number of desired auxiliary effect slot sends per source. More...
 

Public Member Functions

 AudioContext ()
 Constructs a new AudioContext, using the default audio device. More...
 
 AudioContext (string device)
 Constructs a new AudioContext instance. More...
 
 AudioContext (string device, int freq)
 Constructs a new AudioContext, using the specified audio device and device parameters. More...
 
 AudioContext (string device, int freq, int refresh)
 Constructs a new AudioContext, using the specified audio device and device parameters. More...
 
 AudioContext (string device, int freq, int refresh, bool sync)
 Constructs a new AudioContext, using the specified audio device and device parameters. More...
 
 AudioContext (string device, int freq, int refresh, bool sync, bool enableEfx)
 Creates the audio context using the specified device and device parameters. More...
 
 AudioContext (string device, int freq, int refresh, bool sync, bool enableEfx, MaxAuxiliarySends efxMaxAuxSends)
 Creates the audio context using the specified device and device parameters. More...
 
void CheckErrors ()
 Checks for ALC error conditions. More...
 
void MakeCurrent ()
 Makes the AudioContext current in the calling thread. More...
 
void Process ()
 Processes queued audio events. More...
 
void Suspend ()
 Suspends processing of audio events. More...
 
bool SupportsExtension (string extension)
 Checks whether the specified OpenAL extension is supported. More...
 
void Dispose ()
 Disposes of the AudioContext, cleaning up all resources consumed by it. More...
 
override int GetHashCode ()
 Calculates the hash code for this instance. More...
 
override bool Equals (object obj)
 Compares this instance with another. More...
 
override string ToString ()
 Returns a System.String that desrcibes this instance. More...
 

Properties

AlcError CurrentError [get]
 Returns the ALC error code for this instance. More...
 
bool IsProcessing [get, set]
 Gets a System.Boolean indicating whether the AudioContext is currently processing audio events. More...
 
bool IsSynchronized [get, set]
 Gets a System.Boolean indicating whether the AudioContext is synchronized. More...
 
string CurrentDevice [get]
 Gets a System.String with the name of the device used in this context. More...
 
static AudioContext CurrentContext [get]
 Gets the OpenTK.Audio.AudioContext which is current in the application. More...
 
static IList< string > AvailableDevices [get]
 Returns a list of strings containing all known playback devices. More...
 
static string DefaultDevice [get]
 Returns the name of the device that will be used as playback default. More...
 

Detailed Description

Provides methods to instantiate, use and destroy an audio context for playback. Static methods are provided to list available devices known by the driver.

Member Enumeration Documentation

May be passed at context construction time to indicate the number of desired auxiliary effect slot sends per source.

Enumerator
UseDriverDefault 

Will chose a reliably working parameter.

One 

One send per source.

Two 

Two sends per source.

Three 

Three sends per source.

Four 

Four sends per source.

Constructor & Destructor Documentation

OpenTK.Audio.AudioContext.AudioContext ( )

Constructs a new AudioContext, using the default audio device.

OpenTK.Audio.AudioContext.AudioContext ( string  device)

Constructs a new AudioContext instance.

Parameters
deviceThe device name that will host this instance.
OpenTK.Audio.AudioContext.AudioContext ( string  device,
int  freq 
)

Constructs a new AudioContext, using the specified audio device and device parameters.

Parameters
deviceThe name of the audio device to use.
freqFrequency for mixing output buffer, in units of Hz. Pass 0 for driver default.

Use AudioContext.AvailableDevices to obtain a list of all available audio devices. devices.

OpenTK.Audio.AudioContext.AudioContext ( string  device,
int  freq,
int  refresh 
)

Constructs a new AudioContext, using the specified audio device and device parameters.

Parameters
deviceThe name of the audio device to use.
freqFrequency for mixing output buffer, in units of Hz. Pass 0 for driver default.
refreshRefresh intervals, in units of Hz. Pass 0 for driver default.

Use AudioContext.AvailableDevices to obtain a list of all available audio devices. devices.

OpenTK.Audio.AudioContext.AudioContext ( string  device,
int  freq,
int  refresh,
bool  sync 
)

Constructs a new AudioContext, using the specified audio device and device parameters.

Parameters
deviceThe name of the audio device to use.
freqFrequency for mixing output buffer, in units of Hz. Pass 0 for driver default.
refreshRefresh intervals, in units of Hz. Pass 0 for driver default.
syncFlag, indicating a synchronous context.

Use AudioContext.AvailableDevices to obtain a list of all available audio devices. devices.

OpenTK.Audio.AudioContext.AudioContext ( string  device,
int  freq,
int  refresh,
bool  sync,
bool  enableEfx 
)

Creates the audio context using the specified device and device parameters.

Parameters
deviceThe device descriptor obtained through AudioContext.AvailableDevices.
freqFrequency for mixing output buffer, in units of Hz. Pass 0 for driver default.
refreshRefresh intervals, in units of Hz. Pass 0 for driver default.
syncFlag, indicating a synchronous context.
enableEfxIndicates whether the EFX extension should be initialized, if present.
Exceptions
ArgumentNullExceptionOccurs when the device string is invalid.
ArgumentOutOfRangeExceptionOccurs when a specified parameter is invalid.
AudioDeviceExceptionOccurs when the specified device is not available, or is in use by another program.
AudioContextExceptionOccurs when an audio context could not be created with the specified parameters.
NotSupportedExceptionOccurs when an AudioContext already exists.

For maximum compatibility, you are strongly recommended to use the default constructor.

Multiple AudioContexts are not supported at this point.

The number of auxilliary EFX sends depends on the audio hardware and drivers. Most Realtek devices, as well as the Creative SB Live!, support 1 auxilliary send. Creative's Audigy and X-Fi series support 4 sends. Values higher than supported will be clamped by the driver.

OpenTK.Audio.AudioContext.AudioContext ( string  device,
int  freq,
int  refresh,
bool  sync,
bool  enableEfx,
MaxAuxiliarySends  efxMaxAuxSends 
)

Creates the audio context using the specified device and device parameters.

Parameters
deviceThe device descriptor obtained through AudioContext.AvailableDevices.
freqFrequency for mixing output buffer, in units of Hz. Pass 0 for driver default.
refreshRefresh intervals, in units of Hz. Pass 0 for driver default.
syncFlag, indicating a synchronous context.
enableEfxIndicates whether the EFX extension should be initialized, if present.
efxMaxAuxSendsRequires EFX enabled. The number of desired Auxiliary Sends per source.
Exceptions
ArgumentNullExceptionOccurs when the device string is invalid.
ArgumentOutOfRangeExceptionOccurs when a specified parameter is invalid.
AudioDeviceExceptionOccurs when the specified device is not available, or is in use by another program.
AudioContextExceptionOccurs when an audio context could not be created with the specified parameters.
NotSupportedExceptionOccurs when an AudioContext already exists.

For maximum compatibility, you are strongly recommended to use the default constructor.

Multiple AudioContexts are not supported at this point.

The number of auxilliary EFX sends depends on the audio hardware and drivers. Most Realtek devices, as well as the Creative SB Live!, support 1 auxilliary send. Creative's Audigy and X-Fi series support 4 sends. Values higher than supported will be clamped by the driver.

Member Function Documentation

void OpenTK.Audio.AudioContext.CheckErrors ( )

Checks for ALC error conditions.

Exceptions
OutOfMemoryExceptionRaised when an out of memory error is detected.
AudioValueExceptionRaised when an invalid value is detected.
AudioDeviceExceptionRaised when an invalid device is detected.
AudioContextExceptionRaised when an invalid context is detected.
void OpenTK.Audio.AudioContext.Dispose ( )

Disposes of the AudioContext, cleaning up all resources consumed by it.

override bool OpenTK.Audio.AudioContext.Equals ( object  obj)

Compares this instance with another.

Parameters
objThe instance to compare to.
Returns
True, if obj refers to this instance; false otherwise.
override int OpenTK.Audio.AudioContext.GetHashCode ( )

Calculates the hash code for this instance.

Returns
void OpenTK.Audio.AudioContext.MakeCurrent ( )

Makes the AudioContext current in the calling thread.

Exceptions
ObjectDisposedExceptionOccurs if this function is called after the AudioContext has been disposed.
AudioContextExceptionOccurs when the AudioContext could not be made current.

Only one AudioContext can be current in the application at any time, regardless of the number of threads.

void OpenTK.Audio.AudioContext.Process ( )

Processes queued audio events.

If AudioContext.IsSynchronized is true, this function will resume the internal audio processing thread. If AudioContext.IsSynchronized is false, you will need to call this function multiple times per second to process audio events.

In some implementations this function may have no effect.

Exceptions
ObjectDisposedExceptionOccurs when this function is called after the AudioContext had been disposed.
See Also
Suspend, IsProcessing, IsSynchronized
bool OpenTK.Audio.AudioContext.SupportsExtension ( string  extension)

Checks whether the specified OpenAL extension is supported.

Parameters
extensionThe name of the extension to check (e.g. "ALC_EXT_EFX").
Returns
true if the extension is supported; false otherwise.
void OpenTK.Audio.AudioContext.Suspend ( )

Suspends processing of audio events.

To avoid audio artifacts when calling this function, set audio gain to zero before suspending an AudioContext.

In some implementations, it can be faster to suspend processing before changing AudioContext state.

In some implementations this function may have no effect.

Exceptions
ObjectDisposedExceptionOccurs when this function is called after the AudioContext had been disposed.
See Also
Process, IsProcessing, IsSynchronized
override string OpenTK.Audio.AudioContext.ToString ( )

Returns a System.String that desrcibes this instance.

Returns
A System.String that desrcibes this instance.

Property Documentation

IList<string> OpenTK.Audio.AudioContext.AvailableDevices
staticget

Returns a list of strings containing all known playback devices.

AudioContext OpenTK.Audio.AudioContext.CurrentContext
staticget

Gets the OpenTK.Audio.AudioContext which is current in the application.

Only one AudioContext can be current in the application at any time, regardless of the number of threads.

string OpenTK.Audio.AudioContext.CurrentDevice
get

Gets a System.String with the name of the device used in this context.

AlcError OpenTK.Audio.AudioContext.CurrentError
get

Returns the ALC error code for this instance.

string OpenTK.Audio.AudioContext.DefaultDevice
staticget

Returns the name of the device that will be used as playback default.

bool OpenTK.Audio.AudioContext.IsProcessing
getset

Gets a System.Boolean indicating whether the AudioContext is currently processing audio events.

See Also
Process, Suspend
bool OpenTK.Audio.AudioContext.IsSynchronized
getset

Gets a System.Boolean indicating whether the AudioContext is synchronized.

See Also
Process