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...

List of all members.

Public Types

enum  MaxAuxiliarySends {
  UseDriverDefault = 0, One = 1, Two = 2, Three = 3,
  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.
 AudioContext (string device)
 Constructs a new AudioContext instance.
 AudioContext (string device, int freq)
 Constructs a new AudioContext, using the specified audio device and device parameters.
 AudioContext (string device, int freq, int refresh)
 Constructs a new AudioContext, using the specified audio device and device parameters.
 AudioContext (string device, int freq, int refresh, bool sync)
 Constructs a new AudioContext, using the specified audio device and device parameters.
 AudioContext (string device, int freq, int refresh, bool sync, bool enableEfx)
 Creates the audio context using the specified device and device parameters.
 AudioContext (string device, int freq, int refresh, bool sync, bool enableEfx, MaxAuxiliarySends efxMaxAuxSends)
 Creates the audio context using the specified device and device parameters.
void CheckErrors ()
 Checks for ALC error conditions.
void MakeCurrent ()
 Makes the AudioContext current in the calling thread.
void Process ()
 Processes queued audio events.
void Suspend ()
 Suspends processing of audio events.
bool SupportsExtension (string extension)
 Checks whether the specified OpenAL extension is supported.
void Dispose ()
 Disposes of the AudioContext, cleaning up all resources consumed by it.
override int GetHashCode ()
 Calculates the hash code for this instance.
override bool Equals (object obj)
 Compares this instance with another.
override string ToString ()
 Returns a System.String that desrcibes this instance.

Properties

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

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.

Definition at line 42 of file AudioContext.cs.


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.

Definition at line 212 of file AudioContext.cs.

00212                                      :int
00213         {
00215             UseDriverDefault = 0,
00217             One = 1,
00219             Two = 2,
00221             Three = 3,
00223             Four = 4,
00224         }


Constructor & Destructor Documentation

OpenTK.Audio.AudioContext.AudioContext (  ) 

Constructs a new AudioContext, using the default audio device.

Definition at line 77 of file AudioContext.cs.

00078             : this(null, 0, 0, false, true, MaxAuxiliarySends.UseDriverDefault) { }

OpenTK.Audio.AudioContext.AudioContext ( string  device  ) 

Constructs a new AudioContext instance.

Parameters:
device The device name that will host this instance.

Definition at line 88 of file AudioContext.cs.

00088 : this(device, 0, 0, false, true, MaxAuxiliarySends.UseDriverDefault) { }

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

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

Parameters:
device The name of the audio device to use.
freq Frequency 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.

Definition at line 101 of file AudioContext.cs.

00101 : this(device, freq, 0, false, true, MaxAuxiliarySends.UseDriverDefault) { }

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

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

Parameters:
device The name of the audio device to use.
freq Frequency for mixing output buffer, in units of Hz. Pass 0 for driver default.
refresh Refresh intervals, in units of Hz. Pass 0 for driver default.

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

Definition at line 115 of file AudioContext.cs.

00116             : this(device, freq, refresh, false, true, MaxAuxiliarySends.UseDriverDefault) { }

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:
device The name of the audio device to use.
freq Frequency for mixing output buffer, in units of Hz. Pass 0 for driver default.
refresh Refresh intervals, in units of Hz. Pass 0 for driver default.
sync Flag, indicating a synchronous context.

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

Definition at line 131 of file AudioContext.cs.

00132             : this(AudioDeviceEnumerator.AvailablePlaybackDevices[0], freq, refresh, sync, true) { }

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:
device The device descriptor obtained through AudioContext.AvailableDevices.
freq Frequency for mixing output buffer, in units of Hz. Pass 0 for driver default.
refresh Refresh intervals, in units of Hz. Pass 0 for driver default.
sync Flag, indicating a synchronous context.
enableEfx Indicates whether the EFX extension should be initialized, if present.
Exceptions:
ArgumentNullException Occurs when the device string is invalid.
ArgumentOutOfRangeException Occurs when a specified parameter is invalid.
AudioDeviceException Occurs when the specified device is not available, or is in use by another program.
AudioContextException Occurs when an audio context could not be created with the specified parameters.
NotSupportedException Occurs 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.

Definition at line 163 of file AudioContext.cs.

00164         {
00165             CreateContext(device, freq, refresh, sync, enableEfx, MaxAuxiliarySends.UseDriverDefault);
00166         }

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:
device The device descriptor obtained through AudioContext.AvailableDevices.
freq Frequency for mixing output buffer, in units of Hz. Pass 0 for driver default.
refresh Refresh intervals, in units of Hz. Pass 0 for driver default.
sync Flag, indicating a synchronous context.
enableEfx Indicates whether the EFX extension should be initialized, if present.
efxMaxAuxSends Requires EFX enabled. The number of desired Auxiliary Sends per source.
Exceptions:
ArgumentNullException Occurs when the device string is invalid.
ArgumentOutOfRangeException Occurs when a specified parameter is invalid.
AudioDeviceException Occurs when the specified device is not available, or is in use by another program.
AudioContextException Occurs when an audio context could not be created with the specified parameters.
NotSupportedException Occurs 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.

Definition at line 198 of file AudioContext.cs.

00199         {
00200             CreateContext(device, freq, refresh, sync, enableEfx, efxMaxAuxSends);
00201         }


Member Function Documentation

void OpenTK.Audio.AudioContext.CheckErrors (  ) 

Checks for ALC error conditions.

Exceptions:
OutOfMemoryException Raised when an out of memory error is detected.
AudioValueException Raised when an invalid value is detected.
AudioDeviceException Raised when an invalid device is detected.
AudioContextException Raised when an invalid context is detected.

Definition at line 434 of file AudioContext.cs.

00435         {
00436             if (disposed)
00437                 throw new ObjectDisposedException(this.GetType().FullName);
00438 
00439             new AudioDeviceErrorChecker(device_handle).Dispose();
00440         }

void OpenTK.Audio.AudioContext.Dispose (  ) 

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

Definition at line 698 of file AudioContext.cs.

00699         {
00700             this.Dispose(true);
00701             GC.SuppressFinalize(this);
00702         }

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

Compares this instance with another.

Parameters:
obj The instance to compare to.
Returns:
True, if obj refers to this instance; false otherwise.

Definition at line 753 of file AudioContext.cs.

00754         {
00755             return base.Equals(obj);
00756         }

override int OpenTK.Audio.AudioContext.GetHashCode (  ) 

Calculates the hash code for this instance.

Returns:

Definition at line 743 of file AudioContext.cs.

00744         {
00745             return base.GetHashCode();
00746         }

void OpenTK.Audio.AudioContext.MakeCurrent (  ) 

Makes the AudioContext current in the calling thread.

Exceptions:
ObjectDisposedException Occurs if this function is called after the AudioContext has been disposed.
AudioContextException Occurs 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.

Definition at line 475 of file AudioContext.cs.

00476         {
00477             if (disposed)
00478                 throw new ObjectDisposedException(this.GetType().FullName);
00479 
00480             AudioContext.MakeCurrent(this);
00481         }

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:
ObjectDisposedException Occurs when this function is called after the AudioContext had been disposed.
See also:
Suspend, IsProcessing, IsSynchronized

Definition at line 548 of file AudioContext.cs.

00549         {
00550             if (disposed)
00551                 throw new ObjectDisposedException(this.GetType().FullName);
00552 
00553             Alc.ProcessContext(this.context_handle);
00554             IsProcessing = true;
00555         }

bool OpenTK.Audio.AudioContext.SupportsExtension ( string  extension  ) 

Checks whether the specified OpenAL extension is supported.

Parameters:
extension The name of the extension to check (e.g. "ALC_EXT_EFX").
Returns:
true if the extension is supported; false otherwise.

Definition at line 599 of file AudioContext.cs.

00600         {
00601             if (disposed)
00602                 throw new ObjectDisposedException(this.GetType().FullName);
00603 
00604             return Alc.IsExtensionPresent(this.Device, extension);
00605         }

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:
ObjectDisposedException Occurs when this function is called after the AudioContext had been disposed.
See also:
Process, IsProcessing, IsSynchronized

Definition at line 581 of file AudioContext.cs.

00582         {
00583             if (disposed)
00584                 throw new ObjectDisposedException(this.GetType().FullName);
00585 
00586             Alc.SuspendContext(this.context_handle);
00587             IsProcessing = false;
00588         }

override string OpenTK.Audio.AudioContext.ToString (  ) 

Returns a System.String that desrcibes this instance.

Returns:
A System.String that desrcibes this instance.

Definition at line 762 of file AudioContext.cs.

00763         {
00764             return String.Format("{0} (handle: {1}, device: {2})",
00765                                  this.device_name, this.context_handle, this.device_handle);
00766         }


Property Documentation

IList<string> OpenTK.Audio.AudioContext.AvailableDevices [static, get]

Returns a list of strings containing all known playback devices.

Definition at line 668 of file AudioContext.cs.

AudioContext OpenTK.Audio.AudioContext.CurrentContext [static, get]

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.

Definition at line 641 of file AudioContext.cs.

string OpenTK.Audio.AudioContext.CurrentDevice [get]

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

Definition at line 615 of file AudioContext.cs.

AlcError OpenTK.Audio.AudioContext.CurrentError [get]

Returns the ALC error code for this instance.

Definition at line 450 of file AudioContext.cs.

string OpenTK.Audio.AudioContext.DefaultDevice [static, get]

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

Definition at line 682 of file AudioContext.cs.

bool OpenTK.Audio.AudioContext.IsProcessing [get, set]

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

See also:
Process, Suspend

Definition at line 494 of file AudioContext.cs.

bool OpenTK.Audio.AudioContext.IsSynchronized [get, set]

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

See also:
Process

Definition at line 515 of file AudioContext.cs.

 All Classes Functions Variables Enumerations Properties Events

Generated on Tue Mar 9 14:59:19 2010 for The Open Toolkit library by  doxygen 1.6.1