Allows recording using the Windows waveIn APIs Events are raised as recorded buffers are made available.
More...
|
| 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.
|
|
|
virtual void | Dispose (bool disposing) |
| Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
|
Allows recording using the Windows waveIn APIs Events are raised as recorded buffers are made available.
◆ 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
-
windowHandle | A valid window handle |
◆ WaveIn() [3/3]
Prepares a Wave input device for recording.
◆ Callback()
Callback method for handling wave input messages.
- Parameters
-
waveInHandle | The handle to the input wave. |
message | The wave message received. |
userData | User data associated with the wave input. |
waveHeader | The wave header associated with the input. |
reserved | Reserved 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.
◆ 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.
◆ 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.
◆ Dispose() [1/2]
void NAudio.Wave.WaveIn.Dispose |
( |
| ) |
|
|
inline |
◆ 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.
◆ 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.
◆ GetCapabilities()
Retrieves the capabilities of the specified audio input device.
- Parameters
-
devNumber | The device number of the audio input device. |
- Returns
- The capabilities of the audio input device specified by devNumber .
- Exceptions
-
MmException | Thrown when an error occurs while retrieving the device capabilities. |
◆ 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
-
Exception | Thrown when the retrieved time type does not match the expected type. |
◆ 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
-
MmException | Thrown when an error occurs during the wave input device opening process. |
◆ RaiseDataAvailable()
void NAudio.Wave.WaveIn.RaiseDataAvailable |
( |
WaveInBuffer | buffer | ) |
|
|
inlineprivate |
Raises the DataAvailable event with the provided WaveInBuffer data.
- Parameters
-
buffer | The WaveInBuffer containing the recorded data. |
- Exceptions
-
ArgumentNullException | Thrown 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.
◆ RaiseRecordingStopped()
void NAudio.Wave.WaveIn.RaiseRecordingStopped |
( |
Exception | e | ) |
|
|
inlineprivate |
Raises the RecordingStopped event with the specified exception.
- Parameters
-
e | The exception that caused the recording to stop. |
- Exceptions
-
ArgumentNullException | Thrown 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.
◆ 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
-
InvalidOperationException | Thrown when the recording is already in progress. |
Implements NAudio.Wave.IWaveIn.
◆ StopRecording()
void NAudio.Wave.WaveIn.StopRecording |
( |
| ) |
|
|
inline |
Stops the recording if it is currently in progress.
- Exceptions
-
MmException | Thrown 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.
◆ buffers
◆ callback
◆ callbackInfo
◆ 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 |
◆ 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
◆ DataAvailable
Indicates recorded data is available.
◆ RecordingStopped
Indicates that all recorded data has now been received.
The documentation for this class was generated from the following file:
- /Users/sumansaurabh/Documents/my-startup/xeno-rat/Plugins/LiveMicrophone/lib/NAudio.WinForms/WaveIn.cs