Click or drag to resize
Accord.NET (logo)

AudioCaptureDevice Class

Audio source for local audio capture device (i.e. a microphone).
Inheritance Hierarchy
SystemObject
  Accord.DirectSoundAudioCaptureDevice

Namespace:  Accord.DirectSound
Assembly:  Accord.Audio.DirectSound (in Accord.Audio.DirectSound.dll) Version: 3.7.0
Syntax
public class AudioCaptureDevice : IAudioSource, 
	IDisposable
Request Example View Source

The AudioCaptureDevice type exposes the following members.

Constructors
  NameDescription
Public methodAudioCaptureDevice
Initializes a new instance of the AudioCaptureDevice class.
Public methodAudioCaptureDevice(Guid)
Initializes a new instance of the AudioCaptureDevice class.
Public methodAudioCaptureDevice(AudioDeviceInfo)
Initializes a new instance of the AudioCaptureDevice class.
Public methodAudioCaptureDevice(Guid, String)
Initializes a new instance of the AudioCaptureDevice class.
Top
Properties
  NameDescription
Public propertyBytesReceived
Received bytes count.
Public propertyCanSeek
Gets whether this audio source supports seeking.
Public propertyChannels
Gets the number of audio channels captured by the device. Currently, only a single channel is supported.
Public propertyDesiredFrameSize
Gets or sets the desired frame size.
Public propertyFormat
Gets or sets the sample format used by the device.
Public propertyFramesReceived
Received frames count.
Public propertyIsRunning
State of the audio source.
Public propertySampleRate
Gets or sets the desired sample rate for this capturing device.
Public propertySource
Audio source.
Public propertyUserData
User data.
Top
Methods
  NameDescription
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Protected methodDispose(Boolean)
Releases unmanaged and - optionally - managed resources
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Releases unmanaged resources and performs other cleanup operations before the AudioCaptureDevice is reclaimed by garbage collection.
(Overrides ObjectFinalize.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnNewFrame
Notifies client about new block of frames.
Public methodSeek
This source does not support seeking.
Public methodSignalToStop
Signals audio source to stop its work.
Public methodStart
Start audio source.
Public methodStop
Stop audio source.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodWaitForStop
Wait for audio source has stopped.
Top
Events
  NameDescription
Public eventAudioSourceError
Audio source error event.
Public eventNewFrame
New frame event.
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodToT
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

This audio source captures audio data obtained from a local audio capture device such as the microphone. The audio is captured using DirectSound through SlimDX.

For instructions on how to list capture devices, please see the AudioDeviceCollection documentation page.

Examples

Sample usage:

// Create default capture device
AudioCaptureDevice source = new AudioCaptureDevice();

// Specify capturing options
source.DesiredFrameSize = 4096;
source.SampleRate = 22050;

// Specify the callback function which will be
// called once a sample is completely available
source.NewFrame += source_NewFrame;

// Start capturing
source.Start();

// ...

// The callback function should determine what
// should be done with the samples being caught
private void source_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
    // Read current frame...
    Signal s = eventArgs.Signal;

    // Process/play/record it
    // ...
}

For more details regarding usage, please check one of the Audio sample applications accompanying the framework.

See Also