Jithu Johncena

Jithu Johncena

  • NA
  • 3
  • 4.9k

How to change .wav format file bit-rate

Nov 9 2016 7:42 AM
Hi all,
In my application i ahve some .wav format audio files,so here i want to change Bit rate, for that i am using below code
<pre lang="C#">int bitrate;
using (var reader = new WaveFileReader(textBox1.Text))
{
bitrate = reader.WaveFormat.AverageBytesPerSecond * 8;
reader.Dispose();
}
if (bitrate &gt; 128000)
{
using (var reader = new WaveFileReader(textBox1.Text))
{
var newFormat = new WaveFormat(8000, 16, 1);
using (var conversionStream = new WaveFormatConversionStream(newFormat, reader))
{
WaveFileWriter.CreateWaveFile(@"C:\Docs\Files\", conversionStream);
}
}
}</pre>
it is working for some files only, and some files get below error
<pre lang="C#">An unhandled exception of type 'NAudio.MmException' occurred in NAudio.dll
Additional information: AcmNotPossible calling acmStreamOpen</pre>
How can i solve the error ?
--Here i am using Naudio Dll

Answers (1)