I have an usb audio board that supports asio driver with 4 inputs and 4 outputs.
I want to send and receive data simultaneously.
But currently I can receive and send data only to one channels at a time. I cannot figure out how to set it in asioOut class from Naudio c# library.
It is possible to have one AudioAvailable event for each channel? Similar to waveIn / waveOut classes.
How can I achive this?
Here is my code:
int sampleRate = 44100;
int channels = 4;
buffWaveProvider = new BufferedWaveProvider(new NAudio.Wave.WaveFormat(sampleRate, 32, channels));
asioOut = new AsioOut(radioForm.driverName);
asioOut.ChannelOffset = OUTdevID;
asioOut.InputChannelOffset = INdevId;
asioOut.AudioAvailable += OnAsioOutAudioAvailable;
asioOut.InitRecordAndPlayback(buffWaveProvider, channels, sampleRate);
public void OnAsioOutAudioAvailable(object sender, AsioAudioAvailableEventArgs e)
if (speakersOn && e.InputBuffers.Length != 0 && !monitorRequest)
byte buf = new byte[e.SamplesPerBuffer*4];
for (int i = 0; i < e.InputBuffers.Length; i++)
Marshal.Copy(e.InputBuffers[i], buf, 0, e.SamplesPerBuffer*4);
e.WrittenToOutputBuffers = true;
if (Main.buffWaveProvider != null)
Main.buffWaveProvider.AddSamples(data, 0, dataLen);
Here's a simple example I created that is accessing both the input and output ASIO buffers and performing low-level manipulation of the samples.