Class WaveOut
WaveOut playback device using event callbacks
public class WaveOut : IWavePlayer, IDisposable, IWavePosition, IWaveLatency
- Inheritance
-
WaveOut
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
WaveOut()
Creates a new WaveOut device
public WaveOut()
Properties
AverageLatency
The steady-state latency from a sample being queued for output to it being emitted by the audio hardware, assuming uninterrupted playback. This is a property of the buffer configuration and the driver, not of the current playback state.
public TimeSpan AverageLatency { get; }
Property Value
Remarks
Computed from the buffer configuration as (NumberOfBuffers - 0.5) * BufferMilliseconds:
in steady state every queued buffer plus half of the one currently playing sits between
the application and the speaker.
BufferMilliseconds
Milliseconds for each buffer. Recommended value is 100ms. Should be set before a call to Init
public int BufferMilliseconds { get; set; }
Property Value
CurrentLatency
The time that has elapsed since the sample currently emerging from the hardware was queued for output. In steady state this is approximately equal to AverageLatency; it differs during start-up, after an underrun, or when the host is filling buffers irregularly. Implementations that cannot meaningfully distinguish from the average are permitted to return AverageLatency.
public TimeSpan CurrentLatency { get; }
Property Value
Remarks
Returns the elapsed time since the oldest in-queue buffer was filled — that is the buffer the hardware is currently draining. Falls back to AverageLatency when no buffer timestamps are available (e.g. immediately after Init(IWaveProvider)).
DeviceCount
Returns the number of Wave Out devices available in the system
public static int DeviceCount { get; }
Property Value
DeviceNumber
Gets or sets the device number
Should be set before a call to Init
This must be between -1 and
public int DeviceNumber { get; set; }
Property Value
NumberOfBuffers
Gets or sets the number of buffers used Should be set before a call to Init
public int NumberOfBuffers { get; set; }
Property Value
OutputWaveFormat
Gets a WaveFormat instance indicating the format the hardware is using.
public WaveFormat OutputWaveFormat { get; }
Property Value
PlaybackState
Playback State
public PlaybackState PlaybackState { get; }
Property Value
Volume
Volume for this device 1.0 is full scale
public float Volume { get; set; }
Property Value
Methods
Dispose()
Closes this WaveOut device
public void Dispose()
Dispose(bool)
Closes the WaveOut device and disposes of buffers
protected void Dispose(bool disposing)
Parameters
disposingboolTrue if called from
Dispose
~WaveOut()
Finalizer. Only called when user forgets to call
protected ~WaveOut()
GetCapabilities(int)
Retrieves the capabilities of a waveOut device
public static WaveOutCapabilities GetCapabilities(int devNumber)
Parameters
devNumberintDevice to test
Returns
- WaveOutCapabilities
The WaveOut device capabilities
GetPosition()
Gets the current position in bytes from the wave output device. (n.b. this is not the same thing as the position within your reader stream - it calls directly into waveOutGetPosition)
public long GetPosition()
Returns
- long
Position in bytes
Init(IWaveProvider)
Initialises the WaveOut device
public void Init(IWaveProvider waveProvider)
Parameters
waveProviderIWaveProviderThe wave provider to play
Pause()
Pause the audio
public void Pause()
Play()
Start playing the audio from the WaveStream
public void Play()
Stop()
Stop and reset the WaveOut device
public void Stop()
Events
PlaybackStopped
Indicates playback has stopped automatically
public event EventHandler<StoppedEventArgs> PlaybackStopped