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...
|
| 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.
|
|
|
virtual void | Dispose (bool disposing) |
| Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
|
|
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.
|
|
Recording using waveIn api with event callbacks. Use this for recording in non-gui applications Events are raised as recorded buffers are made available.
◆ WaveInEvent()
NAudio.Wave.WaveInEvent.WaveInEvent |
( |
| ) |
|
|
inline |
Prepares a Wave input device for recording.
◆ 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.
◆ 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.
◆ Dispose() [1/2]
void NAudio.Wave.WaveInEvent.Dispose |
( |
| ) |
|
|
inline |
◆ 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.
◆ 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.
◆ 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. |
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.
◆ 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
-
Exception | Thrown when the retrieved position type is not in bytes. |
◆ 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
-
MmException | Thrown when an error occurs during the wave input device opening process. |
◆ RaiseRecordingStoppedEvent()
void NAudio.Wave.WaveInEvent.RaiseRecordingStoppedEvent |
( |
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 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.
◆ 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
-
Exception | Thrown if an error occurs during the recording process. |
◆ StartRecording()
void NAudio.Wave.WaveInEvent.StartRecording |
( |
| ) |
|
|
inline |
Starts recording audio.
- Exceptions
-
InvalidOperationException | Thrown when the recording is already in progress. |
Implements NAudio.Wave.IWaveIn.
◆ 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
-
MmException | Thrown when an error occurs during the waveInStop or waveInReset operation. |
Implements NAudio.Wave.IWaveIn.
◆ buffers
◆ callbackEvent
readonly AutoResetEvent NAudio.Wave.WaveInEvent.callbackEvent |
|
private |
◆ captureState
◆ syncContext
readonly SynchronizationContext NAudio.Wave.WaveInEvent.syncContext |
|
private |
◆ waveInHandle
IntPtr NAudio.Wave.WaveInEvent.waveInHandle |
|
private |
◆ 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
◆ 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.WinMM/WaveInEvent.cs