This project has moved and is read-only. For the latest updates, please go here.

combining ASIO.NET and NAudio

Aug 27, 2011 at 4:22 PM
Edited Aug 27, 2011 at 4:24 PM


as mentioned serveral times in the NAudio Discussions, the ASIO support in NAudio is still very "basic" at the moment and it does not provide ASIO Input. But there is this ASIO.NET  library on Because I like the Naudio model with its WaveStreams, Converters etc., I don't want to do without NAudio and think of a way to combine ASIO.NET with NAudio.  In NAudio the buffer filling in class NAudio.Wave.AsioOut happens here:


void driver_BufferUpdate(IntPtr[] bufferChannels)
 int read = sourceStream.Read(waveBuffer,0,waveBuffer.Length);


So when using the ASIO.NET lib one could do the buffer filling in the ASIO.NET callback (copy float samples from NAudio wavestreams/waveproviders into the ASIO.NET buffer):


/// <summary>
///ASIO.NET event handler: Called when a buffer update is required
/// </summary>
private static void AsioDriver_BufferUpdate(object sender, EventArgs e)
  AsioDriver driver = sender as AsioDriver;

// get the input channel and the stereo output channels
Channel input = driver.InputChannels[0];
Channel leftOutput = driver.OutputChannels[0];
Channel rightOutput = driver.OutputChannels[1];

// sourceStream is IWaveProvider from NAudio,(simplified: leftOutput is probably incompatible as first arg for Read)
 int read = sourceStream.Read(leftOutput,0,leftOutput.Length);

Would it make sense to do so or will there probably be still too much overhead when combining with ASIO.NET to get low latencies ?



Sep 6, 2011 at 10:38 AM

You will never get really low latencies with .NET, but you should be able to do this if you want to use ASIO.NET. It wouldn't take too much effort to update NAudio to support ASIO recording if you want to try that, and may be easier. I don't have the time to work on it at the moment, but it is something I want to do for a future NAudio.