I\'m trying to get the sound input and send output directly with less latency possible with C#.
I\'m using the library NAud
You should not be using two instances of AsioOut
for the same device. I'm surprised this works at all. Just use the one, with InitRecordAndPlayback
.
For absolute minimal latency for pass-through monitoring, in AudioAvailableEvent
, copy directly to the OutputBuffers
, and set WrittenToOutputBuffers = true
. This means you don't need a BufferedWaveProvider
.
Also remember that any glitches are simply due to you not managing to process the AudioAvailable event quickly enough. When you're working with ASIO, you can be at very low latencies (e.g. sub 10ms), and can be dealing with lots of data (e.g. 96kHz sample rates, 8 channels of input and output). So you need to do a lot of moving of data in a short time window. With .NET, you have to factor in the unfortunate fact that the garbage collector could kick in at any time and cause you to miss a buffer from time to time.