Getting Volume from a Recorded Sound Programmatically

Hello All,

So I’m trying to get the volume from a sound that I’ve recorded. Looking at the DSP descriptions, it seems like FMOD_DSP_TYPE_LOUDNESS_METER is the only one that will get me this information ( from the documentation: This unit analyzes the loudness and true peak of the signal). It has three parameters, where the the third one is of type DATA and has the loudness and true peak. So, we have the code:

void* data;
unsigned int len;
char s[256];
int stringlen = 256;

m_loudnessdsp->getParameterData( 2, &data, &len, s, stringlen );

The problem is that I have no idea what format the data in data is going to be, and can’t figure it out. I’ve tried printing s, but get the string “09?[?” which is not helpful in the slightest. The only other application that I can find for this method is with an FFT DSP, but that takes type FFT Data and so I’m not sure that would apply to this.

Does anyone know what format this data will come in? Or, does anyone have an easier way of getting the average volume of a recorded sound (abt .7 seconds long)? Most of the tutorials I’ve found are all from FMOD Ex, which isn’t helpful. I assumed that this way would be easier than dealing with the raw data because it was set up already, but if there’s an easy way to get the raw sound data, I’d be fine working with that as well.

Thanks!

The loudness meter isn’t usable from the public API at the moment. It’s designed to run and display it’s output in the studio tool. As you’ve discovered it’s data parameters are not in declared in any of our headers.

I would look at this question http://52.88.2.202/questions/question/microphone-input-playback for info on using DSP::getMeteringInfo.

Thanks so much! One more question about the link: It seems like the getMeteringInfo is not dependent on which DSP I use. Since I’m not actually trying to modify the sound, just get the volume for it, can I just arbitrarily pick a DSP type to add to the channel and then setMeteringEnabled for that DSP? Or are there any constraints on how setMeteringEnabled can be used for certain types of DSPs?

You don’t need to add a new DSP for metering. All channels and channel groups have a least one DSP that you can grab using Channel::getDSP(FMOD_CHANNELCONTROL_DSP_HEAD, &headDsp);