I've been looking for this for 2 days, and found a few command line tools to retrieve the level of an mp3, but nothing I can easily return a value from. I'm starting to think I need to invoke sox, have it write to a temp.txt, and then read the data back in.... but that's really ugly.
So here's the scenario, I have a few thousand mp3 files and I want to sort them, put ones that are at a lower RMS volume level in a different directory.
Dealing with mp3 files is generally more difficult than open formats or simpler formats like PCM WAV.
Since you're just doing some one-time file organization, calling into a command-line tool is probably fine. I might also suggest using something like Python for a task like this, or even some bash scripting.
That being said, there are C/C++ libraries you can use. One such library is mpg123, which is somewhat annoying to search for since it's also the name of the audio player built on top of it, but it should have the capability to read in an mp3 file and decode it to a waveform which you can then get the average/rms amplitude from.
Those are both excellent places to start! I'll look intompg123.h and.... I "think" ffmpeg might have something similar, I'm pretty sure it was ffmpeg I used years ago to get file length for an mp3 player I wrote that "mixed" tracks.