C# Class OpenTK.Audio.AudioContext

Provides methods to instantiate, use and destroy an audio context for playback. Static methods are provided to list available devices known by the driver.
Inheritance: IDisposable
Mostra file Open project: hultqvist/opentk Class Usage Examples

Private Properties

Property Type Description
AudioContext System
CreateContext void
Dispose void
MakeCurrent void

Public Methods

Method Description
AudioContext ( string device ) : System

Constructs a new AudioContext instance.

AudioContext ( string device, int freq ) : System

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

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

AudioContext ( string device, int freq, int refresh ) : System

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

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

AudioContext ( string device, int freq, int refresh, bool sync ) : System

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

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

AudioContext ( string device, int freq, int refresh, bool sync, bool enableEfx ) : System

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

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.

AudioContext ( string device, int freq, int refresh, bool sync, bool enableEfx, MaxAuxiliarySends efxMaxAuxSends ) : System

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

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.

CheckErrors ( ) : void

Checks for ALC error conditions.

Dispose ( ) : void

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

Equals ( object obj ) : bool

Compares this instance with another.

GetHashCode ( ) : int

Calculates the hash code for this instance.

MakeCurrent ( ) : void

Makes the AudioContext current in the calling thread.

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

Process ( ) : void

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.

SupportsExtension ( string extension ) : bool

Checks whether the specified OpenAL extension is supported.

Suspend ( ) : void

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.

ToString ( ) : string

Returns a System.String that desrcibes this instance.

Private Methods

Method Description
AudioContext ( ) : System

Runs before the actual class constructor, to load available devices.

CreateContext ( string device, int freq, int refresh, bool sync, bool enableEfx, MaxAuxiliarySends efxAuxiliarySends ) : void

Creates the audio context using the specified device.

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.

Dispose ( bool manual ) : void
MakeCurrent ( AudioContext context ) : void

Makes the specified AudioContext current in the calling thread.

Method Details

AudioContext() public method

Constructs a new AudioContext instance.
public AudioContext ( string device ) : System
device string The device name that will host this instance.
return System

AudioContext() public method

Constructs a new AudioContext, using the specified audio device and device parameters.
Use AudioContext.AvailableDevices to obtain a list of all available audio devices. devices.
public AudioContext ( string device, int freq ) : System
device string The name of the audio device to use.
freq int Frequency for mixing output buffer, in units of Hz. Pass 0 for driver default.
return System

AudioContext() public method

Constructs a new AudioContext, using the specified audio device and device parameters.
Use AudioContext.AvailableDevices to obtain a list of all available audio devices. devices.
public AudioContext ( string device, int freq, int refresh ) : System
device string The name of the audio device to use.
freq int Frequency for mixing output buffer, in units of Hz. Pass 0 for driver default.
refresh int Refresh intervals, in units of Hz. Pass 0 for driver default.
return System

AudioContext() public method

Constructs a new AudioContext, using the specified audio device and device parameters.
Use AudioContext.AvailableDevices to obtain a list of all available audio devices. devices.
public AudioContext ( string device, int freq, int refresh, bool sync ) : System
device string The name of the audio device to use.
freq int Frequency for mixing output buffer, in units of Hz. Pass 0 for driver default.
refresh int Refresh intervals, in units of Hz. Pass 0 for driver default.
sync bool Flag, indicating a synchronous context.
return System

AudioContext() public method

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

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.

Occurs when the device string is invalid. Occurs when a specified parameter is invalid. /// Occurs when the specified device is not available, or is in use by another program. /// /// Occurs when an audio context could not be created with the specified parameters. /// /// Occurs when an AudioContext already exists.
public AudioContext ( string device, int freq, int refresh, bool sync, bool enableEfx ) : System
device string The device descriptor obtained through AudioContext.AvailableDevices.
freq int Frequency for mixing output buffer, in units of Hz. Pass 0 for driver default.
refresh int Refresh intervals, in units of Hz. Pass 0 for driver default.
sync bool Flag, indicating a synchronous context.
enableEfx bool Indicates whether the EFX extension should be initialized, if present.
return System

AudioContext() public method

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

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.

Occurs when the device string is invalid. Occurs when a specified parameter is invalid. /// Occurs when the specified device is not available, or is in use by another program. /// /// Occurs when an audio context could not be created with the specified parameters. /// /// Occurs when an AudioContext already exists.
public AudioContext ( string device, int freq, int refresh, bool sync, bool enableEfx, MaxAuxiliarySends efxMaxAuxSends ) : System
device string The device descriptor obtained through AudioContext.AvailableDevices.
freq int Frequency for mixing output buffer, in units of Hz. Pass 0 for driver default.
refresh int Refresh intervals, in units of Hz. Pass 0 for driver default.
sync bool Flag, indicating a synchronous context.
enableEfx bool Indicates whether the EFX extension should be initialized, if present.
efxMaxAuxSends MaxAuxiliarySends Requires EFX enabled. The number of desired Auxiliary Sends per source.
return System

CheckErrors() public method

Checks for ALC error conditions.
Raised when an out of memory error is detected. Raised when an invalid value is detected. Raised when an invalid device is detected. Raised when an invalid context is detected.
public CheckErrors ( ) : void
return void

Dispose() public method

Disposes of the AudioContext, cleaning up all resources consumed by it.
public Dispose ( ) : void
return void

Equals() public method

Compares this instance with another.
public Equals ( object obj ) : bool
obj object The instance to compare to.
return bool

GetHashCode() public method

Calculates the hash code for this instance.
public GetHashCode ( ) : int
return int

MakeCurrent() public method

Makes the AudioContext current in the calling thread.
Only one AudioContext can be current in the application at any time, regardless of the number of threads.
/// Occurs if this function is called after the AudioContext has been disposed. /// /// Occurs when the AudioContext could not be made current. ///
public MakeCurrent ( ) : void
return void

Process() public method

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.

Occurs when this function is called after the AudioContext had been disposed.
public Process ( ) : void
return void

SupportsExtension() public method

Checks whether the specified OpenAL extension is supported.
public SupportsExtension ( string extension ) : bool
extension string The name of the extension to check (e.g. "ALC_EXT_EFX").
return bool

Suspend() public method

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.

Occurs when this function is called after the AudioContext had been disposed.
public Suspend ( ) : void
return void

ToString() public method

Returns a System.String that desrcibes this instance.
public ToString ( ) : string
return string