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.
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.