Question

I'm using NAudio to decode, play and record a MP3 Stream. For recording I use WasapiLoopbackCapture to save the stream to a wav file:

if (waveIn == null) {
  waveIn = new WasapiLoopbackCapture();
  writer = new WaveFileWriter(outputFilename, waveIn.WaveFormat);
  waveIn.DataAvailable += new EventHandler<WaveInEventArgs>(waveIn_DataAvailable);
  waveIn.RecordingStopped += new EventHandler(waveIn_RecordingStopped);
  waveIn.StartRecording();
}

I'm now searching for a solution to save the wav file not with 3072 kBit/s (what seems to be standard for the wasApi). The mp3 stream provides 128 kBit/s, so this would be a good bitrate for my wav file. I tried to modify the waveIn.WaveFormat but I didn't find the right properties.

Was it helpful?

Solution

Unfortunately WASAPI does not allow you to change the sample rate for loopback recording. You have to perform your own sample rate conversion yourself afterwards. The DmoResampler or WaveFormatConversionStream classes in NAudio can be used for this.

OTHER TIPS

I am not familiar with Naudio's abstractions on wasapi but you can force windows to give you the audio in a specific bitrate/samplesize using the wasapi C++ API. If that helps

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top