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

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

Inherits IDisposable.

Public Member Functions

 AudioCapture ()
 Opens the default device for audio recording. Implicitly set parameters are: 22050Hz, 16Bit Mono, 4096 samples ringbuffer. More...
 
 AudioCapture (string deviceName, int frequency, ALFormat sampleFormat, int bufferSize)
 Opens a device for audio recording. More...
 
void CheckErrors ()
 Checks for ALC error conditions. More...
 
void Start ()
 Start recording samples. The number of available samples can be obtained through the AvailableSamples property. The data can be queried with any ReadSamples(IntPtr, int) method. More...
 
void Stop ()
 Stop recording samples. This will not clear previously recorded samples. More...
 
void ReadSamples (IntPtr buffer, int sampleCount)
 Fills the specified buffer with samples from the internal capture ring-buffer. This method does not block: it is an error to specify a sampleCount larger than AvailableSamples. More...
 
void ReadSamples< TBuffer > (TBuffer[] buffer, int sampleCount)
 Fills the specified buffer with samples from the internal capture ring-buffer. This method does not block: it is an error to specify a sampleCount larger than AvailableSamples. More...
 
void Dispose ()
 Closes the device and disposes the instance. More...
 

Properties

string CurrentDevice [get]
 The name of the device associated with this instance. More...
 
static IList< string > AvailableDevices [get]
 Returns a list of strings containing all known recording devices. More...
 
static string DefaultDevice [get]
 Returns the name of the device that will be used as recording default. More...
 
AlcError CurrentError [get]
 Returns the ALC error code for this device. More...
 
int AvailableSamples [get]
 Returns the number of available samples for capture. More...
 
ALFormat SampleFormat [get, set]
 Gets the OpenTK.Audio.ALFormat for this instance. More...
 
int SampleFrequency [get, set]
 Gets the sampling rate for this instance. More...
 
bool IsRunning [get]
 Gets a value indicating whether this instance is currently capturing samples. More...
 

Detailed Description

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

Constructor & Destructor Documentation

OpenTK.Audio.AudioCapture.AudioCapture ( )

Opens the default device for audio recording. Implicitly set parameters are: 22050Hz, 16Bit Mono, 4096 samples ringbuffer.

OpenTK.Audio.AudioCapture.AudioCapture ( string  deviceName,
int  frequency,
ALFormat  sampleFormat,
int  bufferSize 
)

Opens a device for audio recording.

Parameters
deviceNameThe device name.
frequencyThe frequency that the data should be captured at.
sampleFormatThe requested capture buffer format.
bufferSizeThe size of OpenAL's capture internal ring-buffer. This value expects number of samples, not bytes.

Member Function Documentation

void OpenTK.Audio.AudioCapture.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.AudioCapture.Dispose ( )

Closes the device and disposes the instance.

void OpenTK.Audio.AudioCapture.ReadSamples ( IntPtr  buffer,
int  sampleCount 
)

Fills the specified buffer with samples from the internal capture ring-buffer. This method does not block: it is an error to specify a sampleCount larger than AvailableSamples.

Parameters
bufferA pointer to a previously initialized and pinned array.
sampleCountThe number of samples to be written to the buffer.
void OpenTK.Audio.AudioCapture.ReadSamples< TBuffer > ( TBuffer[]  buffer,
int  sampleCount 
)

Fills the specified buffer with samples from the internal capture ring-buffer. This method does not block: it is an error to specify a sampleCount larger than AvailableSamples.

Parameters
bufferThe buffer to fill.
sampleCountThe number of samples to be written to the buffer.
Exceptions
System.ArgumentNullExceptionRaised when buffer is null.
System.ArgumentOutOfRangeExceptionRaised when sampleCount is larger than the buffer.
Type Constraints
TBuffer :struct 
void OpenTK.Audio.AudioCapture.Start ( )

Start recording samples. The number of available samples can be obtained through the AvailableSamples property. The data can be queried with any ReadSamples(IntPtr, int) method.

void OpenTK.Audio.AudioCapture.Stop ( )

Stop recording samples. This will not clear previously recorded samples.

Property Documentation

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

Returns a list of strings containing all known recording devices.

int OpenTK.Audio.AudioCapture.AvailableSamples
get

Returns the number of available samples for capture.

string OpenTK.Audio.AudioCapture.CurrentDevice
get

The name of the device associated with this instance.

AlcError OpenTK.Audio.AudioCapture.CurrentError
get

Returns the ALC error code for this device.

string OpenTK.Audio.AudioCapture.DefaultDevice
staticget

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

bool OpenTK.Audio.AudioCapture.IsRunning
get

Gets a value indicating whether this instance is currently capturing samples.

ALFormat OpenTK.Audio.AudioCapture.SampleFormat
getset

Gets the OpenTK.Audio.ALFormat for this instance.

int OpenTK.Audio.AudioCapture.SampleFrequency
getset

Gets the sampling rate for this instance.