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

Allows recording using the Windows waveIn APIs Events are raised as recorded buffers are made available. More...

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

Public Member Functions

 WaveIn ()
 Prepares a Wave input device for recording.
 
 WaveIn (IntPtr windowHandle)
 Creates a WaveIn device using the specified window handle for callbacks.
 
 WaveIn (WaveCallbackInfo callbackInfo)
 Prepares a Wave input device for recording.
 
void StartRecording ()
 Starts the audio recording process.
 
void StopRecording ()
 Stops the recording if it is currently in progress.
 
long GetPosition ()
 Retrieves the current input position of the audio device in bytes.
 
MixerLine GetMixerLine ()
 Gets the mixer line associated with the current wave input handle or device number.
 
void Dispose ()
 Dispose method.
 

Static Public Member Functions

static WaveInCapabilities GetCapabilities (int devNumber)
 Retrieves the capabilities of the specified audio input device.
 

Protected Member Functions

virtual void Dispose (bool disposing)
 Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 

Properties

static int DeviceCount [get]
 Returns the number of Wave In devices available in the system.
 
int BufferMilliseconds [get, set]
 Milliseconds for the buffer. Recommended value is 100ms.
 
int NumberOfBuffers [get, set]
 Number of Buffers to use (usually 2 or 3)
 
int DeviceNumber [get, set]
 The device number to use.
 
WaveFormat WaveFormat [get, set]
 WaveFormat we are recording in.
 
- Properties inherited from NAudio.Wave.IWaveIn

Events

EventHandler< WaveInEventArgsDataAvailable
 Indicates recorded data is available.
 
EventHandler< StoppedEventArgsRecordingStopped
 Indicates that all recorded data has now been received.
 
- Events inherited from NAudio.Wave.IWaveIn
EventHandler< WaveInEventArgsDataAvailable
 Indicates recorded data is available.
 
EventHandler< StoppedEventArgsRecordingStopped
 Indicates that all recorded data has now been received.
 

Private Member Functions

void CreateBuffers ()
 Creates audio buffers for capturing audio data.
 
void Callback (IntPtr waveInHandle, WaveInterop.WaveMessage message, IntPtr userData, WaveHeader waveHeader, IntPtr reserved)
 Callback method for handling wave input messages.
 
void RaiseDataAvailable (WaveInBuffer buffer)
 Raises the DataAvailable event with the provided WaveInBuffer data.
 
void RaiseRecordingStopped (Exception e)
 Raises the RecordingStopped event with the specified exception.
 
void OpenWaveInDevice ()
 Opens the wave input device and creates necessary buffers.
 
void EnqueueBuffers ()
 Enqueues the reusable buffers.
 
void CloseWaveInDevice ()
 Closes the wave input device and releases associated resources.
 

Private Attributes

IntPtr waveInHandle
 
volatile bool recording
 
WaveInBuffer[] buffers
 
readonly WaveInterop.WaveCallback callback
 
WaveCallbackInfo callbackInfo
 
readonly SynchronizationContext syncContext
 
int lastReturnedBufferIndex
 

Detailed Description

Allows recording using the Windows waveIn APIs Events are raised as recorded buffers are made available.

Constructor & Destructor Documentation

◆ WaveIn() [1/3]

NAudio.Wave.WaveIn.WaveIn ( )
inline

Prepares a Wave input device for recording.

◆ WaveIn() [2/3]

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

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

Parameters
windowHandleA valid window handle

◆ WaveIn() [3/3]

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

Prepares a Wave input device for recording.

Here is the call graph for this function:

Member Function Documentation

◆ Callback()

void NAudio.Wave.WaveIn.Callback ( IntPtr waveInHandle,
WaveInterop::WaveMessage message,
IntPtr userData,
WaveHeader waveHeader,
IntPtr reserved )
inlineprivate

Callback method for handling wave input messages.

Parameters
waveInHandleThe handle to the input wave.
messageThe wave message received.
userDataUser data associated with the wave input.
waveHeaderThe wave header associated with the input.
reservedReserved parameter.

This method is called when a wave input message is received. If the message is WaveInData and recording is in progress, it processes the wave input buffer and raises the DataAvailable event. If an exception occurs while reusing the buffer, the recording is stopped and the RecordingStopped event is raised with the exception details.

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

◆ CloseWaveInDevice()

void NAudio.Wave.WaveIn.CloseWaveInDevice ( )
inlineprivate

Closes the wave input device and releases associated resources.

This method first checks if the waveInHandle is not equal to IntPtr.Zero, and if so, it returns without performing any further actions. If the waveInHandle is not zero, it resets the wave input device using WaveInterop.waveInReset(IntPtr) to properly release buffers. It then disposes of each buffer in the buffers array, if it is not null, and sets the array to null. Finally, it closes the wave input device using WaveInterop.waveInClose(IntPtr) and sets the waveInHandle to IntPtr.Zero.

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

◆ CreateBuffers()

void NAudio.Wave.WaveIn.CreateBuffers ( )
inlineprivate

Creates audio buffers for capturing audio data.

This method creates audio buffers for capturing audio data. It calculates the buffer size based on the specified BufferMilliseconds and WaveFormat. The method then creates an array of WaveInBuffer objects and initializes each buffer with the calculated size.

Here is the caller graph for this function:

◆ Dispose() [1/2]

void NAudio.Wave.WaveIn.Dispose ( )
inline

Dispose method.

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

◆ Dispose() [2/2]

virtual void NAudio.Wave.WaveIn.Dispose ( bool disposing)
inlineprotectedvirtual

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

This method disposes the resources used by the current instance. It is called by the public Dispose() method and the GC.SuppressFinalize(object) method.

Here is the call graph for this function:

◆ EnqueueBuffers()

void NAudio.Wave.WaveIn.EnqueueBuffers ( )
inlineprivate

Enqueues the reusable buffers.

This method iterates through the list of buffers and enqueues the ones that are not already in the queue by calling their Buffer.Reuse method.

Here is the caller graph for this function:

◆ GetCapabilities()

static WaveInCapabilities NAudio.Wave.WaveIn.GetCapabilities ( int devNumber)
inlinestatic

Retrieves the capabilities of the specified audio input device.

Parameters
devNumberThe device number of the audio input device.
Returns
The capabilities of the audio input device specified by devNumber .
Exceptions
MmExceptionThrown when an error occurs while retrieving the device capabilities.
Here is the call graph for this function:

◆ GetMixerLine()

MixerLine NAudio.Wave.WaveIn.GetMixerLine ( )
inline

Gets the mixer line associated with the current wave input handle or device number.

Returns
The MixerLine object representing the mixer line associated with the current wave input handle or device number.

This method retrieves the mixer line associated with the current wave input handle or device number. If the wave input handle is not IntPtr.Zero, it creates a new MixerLine object using the wave input handle and MixerFlags.WaveInHandle. If the wave input handle is IntPtr.Zero, it creates a new MixerLine object using the device number and MixerFlags.WaveIn.

◆ GetPosition()

long NAudio.Wave.WaveIn.GetPosition ( )
inline

Retrieves the current input position of the audio device in bytes.

Returns
The current input position of the audio device in bytes.
Exceptions
ExceptionThrown when the retrieved time type does not match the expected type.
Here is the call graph for this function:

◆ OpenWaveInDevice()

void NAudio.Wave.WaveIn.OpenWaveInDevice ( )
inlineprivate

Opens the wave input device and creates necessary buffers.

This method closes any previously opened wave input device, then attempts to open the specified wave input device using the provided DeviceNumber and WaveFormat . If successful, it creates necessary buffers for the opened wave input device.

Exceptions
MmExceptionThrown when an error occurs during the wave input device opening process.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RaiseDataAvailable()

void NAudio.Wave.WaveIn.RaiseDataAvailable ( WaveInBuffer buffer)
inlineprivate

Raises the DataAvailable event with the provided WaveInBuffer data.

Parameters
bufferThe WaveInBuffer containing the recorded data.
Exceptions
ArgumentNullExceptionThrown when the provided buffer is null.

This method raises the DataAvailable event with the recorded data from the WaveInBuffer. The WaveInEventArgs object contains the recorded data and the number of bytes recorded.

Here is the caller graph for this function:

◆ RaiseRecordingStopped()

void NAudio.Wave.WaveIn.RaiseRecordingStopped ( Exception e)
inlineprivate

Raises the RecordingStopped event with the specified exception.

Parameters
eThe exception that caused the recording to stop.
Exceptions
ArgumentNullExceptionThrown when the exception e is null.

This method raises the RecordingStopped event with the specified exception e . 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:

◆ StartRecording()

void NAudio.Wave.WaveIn.StartRecording ( )
inline

Starts the audio recording process.

This method starts the audio recording process by opening the wave input device, enqueueing buffers, and invoking the waveInStart function from the WaveInterop class. If the recording is already in progress, an InvalidOperationException with the message "Already recording" is thrown.

Exceptions
InvalidOperationExceptionThrown when the recording is already in progress.

Implements NAudio.Wave.IWaveIn.

Here is the call graph for this function:

◆ StopRecording()

void NAudio.Wave.WaveIn.StopRecording ( )
inline

Stops the recording if it is currently in progress.

Exceptions
MmExceptionThrown when an error occurs while stopping the recording.

If the recording is currently in progress, this method stops the recording and reports any remaining buffers in the correct order. It then raises the DataAvailable event for each completed buffer and the RecordingStopped event to indicate that the recording has stopped. If no recording is in progress, this method does nothing.

Implements NAudio.Wave.IWaveIn.

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

Member Data Documentation

◆ buffers

WaveInBuffer [] NAudio.Wave.WaveIn.buffers
private

◆ callback

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

◆ callbackInfo

WaveCallbackInfo NAudio.Wave.WaveIn.callbackInfo
private

◆ lastReturnedBufferIndex

int NAudio.Wave.WaveIn.lastReturnedBufferIndex
private

◆ recording

volatile bool NAudio.Wave.WaveIn.recording
private

◆ syncContext

readonly SynchronizationContext NAudio.Wave.WaveIn.syncContext
private

◆ waveInHandle

IntPtr NAudio.Wave.WaveIn.waveInHandle
private

Property Documentation

◆ BufferMilliseconds

int NAudio.Wave.WaveIn.BufferMilliseconds
getset

Milliseconds for the buffer. Recommended value is 100ms.

◆ DeviceCount

int NAudio.Wave.WaveIn.DeviceCount
staticget

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

◆ DeviceNumber

int NAudio.Wave.WaveIn.DeviceNumber
getset

The device number to use.

◆ NumberOfBuffers

int NAudio.Wave.WaveIn.NumberOfBuffers
getset

Number of Buffers to use (usually 2 or 3)

◆ WaveFormat

WaveFormat NAudio.Wave.WaveIn.WaveFormat
getset

WaveFormat we are recording in.

Implements NAudio.Wave.IWaveIn.

Event Documentation

◆ DataAvailable

EventHandler<WaveInEventArgs> NAudio.Wave.WaveIn.DataAvailable

Indicates recorded data is available.

◆ RecordingStopped

EventHandler<StoppedEventArgs> NAudio.Wave.WaveIn.RecordingStopped

Indicates that all recorded data has now been received.


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