How to normalize mp3-files in C#

Who doesn’t know the following situation? You create a playlist with your favorite songs, looking forward to a leisurely afternoon on the couch and nevertheless the right mood won’t be there.
The first song roars at you, so you take your remote and turn down your music. The next song is so quiet, that it’s really hard to understand anything. So you turn you volume up again. And so on…

The magic word for this problem is normalization. Goal of normalization is that every song has the same maximum volume level. So you can still hear the difference between quiet and loud parts of a song, but the volume level of the songs to each other is adjusted.
Today I’ll show you how to write a program in C# which can normalize your music files.

What do you need?

private void mp3Normalization()
{
   OpenFileDialog ofd = new OpenFileDialog();
   ofd.Multiselect = true;
   if (ofd.ShowDialog() == DialogResult.OK)
   {
        foreach(string fname in ofd.FileNames)
        {
              Process pp = new Process();

              pp.StartInfo.FileName = Application.StartupPath + "\mp3gain.exe";
              pp.StartInfo.Arguments = "/r /d 20 /k /c "" + fname + """;
              pp.Start();
              pp.WaitForExit();
        }
        MessageBox.Show("All files successful normalized.");
   }
}

If you have any questions or tips, then send me just a comment.

Leave a comment

Please be polite. We appreciate that. Your email address will not be published and required fields are marked