I am trying to change the format of a wav file in .Net from a 32 bit, 44100 samplerate, stereo wav file to a 16 bit, 44100 samplerate, stereo wav file.
The code Ive already tried with Naudio:
public static byte[] ChangeWavQuality(Stream filePath, int sampleRate, int bitDepth, int numOfChannels = 2)
{
WaveFormat w = new WaveFormat(sampleRate, bitDepth, numOfChannels);
WaveStream stream = new WaveFileReader(filePath);
WaveFormatConversionStream str = new WaveFormatConversionStream(w, stream);
byte[] buffer = new byte[str.Length];
str.Write(buffer, 0, buffer.Length);
return buffer;
}
But the error Im getting with this piece of code ive tried is that everytime I try to use this code I get an error returning:
An unhandled exception of type 'NAudio.MmException' occurred in NAudio.dll
Additional information: AcmNotPossible calling acmStreamOpen
Any others ways of changing the format of a wav file or a fix to the above problem in the code snippet?