When I change the waveFormat of a wav file the "data" identifier shifts to the right. The data identifier which represents the beginning of the da chunk has to be at the 0x24 position but after I change the waveFormat with the NAudio library it shiffts to the 0x26 position.
WAV format
This is the code I use to change the waveFormat:
private void TurnTo16bitsAudio(string path)
{
NAudio.Wave.WaveFileReader wave = new NAudio.Wave.WaveFileReader(@path);
System.Console.WriteLine(wave.WaveFormat);
if (wave.WaveFormat.BitsPerSample >= 16 && wave.WaveFormat.Channels<2)
{
wave.Dispose();
return;
}
var newFormat = new WaveFormat(44100, 16, 1);
var conversionStream = new WaveFormatConversionStream(newFormat, wave);
WaveFileWriter.CreateWaveFile(@path + '1', conversionStream);
wave.Dispose();
wave = new NAudio.Wave.WaveFileReader(@path + '1');
conversionStream = new WaveFormatConversionStream(newFormat, wave);
WaveFileWriter.CreateWaveFile(@path, conversionStream);
wave.Dispose();
conversionStream.Dispose();
System.IO.File.Delete(@path + '1');
}
There is any possibility to change the wav header with NAudio or to change the waveFormat without shiffting the "data" identifier