Show / Hide Table of Contents

Class AudioCapture

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

Inheritance
Object
AudioCapture
Implements
IDisposable
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: OpenTK.Audio
Assembly: OpenTK.dll
Syntax
public sealed class AudioCapture : IDisposable

Constructors

AudioCapture()

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

Declaration
public AudioCapture()

AudioCapture(String, Int32, ALFormat, Int32)

Opens a device for audio recording.

Declaration
public AudioCapture(string deviceName, int frequency, ALFormat sampleFormat, int bufferSize)
Parameters
Type Name Description
String deviceName

The device name.

Int32 frequency

The frequency that the data should be captured at.

ALFormat sampleFormat

The requested capture buffer format.

Int32 bufferSize

The size of OpenAL's capture internal ring-buffer. This value expects number of samples, not bytes.

Properties

AvailableDevices

Returns a list of strings containing all known recording devices.

Declaration
public static IList<string> AvailableDevices { get; }
Property Value
Type Description
IList<String>

AvailableSamples

Returns the number of available samples for capture.

Declaration
public int AvailableSamples { get; }
Property Value
Type Description
Int32

CurrentDevice

The name of the device associated with this instance.

Declaration
public string CurrentDevice { get; }
Property Value
Type Description
String

CurrentError

Returns the ALC error code for this device.

Declaration
public AlcError CurrentError { get; }
Property Value
Type Description
AlcError

DefaultDevice

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

Declaration
public static string DefaultDevice { get; }
Property Value
Type Description
String

IsRunning

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

Declaration
public bool IsRunning { get; }
Property Value
Type Description
Boolean

SampleFormat

Gets the OpenTK.Audio.ALFormat for this instance.

Declaration
public ALFormat SampleFormat { get; }
Property Value
Type Description
ALFormat

SampleFrequency

Gets the sampling rate for this instance.

Declaration
public int SampleFrequency { get; }
Property Value
Type Description
Int32

Methods

CheckErrors()

Checks for ALC error conditions.

Declaration
public void CheckErrors()
Exceptions
Type Condition
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.

Dispose()

Closes the device and disposes the instance.

Declaration
public void Dispose()

Finalize()

Finalizes this instance.

Declaration
protected void Finalize()

ReadSamples(IntPtr, Int32)

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.

Declaration
public void ReadSamples(IntPtr buffer, int sampleCount)
Parameters
Type Name Description
IntPtr buffer

A pointer to a previously initialized and pinned array.

Int32 sampleCount

The number of samples to be written to the buffer.

ReadSamples<TBuffer>(TBuffer[], Int32)

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.

Declaration
public void ReadSamples<TBuffer>(TBuffer[] buffer, int sampleCount)
    where TBuffer : struct
Parameters
Type Name Description
TBuffer[] buffer

The buffer to fill.

Int32 sampleCount

The number of samples to be written to the buffer.

Type Parameters
Name Description
TBuffer
Exceptions
Type Condition
ArgumentNullException

Raised when buffer is null.

ArgumentOutOfRangeException

Raised when sampleCount is larger than the buffer.

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, Int32) method.

Declaration
public void Start()

Stop()

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

Declaration
public void Stop()

Implements

System.IDisposable
In This Article
Back to top Generated by DocFX