Click or drag to resize
Accord.NET (logo)

AudioOutputDevice Class

Audio output device for local audio playback (i.e. a sound card port).
Inheritance Hierarchy

Namespace:  Accord.DirectSound
Assembly:  Accord.Audio.DirectSound (in Accord.Audio.DirectSound.dll) Version: 3.7.0
public class AudioOutputDevice : IAudioOutput, 
Request Example View Source

The AudioOutputDevice type exposes the following members.

Public methodAudioOutputDevice(IntPtr, Int32, Int32)
Constructs a new Audio Output Device.
Public methodAudioOutputDevice(Guid, IntPtr, Int32, Int32)
Constructs a new Audio Output Device.
Public propertyChannels
Gets the number of channels for the current output device.
Public propertyIsRunning
Gets a value indicating whether this instance is playing audio.
Public propertyOutput
Audio output.
Public propertyOwner
Gets the parent owner form for the device.
Public propertySamplingRate
Gets the sampling rate for the current output device.
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 WaveFileAudioSource 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.)
Public methodPlay
Starts playing the current buffer.
Public methodPlay(Single)
Starts playing the current buffer.
Public methodSignalToStop
Signals audio output to stop its work.
Public methodStop
Stops playing the current buffer.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodWaitForStop
Wait for audio output has stopped.
Public eventAudioOutputError
Audio output error event.
Public eventFramePlayingStarted
Raised when a frame starts playing.
Public eventNewFrameRequested
Raised when a frame starts playing.
Public eventStopped
Indicates all frames have been played and the audio finished.
Extension Methods
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.)

This audio output sends audio data to a local output device such as a sound card. The audio is reproduced using DirectSound through SlimDX.

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


Sample usage:

// To create an audio output device, DirectSound requires a handle to
// the parent form of the application (or other application handle). In
// Windows.Forms, this could be achieved by providing the Handle property
// of the currently displayed form.

int sampleRate = 22000; // 22kHz
int channels = 2;       // stereo

// Create the audio output device with the desired values
AudioOutputDevice output = new AudioOutputDevice(Handle, sampleRate, channels);

// The output device works at real time, and as such, forms a queue of audio
// samples to be played (more specifically, a buffer). When this buffer starts
// to get empty, the output will ask the application for more samples of it
// should stop playing. To ask for more samples, the output device will fire
// an event which should be handled by the user:

output.NewFrameRequested += output_NewFrameRequested;

// It is also possible to configure an event to be fired when the device
// has stopped playing and when it has just started playing a frame. Those
// are mainly used for reporting status to GUI controls.
output.Stopped += output_Stopped;
output.FramePlayingStarted += output_FramePlayingStarted;

// Start playing

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

See Also