This project has moved. For the latest updates, please go here.

How can I normalize my volume of my recorded wav file?

May 22 at 5:36 PM
I hope someone can help me, I have a recorded wav file which I did already sent through the SimpleCompressor class like that:
            WaveFileReader audio = new WaveFileReader(strFile);
            string strCompressedFile = "";

            byte[] WaveData = new byte[audio.Length];
            SimpleCompressorStream Compressor = new SimpleCompressorStream(audio);
            Compressor.Enabled = true;

            if (Compressor.Read(WaveData, 0, WaveData.Length) > 0)
                strCompressedFile = "xxx.wav";               
                WaveFileWriter CompressedWaveFile = new WaveFileWriter(strCompressedFile, audio.WaveFormat);
                CompressedWaveFile.Write(WaveData, 0, WaveData.Length);

Afterwards I need to do some normalization of the volume but I have no idea how to do that. Is there any function in naudio for that like the compressor class? If not what do I have to do?
May 24 at 7:04 PM
Simply loop through each sample and find the max sample. Finally loop through each sample again and multiply by (1/max sample).