Xeno-rat
Loading...
Searching...
No Matches
NAudio.Wave.WaveOut Class Reference

Represents a wave out device. More...

Inheritance diagram for NAudio.Wave.WaveOut:
Collaboration diagram for NAudio.Wave.WaveOut:

Public Member Functions

 WaveOut ()
 Creates a default WaveOut device Will use window callbacks if called from a GUI thread, otherwise function callbacks.
 
 WaveOut (IntPtr windowHandle)
 Creates a WaveOut device using the specified window handle for callbacks.
 
 WaveOut (WaveCallbackInfo callbackInfo)
 Opens a WaveOut device.
 
void Init (IWaveProvider waveProvider)
 Initializes the audio output with the specified wave provider.
 
void Play ()
 Plays the audio if the playback state is stopped, or resumes playing if the state is paused.
 
void Pause ()
 Pauses the playback if the current state is playing.
 
void Resume ()
 Resumes playback of the audio.
 
void Stop ()
 Stops the audio playback.
 
long GetPosition ()
 Gets the current position in bytes of the audio playback.
 
void Dispose ()
 Releases the unmanaged resources used by the WaveOut device and optionally releases the managed resources.
 

Static Public Member Functions

static WaveOutCapabilities GetCapabilities (int devNumber)
 Retrieves the capabilities of the specified audio output device.
 

Protected Member Functions

void Dispose (bool disposing)
 Closes the WaveOut device and disposes of buffers.
 

Properties

static Int32 DeviceCount [get]
 Returns the number of Wave Out devices available in the system.
 
int DesiredLatency [get, set]
 Gets or sets the desired latency in milliseconds Should be set before a call to Init.
 
int NumberOfBuffers [get, set]
 Gets or sets the number of buffers used Should be set before a call to Init.
 
int DeviceNumber = -1 [get, set]
 Gets or sets the device number Should be set before a call to Init This must be between -1 and DeviceCount- 1. -1 means stick to default device even default device is changed.
 
WaveFormat OutputWaveFormat [get]
 Gets a Wave.WaveFormat instance indicating the format the hardware is using.
 
PlaybackState PlaybackState [get]
 Playback State.
 
float Volume [get, set]
 Volume for this device 1.0 is full scale.
 
- Properties inherited from NAudio.Wave.IWavePlayer
- Properties inherited from NAudio.Wave.IWavePosition

Events

EventHandler< StoppedEventArgsPlaybackStopped
 Indicates playback has stopped automatically.
 
- Events inherited from NAudio.Wave.IWavePlayer
EventHandler< StoppedEventArgsPlaybackStopped
 Indicates that playback has gone into a stopped state due to reaching the end of the input stream or an error has been encountered during playback.
 

Private Member Functions

void EnqueueBuffers ()
 Enqueues the available buffers for playback.
 
 ~WaveOut ()
 Finalizer. Only called when user forgets to call Dispose
 
void Callback (IntPtr hWaveOut, WaveInterop.WaveMessage uMsg, IntPtr dwInstance, WaveHeader wavhdr, IntPtr dwReserved)
 Callback method for the wave out function.
 
void RaisePlaybackStoppedEvent (Exception e)
 Raises the PlaybackStopped event with the specified exception.
 

Private Attributes

IntPtr hWaveOut
 
WaveOutBuffer[] buffers
 
IWaveProvider waveStream
 
volatile PlaybackState playbackState
 
readonly WaveInterop.WaveCallback callback
 
readonly WaveCallbackInfo callbackInfo
 
readonly object waveOutLock
 
int queuedBuffers
 
readonly SynchronizationContext syncContext
 

Detailed Description

Represents a wave out device.

Constructor & Destructor Documentation

◆ WaveOut() [1/3]

NAudio.Wave.WaveOut.WaveOut ( )
inline

Creates a default WaveOut device Will use window callbacks if called from a GUI thread, otherwise function callbacks.

◆ WaveOut() [2/3]

NAudio.Wave.WaveOut.WaveOut ( IntPtr windowHandle)
inline

Creates a WaveOut device using the specified window handle for callbacks.

Parameters
windowHandleA valid window handle

◆ WaveOut() [3/3]

NAudio.Wave.WaveOut.WaveOut ( WaveCallbackInfo callbackInfo)
inline

Opens a WaveOut device.

Here is the call graph for this function:

◆ ~WaveOut()

NAudio.Wave.WaveOut.~WaveOut ( )
inlineprivate

Finalizer. Only called when user forgets to call Dispose

Here is the call graph for this function:

Member Function Documentation

◆ Callback()

void NAudio.Wave.WaveOut.Callback ( IntPtr hWaveOut,
WaveInterop::WaveMessage uMsg,
IntPtr dwInstance,
WaveHeader wavhdr,
IntPtr dwReserved )
inlineprivate

Callback method for the wave out function.

Parameters
hWaveOutHandle to the waveform-audio output device associated with the callback.
uMsgThe message sent to the callback function.
dwInstanceUser instance data specified with waveOutOpen.
wavhdrPointer to a WaveHeader structure that identifies the header of the completed waveform-audio data block.
dwReservedNot used.

This method is called when a waveform-audio output buffer is done. It checks if the playback state is playing and then processes the buffer. If an exception occurs during processing, it is caught and stored in the 'exception' variable. After processing, it checks if all buffers have been played and raises the playback stopped event if so.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dispose() [1/2]

void NAudio.Wave.WaveOut.Dispose ( )
inline

Releases the unmanaged resources used by the WaveOut device and optionally releases the managed resources.

Parameters
disposingtrue to release both managed and unmanaged resources; false to release only unmanaged resources.

This method stops the playback of audio using the WaveOut device and releases the unmanaged resources associated with it. If disposing is true, it also releases the managed resources, such as audio buffers.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dispose() [2/2]

void NAudio.Wave.WaveOut.Dispose ( bool disposing)
inlineprotected

Closes the WaveOut device and disposes of buffers.

Parameters
disposingTrue if called from Dispose
Here is the call graph for this function:

◆ EnqueueBuffers()

void NAudio.Wave.WaveOut.EnqueueBuffers ( )
inlineprivate

Enqueues the available buffers for playback.

This method iterates through the available buffers and enqueues them for playback if they are not already in the queue. If a buffer is successfully enqueued, the count of queued buffers is incremented. If a buffer's 'OnDone' method returns false, the playback state is set to 'Stopped' and the iteration is terminated.

Here is the caller graph for this function:

◆ GetCapabilities()

static WaveOutCapabilities NAudio.Wave.WaveOut.GetCapabilities ( int devNumber)
inlinestatic

Retrieves the capabilities of the specified audio output device.

Parameters
devNumberThe device number for which to retrieve the capabilities.
Returns
The capabilities of the audio output device specified by devNumber .
Exceptions
MmExceptionThrown when an error occurs while retrieving the device capabilities.

This method retrieves the capabilities of the specified audio output device using the WaveOut API. It initializes a new instance of WaveOutCapabilities and populates it with the capabilities of the specified device. The method then returns the retrieved capabilities.

Here is the call graph for this function:

◆ GetPosition()

long NAudio.Wave.WaveOut.GetPosition ( )

Gets the current position in bytes of the audio playback.

Returns
The current position in bytes of the audio playback.

Implements NAudio.Wave.IWavePosition.

◆ Init()

void NAudio.Wave.WaveOut.Init ( IWaveProvider waveProvider)
inline

Initializes the audio output with the specified wave provider.

Parameters
waveProviderThe wave provider to be used for audio output.
Exceptions
MmExceptionThrown when an error occurs during the initialization process.

This method initializes the audio output with the provided wave provider and sets up the necessary buffers for playback. It calculates the buffer size based on the desired latency and number of buffers, and then opens the wave output device. After successful initialization, the audio output is ready for playback.

Implements NAudio.Wave.IWavePlayer.

Here is the call graph for this function:

◆ Pause()

void NAudio.Wave.WaveOut.Pause ( )
inline

Pauses the playback if the current state is playing.

Exceptions
MmExceptionThrown when an error occurs during the pause operation.

Implements NAudio.Wave.IWavePlayer.

Here is the call graph for this function:

◆ Play()

void NAudio.Wave.WaveOut.Play ( )
inline

Plays the audio if the playback state is stopped, or resumes playing if the state is paused.

If the playbackState is PlaybackState.Stopped, this method changes the state to PlaybackState.Playing and enqueues any available buffers for playback. If the playbackState is PlaybackState.Paused, this method enqueues any available buffers for playback, resumes playback, and changes the state to PlaybackState.Playing.

Implements NAudio.Wave.IWavePlayer.

Here is the call graph for this function:

◆ RaisePlaybackStoppedEvent()

void NAudio.Wave.WaveOut.RaisePlaybackStoppedEvent ( Exception e)
inlineprivate

Raises the PlaybackStopped event with the specified exception.

Parameters
eThe exception that caused the playback to stop.

This method raises the PlaybackStopped event with the specified exception. If a synchronization context is available, the event is raised on the synchronization context; otherwise, it is raised on the current thread.

Here is the caller graph for this function:

◆ Resume()

void NAudio.Wave.WaveOut.Resume ( )
inline

Resumes playback of the audio.

If the playback state is paused, this method resumes the audio playback using the waveOutRestart function from the WaveInterop class. If an error occurs during the resumption of playback, a MmException is thrown with the corresponding error message.

Exceptions
MmExceptionThrown when an error occurs during the resumption of audio playback.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Stop()

void NAudio.Wave.WaveOut.Stop ( )
inline

Stops the audio playback.

Exceptions
MmExceptionThrown when an error occurs during the audio playback stop operation.

If the current playback state is not already stopped, this method resets the audio output device and stops the playback. This method also raises the PlaybackStopped event if the audio playback was stopped successfully.

Implements NAudio.Wave.IWavePlayer.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ buffers

WaveOutBuffer [] NAudio.Wave.WaveOut.buffers
private

◆ callback

readonly WaveInterop.WaveCallback NAudio.Wave.WaveOut.callback
private

◆ callbackInfo

readonly WaveCallbackInfo NAudio.Wave.WaveOut.callbackInfo
private

◆ hWaveOut

IntPtr NAudio.Wave.WaveOut.hWaveOut
private

◆ playbackState

volatile PlaybackState NAudio.Wave.WaveOut.playbackState
private

◆ queuedBuffers

int NAudio.Wave.WaveOut.queuedBuffers
private

◆ syncContext

readonly SynchronizationContext NAudio.Wave.WaveOut.syncContext
private

◆ waveOutLock

readonly object NAudio.Wave.WaveOut.waveOutLock
private

◆ waveStream

IWaveProvider NAudio.Wave.WaveOut.waveStream
private

Property Documentation

◆ DesiredLatency

int NAudio.Wave.WaveOut.DesiredLatency
getset

Gets or sets the desired latency in milliseconds Should be set before a call to Init.

◆ DeviceCount

Int32 NAudio.Wave.WaveOut.DeviceCount
staticget

Returns the number of Wave Out devices available in the system.

◆ DeviceNumber

int NAudio.Wave.WaveOut.DeviceNumber = -1
getset

Gets or sets the device number Should be set before a call to Init This must be between -1 and DeviceCount- 1. -1 means stick to default device even default device is changed.

◆ NumberOfBuffers

int NAudio.Wave.WaveOut.NumberOfBuffers
getset

Gets or sets the number of buffers used Should be set before a call to Init.

◆ OutputWaveFormat

WaveFormat NAudio.Wave.WaveOut.OutputWaveFormat
get

Gets a Wave.WaveFormat instance indicating the format the hardware is using.

Implements NAudio.Wave.IWavePlayer.

◆ PlaybackState

PlaybackState NAudio.Wave.WaveOut.PlaybackState
get

Playback State.

Implements NAudio.Wave.IWavePlayer.

◆ Volume

float NAudio.Wave.WaveOut.Volume
getset

Volume for this device 1.0 is full scale.

Implements NAudio.Wave.IWavePlayer.

Event Documentation

◆ PlaybackStopped

EventHandler<StoppedEventArgs> NAudio.Wave.WaveOut.PlaybackStopped

Indicates playback has stopped automatically.


The documentation for this class was generated from the following file: