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

Recording using waveIn api with event callbacks. Use this for recording in non-gui applications Events are raised as recorded buffers are made available. More...

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

Public Member Functions

 WaveInEvent ()
 Prepares a Wave input device for recording.
 
void StartRecording ()
 Starts recording audio.
 
void StopRecording ()
 Stops the audio recording if it is currently in progress.
 
long GetPosition ()
 Retrieves the current input device position in bytes.
 
MixerLine GetMixerLine ()
 Retrieves 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 input buffers for capturing audio data.
 
void OpenWaveInDevice ()
 Opens the wave input device and creates necessary buffers.
 
void RecordThread ()
 Records the thread and raises the recording stopped event.
 
void DoRecording ()
 Initiates the audio recording process and handles buffer reusability and data availability events.
 
void RaiseRecordingStoppedEvent (Exception e)
 Raises the RecordingStopped event with the specified exception.
 
void CloseWaveInDevice ()
 Closes the wave input device and releases associated resources.
 

Private Attributes

readonly AutoResetEvent callbackEvent
 
readonly SynchronizationContext syncContext
 
IntPtr waveInHandle
 
volatile CaptureState captureState
 
WaveInBuffer[] buffers
 

Detailed Description

Recording using waveIn api with event callbacks. Use this for recording in non-gui applications Events are raised as recorded buffers are made available.

Constructor & Destructor Documentation

◆ WaveInEvent()

NAudio.Wave.WaveInEvent.WaveInEvent ( )
inline

Prepares a Wave input device for recording.

Member Function Documentation

◆ CloseWaveInDevice()

void NAudio.Wave.WaveInEvent.CloseWaveInDevice ( )
inlineprivate

Closes the wave input device and releases associated resources.

Some drivers may require a reset to properly release buffers. This method resets the wave input device using WaveInterop.waveInReset. It then disposes of any allocated buffers and closes the wave input device using WaveInterop.waveInClose.

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

◆ CreateBuffers()

void NAudio.Wave.WaveInEvent.CreateBuffers ( )
inlineprivate

Creates audio input buffers for capturing audio data.

This method creates audio input buffers for capturing audio data. It calculates the buffer size based on the specified BufferMilliseconds and WaveFormat. The method then initializes the buffers using the calculated size and the waveInHandle.

Here is the caller graph for this function:

◆ Dispose() [1/2]

void NAudio.Wave.WaveInEvent.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.WaveInEvent.Dispose ( bool disposing)
inlineprotectedvirtual

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

This method releases the unmanaged resources used by the object and optionally releases the managed resources.

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

◆ DoRecording()

void NAudio.Wave.WaveInEvent.DoRecording ( )
inlineprivate

Initiates the audio recording process and handles buffer reusability and data availability events.

This method sets the capture state to CaptureState.Capturing and reuses the buffers for capturing audio data. It continuously checks for data availability and invokes the DataAvailable event with the captured audio data if available. The method continues capturing audio until the capture state is changed.

Here is the caller graph for this function:

◆ GetCapabilities()

static WaveInCapabilities NAudio.Wave.WaveInEvent.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.

This method retrieves the capabilities of the audio input device specified by devNumber using the WaveInterop.waveInGetDevCaps method. It initializes a new instance of WaveInCapabilities and retrieves the device capabilities into it. The method then returns the retrieved capabilities.

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

◆ GetMixerLine()

MixerLine NAudio.Wave.WaveInEvent.GetMixerLine ( )
inline

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

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

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

◆ GetPosition()

long NAudio.Wave.WaveInEvent.GetPosition ( )
inline

Retrieves the current input device position in bytes.

Returns
The current position in bytes.
Exceptions
ExceptionThrown when the retrieved position type is not in bytes.
Here is the call graph for this function:

◆ OpenWaveInDevice()

void NAudio.Wave.WaveInEvent.OpenWaveInDevice ( )
inlineprivate

Opens the wave input device and creates necessary buffers.

This method closes any previously opened wave input device and then opens the specified wave input device using the provided wave format and callback event. It then creates necessary buffers for capturing audio data from the 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:

◆ RaiseRecordingStoppedEvent()

void NAudio.Wave.WaveInEvent.RaiseRecordingStoppedEvent ( Exception e)
inlineprivate

Raises the RecordingStopped event with the specified exception.

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

This method raises the RecordingStopped 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:

◆ RecordThread()

void NAudio.Wave.WaveInEvent.RecordThread ( )
inlineprivate

Records the thread and raises the recording stopped event.

This method executes the DoRecording method to perform the recording process. If any exception occurs during the recording, it is captured and stored in the exception variable. After the recording process is completed, the capture state is set to Stopped, and the RaiseRecordingStoppedEvent method is called to raise the recording stopped event, passing the captured exception as a parameter if it occurred.

Exceptions
ExceptionThrown if an error occurs during the recording process.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ StartRecording()

void NAudio.Wave.WaveInEvent.StartRecording ( )
inline

Starts recording audio.

Exceptions
InvalidOperationExceptionThrown when the recording is already in progress.

Implements NAudio.Wave.IWaveIn.

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

◆ StopRecording()

void NAudio.Wave.WaveInEvent.StopRecording ( )
inline

Stops the audio recording if it is currently in progress.

If the captureState is not CaptureState.Stopped, this method changes the captureState to CaptureState.Stopping, stops the audio recording using the WaveInterop.waveInStop method, resets the audio input device using the WaveInterop.waveInReset method, and signals the thread to exit by setting the callbackEvent.

Exceptions
MmExceptionThrown when an error occurs during the waveInStop or waveInReset operation.

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.WaveInEvent.buffers
private

◆ callbackEvent

readonly AutoResetEvent NAudio.Wave.WaveInEvent.callbackEvent
private

◆ captureState

volatile CaptureState NAudio.Wave.WaveInEvent.captureState
private

◆ syncContext

readonly SynchronizationContext NAudio.Wave.WaveInEvent.syncContext
private

◆ waveInHandle

IntPtr NAudio.Wave.WaveInEvent.waveInHandle
private

Property Documentation

◆ BufferMilliseconds

int NAudio.Wave.WaveInEvent.BufferMilliseconds
getset

Milliseconds for the buffer. Recommended value is 100ms.

◆ DeviceCount

int NAudio.Wave.WaveInEvent.DeviceCount
staticget

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

◆ DeviceNumber

int NAudio.Wave.WaveInEvent.DeviceNumber
getset

The device number to use.

◆ NumberOfBuffers

int NAudio.Wave.WaveInEvent.NumberOfBuffers
getset

Number of Buffers to use (usually 2 or 3)

◆ WaveFormat

WaveFormat NAudio.Wave.WaveInEvent.WaveFormat
getset

WaveFormat we are recording in.

Implements NAudio.Wave.IWaveIn.

Event Documentation

◆ DataAvailable

EventHandler<WaveInEventArgs> NAudio.Wave.WaveInEvent.DataAvailable

Indicates recorded data is available.

◆ RecordingStopped

EventHandler<StoppedEventArgs> NAudio.Wave.WaveInEvent.RecordingStopped

Indicates that all recorded data has now been received.


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