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?
- The mp3gain.exe, which can be downloaded from my blog
- The following snippet of C#-code
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.
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
Hi Anna,
since this tutorial is based on an .exe-tool it can’t be run on Android. But what may help you, is the following. When I’m not wrong the mp3-gain-tool is based on the popular ffmpeg library. And this library is also available for ffmpeg.
So here is an article/post which describes how to normalize audio with ffmpeg:
https://superuser.com/questions/323119/how-can-i-normalize-audio-using-ffmpeg
And here is an article, which describes how to use ffmpeg on Android:
https://enoent.fr/blog/2014/06/20/compile-ffmpeg-for-android/
Kind regards,
Raffael