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.

2 Comments

  1. Annasays:

    Hello

    Thank you very much for this page. Right now I need to do the very same in an Android App which is written with Xamarin & C#. Is there a way I can use that there too or does it work only in Windows? I need to normalize some mp3 files and it would be great if I could check the mp3 for the max db value and if it’s under a spezified threshold then set it to a min. db value

Leave a comment

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