How to record and playback with NAudio using AsioOut

前端 未结 1 775
花落未央
花落未央 2020-12-06 16:12

I\'m trying to get the sound input and send output directly with less latency possible with C#.

I\'m using the library NAud

相关标签:
1条回答
  • 2020-12-06 16:46

    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.

    0 讨论(0)
提交回复
热议问题