Click or drag to resize
Accord.NET (logo)

WaveFileAudioSource Class

Read audio samples from a Wave file.
Inheritance Hierarchy
SystemObject
  Accord.DirectSoundWaveFileAudioSource

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

The WaveFileAudioSource type exposes the following members.

Constructors
  NameDescription
Public methodWaveFileAudioSource(Stream)
Constructs a new Wave file audio source.
Public methodWaveFileAudioSource(String)
Constructs a new Wave file audio source.
Top
Properties
  NameDescription
Public propertyBytesReceived
Gets the quantity of bytes received.
Public propertyCanSeek
Gets whether the current source supports seeking.
Public propertyChannels
Gets the number of audio channels in the wave file.
Public propertyDesiredFrameSize
Gets or sets the desired frame size to use when reading this source.
Public propertyFramesReceived
Gets the quantity of frames received.
Public propertyIsRunning
Gets whether this source is active or not.
Public propertySampleRate
Gets the sampling rate for this source.
Public propertySource
Gets or sets the file source path.
Public propertyUserData
Gets or sets a user-defined tag associated with this object.
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 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 methodSeek
Navigates to a given position within the source.
Public methodSignalToStop
Signals the source to stop.
Public methodStart
Starts reading from the source.
Public methodStop
Stops the source.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodWaitForStop
Blocks the calling thread until the source has stopped.
Top
Events
  NameDescription
Public eventAudioSourceError
Event raised when an error occurs in the audio source.
Public eventNewFrame
Event raised when a new frame has arrived.
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 MethodTo(Type)Overloaded.
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.)
Public Extension MethodToTOverloaded.
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 reads audio samples from Wave files. Internally, it uses the WaveDecoder class to automatically decode Wave files into audio signals.

Examples

Sample usage:

// Create the Wave file audio source
WaveFileAudioSource source = new WaveFileAudioSource("audiofile.wav");

// 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
    // ...
}
See Also