Xeno-rat
|
ASIO Out Player. New implementation using an internal C# binding. More...
Public Member Functions | |
AsioOut () | |
Initializes a new instance of the AsioOut class with the first available ASIO Driver. | |
AsioOut (string driverName) | |
Initializes a new instance of the AsioOut class with the driver name. | |
AsioOut (int driverIndex) | |
Opens an ASIO output device. | |
void | Dispose () |
Releases the resources used by the driver and sets the driver to null. | |
bool | IsSampleRateSupported (int sampleRate) |
Checks if the specified sample rate is supported by the driver. | |
void | ShowControlPanel () |
Shows the control panel. | |
void | Play () |
Starts playing the media if it is not already playing. | |
void | Stop () |
Stops the playback and resets the playback state to Stopped. | |
void | Pause () |
Pauses the playback. | |
void | Init (IWaveProvider waveProvider) |
Initializes the recording and playback with the specified waveProvider . | |
void | InitRecordAndPlayback (IWaveProvider waveProvider, int recordChannels, int recordOnlySampleRate) |
Initializes the record and playback with the specified wave provider, record channels, and record only sample rate. | |
string | AsioInputChannelName (int channel) |
Returns the name of the input channel for the specified index. | |
string | AsioOutputChannelName (int channel) |
Returns the name of the output channel based on the provided channel number. | |
Static Public Member Functions | |
static string[] | GetDriverNames () |
Retrieves the names of the available ASIO drivers. | |
static bool | isSupported () |
Checks if the system supports the operation. | |
Properties | |
int | PlaybackLatency [get] |
Gets the latency (in ms) of the playback driver. | |
bool | AutoStop [get, set] |
Automatically stop when the end of the input stream is reached Disable this if auto-stop is causing hanging issues. | |
bool | HasReachedEnd [get, private set] |
A flag to let you know that we have reached the end of the input file Useful if AutoStop is set to false You can monitor this yourself and call Stop when it is true. | |
PlaybackState | PlaybackState [get] |
Playback State. | |
string | DriverName [get] |
Driver Name. | |
int | NumberOfOutputChannels [get, private set] |
The number of output channels we are currently using for playback (Must be less than or equal to DriverOutputChannelCount) | |
int | NumberOfInputChannels [get, private set] |
The number of input channels we are currently recording from (Must be less than or equal to DriverInputChannelCount) | |
int | DriverInputChannelCount [get] |
The maximum number of input channels this ASIO driver supports. | |
int | DriverOutputChannelCount [get] |
The maximum number of output channels this ASIO driver supports. | |
int | FramesPerBuffer [get] |
The number of samples per channel, per buffer. | |
int | ChannelOffset [get, set] |
By default the first channel on the input WaveProvider is sent to the first ASIO output. This option sends it to the specified channel number. Warning: make sure you don't set it higher than the number of available output channels - the number of source channels. n.b. Future NAudio may modify this. | |
int | InputChannelOffset [get, set] |
Input channel offset (used when recording), allowing you to choose to record from just one specific input rather than them all. | |
float | Volume [get, set] |
Sets the volume (1.0 is unity gain) Not supported for ASIO Out. Set the volume on the input stream instead. | |
WaveFormat | OutputWaveFormat [get, private set] |
The WaveFormat this device is using for playback. | |
Properties inherited from NAudio.Wave.IWavePlayer |
Events | |
EventHandler< StoppedEventArgs > | PlaybackStopped |
Playback Stopped. | |
EventHandler< AsioAudioAvailableEventArgs > | AudioAvailable |
When recording, fires whenever recorded audio is available. | |
EventHandler | DriverResetRequest |
Occurs when the driver settings are changed by the user, e.g. in the control panel. | |
Events inherited from NAudio.Wave.IWavePlayer | |
EventHandler< StoppedEventArgs > | PlaybackStopped |
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 | |
~AsioOut () | |
Releases unmanaged resources and performs other cleanup operations before the AsioOut is reclaimed by garbage collection. | |
void | InitFromName (string driverName) |
Initializes the object using the provided driver name and sets up the extended driver. | |
void | OnDriverResetRequest () |
Raises the DriverResetRequest event. | |
void | ReleaseDriver (AsioDriver driver) |
Releases the resources associated with the provided AsioDriver. | |
void | driver_BufferUpdate (IntPtr[] inputChannels, IntPtr[] outputChannels) |
Updates the buffer with input and output channels for audio processing. | |
void | RaisePlaybackStopped (Exception e) |
Raises the PlaybackStopped event with the specified exception. | |
Private Attributes | |
AsioDriverExt | driver |
IWaveProvider | sourceStream |
PlaybackState | playbackState |
int | nbSamples |
byte[] | waveBuffer |
AsioSampleConvertor.SampleConvertor | convertor |
string | driverName |
readonly SynchronizationContext | syncContext |
bool | isInitialized |
ASIO Out Player. New implementation using an internal C# binding.
This implementation is only supporting Short16Bit and Float32Bit formats and is optimized for 2 outputs channels . SampleRate is supported only if AsioDriver is supporting it
This implementation is probably the first AsioDriver binding fully implemented in C#!
Original Contributor: Mark Heath New Contributor to C# binding : Alexandre Mutel - email: alexandre_mutel at yahoo.fr
|
inline |
Initializes a new instance of the AsioOut class with the first available ASIO Driver.
|
inline |
Initializes a new instance of the AsioOut class with the driver name.
driverName | Name of the device. |
|
inline |
Opens an ASIO output device.
driverIndex | Device number (zero based) |
|
inlineprivate |
Releases unmanaged resources and performs other cleanup operations before the AsioOut is reclaimed by garbage collection.
|
inline |
Returns the name of the input channel for the specified index.
channel | The index of the input channel. |
|
inline |
Returns the name of the output channel based on the provided channel number.
channel | The channel number for which the name is to be retrieved. |
|
inline |
Releases the resources used by the driver and sets the driver to null.
This method checks if the driver is not null and if the playbackState is not PlaybackState.Stopped. If the conditions are met, it stops the driver and sets the driver to null after releasing the resources. The ResetRequestCallback of the driver is set to null.
|
inlineprivate |
Updates the buffer with input and output channels for audio processing.
inputChannels | An array of pointers to the input channels. |
outputChannels | An array of pointers to the output channels. |
This method updates the buffer with input and output channels for audio processing. It first checks if there are input channels available, and if so, raises the AudioAvailable event with the appropriate arguments. If the event handler writes to the output buffers, the method returns. If there are output channels available, it reads from the source stream into the wave buffer, calls the convertor to process the audio data, and handles end-of-data conditions.
|
inlinestatic |
Retrieves the names of the available ASIO drivers.
|
inline |
Initializes the recording and playback with the specified waveProvider .
waveProvider | The wave provider to be initialized. |
This method initializes the recording and playback using the specified waveProvider . The recording starts at position 0 and continues indefinitely until stopped.
Implements NAudio.Wave.IWavePlayer.
|
inlineprivate |
Initializes the object using the provided driver name and sets up the extended driver.
driverName | The name of the driver to be initialized. |
This method initializes the object with the specified driver name and sets up the extended driver by instantiating it using the basic driver obtained from AsioDriver.GetAsioDriverByName(string). If an exception occurs during the instantiation of the extended driver, the method releases the basic driver and rethrows the exception. The driver.ResetRequestCallback is set to OnDriverResetRequest. The ChannelOffset is set to 0.
|
inline |
Initializes the record and playback with the specified wave provider, record channels, and record only sample rate.
waveProvider | The wave provider to be initialized. |
recordChannels | The number of record channels. |
recordOnlySampleRate | The record only sample rate. |
InvalidOperationException | Thrown when attempting to initialize an already initialized instance of AsioOut. |
ArgumentException | Thrown when the sample rate is not supported. |
This method initializes the record and playback with the specified wave provider, record channels, and record only sample rate. It sets the desired sample rate based on the wave provider or the record only sample rate. If the wave provider is not null, it sets the source stream, number of output channels, and selects the correct sample convertor based on the ASIO format. It then sets the output wave format based on the ASIO sample type. If the wave provider is null, it sets the number of output channels to 0. It checks if the desired sample rate is supported and sets it if necessary. The method also plugs the callback, fills the buffer, sets the number of input channels, creates buffers, and sets the channel offset. Finally, it creates a buffer big enough to read from the source stream to fill the ASIO buffers if the wave provider is not null.
|
inline |
Checks if the specified sample rate is supported by the driver.
sampleRate | The sample rate to be checked. |
|
inlinestatic |
Checks if the system supports the operation.
|
inlineprivate |
Raises the DriverResetRequest event.
This method raises the DriverResetRequest event, indicating that a reset request has been made for the driver.
|
inline |
Pauses the playback.
This method changes the playback state to paused and stops the driver.
Implements NAudio.Wave.IWavePlayer.
|
inline |
Starts playing the media if it is not already playing.
This method checks the current playback state and starts playing the media if it is not already in the playing state. If the media is already playing, this method does nothing.
Implements NAudio.Wave.IWavePlayer.
|
inlineprivate |
Raises the PlaybackStopped event with the specified exception.
e | The exception that caused the playback to stop. |
ArgumentNullException | Thrown when the e is null. |
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.
|
inlineprivate |
Releases the resources associated with the provided AsioDriver.
driver | The AsioDriver to be released. |
This method disposes the buffers associated with the provided driver and releases the COM AsioDriver resources.
|
inline |
Shows the control panel.
This method calls the driver.ShowControlPanel method to display the control panel.
|
inline |
Stops the playback and resets the playback state to Stopped.
Implements NAudio.Wave.IWavePlayer.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
getset |
Automatically stop when the end of the input stream is reached Disable this if auto-stop is causing hanging issues.
|
getset |
By default the first channel on the input WaveProvider is sent to the first ASIO output. This option sends it to the specified channel number. Warning: make sure you don't set it higher than the number of available output channels - the number of source channels. n.b. Future NAudio may modify this.
|
get |
The maximum number of input channels this ASIO driver supports.
|
get |
Driver Name.
|
get |
The maximum number of output channels this ASIO driver supports.
|
get |
The number of samples per channel, per buffer.
|
getprivate set |
A flag to let you know that we have reached the end of the input file Useful if AutoStop is set to false You can monitor this yourself and call Stop when it is true.
|
getset |
Input channel offset (used when recording), allowing you to choose to record from just one specific input rather than them all.
|
getprivate set |
The number of input channels we are currently recording from (Must be less than or equal to DriverInputChannelCount)
|
getprivate set |
The number of output channels we are currently using for playback (Must be less than or equal to DriverOutputChannelCount)
|
getprivate set |
The WaveFormat this device is using for playback.
Implements NAudio.Wave.IWavePlayer.
|
get |
Gets the latency (in ms) of the playback driver.
|
get |
Playback State.
Implements NAudio.Wave.IWavePlayer.
|
getset |
Sets the volume (1.0 is unity gain) Not supported for ASIO Out. Set the volume on the input stream instead.
Implements NAudio.Wave.IWavePlayer.
EventHandler<AsioAudioAvailableEventArgs> NAudio.Wave.AsioOut.AudioAvailable |
When recording, fires whenever recorded audio is available.
EventHandler NAudio.Wave.AsioOut.DriverResetRequest |
Occurs when the driver settings are changed by the user, e.g. in the control panel.
EventHandler<StoppedEventArgs> NAudio.Wave.AsioOut.PlaybackStopped |
Playback Stopped.