[iOS] Simple way of getting output power?

Hello all,

I’m trying to figure out a simple way of getting overall output power / loudness from the FMOD system. Basically, value from 0.0 to 1.0, where 0.0 is nothing-at-all-super-quiet and 1.0 is THE LOUDEST.

I’ve got as far as poking at brett’s code samples in this thread, but it seems like getting a full FFT and then averaging the values out is a bit of a waste of CPU, going around the houses to get a simple value.

Is there a better way to get this? I’m open to pulling it out of iOS somewhere further along the chain from FMOD; FMOD outputs to an AudioUnit, right?

Perhaps something like this

// Get the master channel group
FMOD::ChannelGroup* master;
system->getMasterChannelGroup(&master);

// Get the DSP unit that is at the head of the DSP chain of the master channel group
FMOD::DSP* masterHead;
master->getDSP(FMOD_CHANNELCONTROL_DSP_HEAD, &masterHead);
// enable output metering
masterHead->setMeteringEnabled(false, true);

// Call this at regular intervals to fetch the output meter
FMOD_DSP_METERING_INFO outputmeter = {};
masterHead->getMeteringInfo(0, &outputmeter);

// stereo on iOS
assert(outputmeter.numchannels == 2);
printf("Power over the last %d samples: left = %f, right = %f \n", outputmeter.numsamples, outputmeter.rmslevel[0], outputmeter.rmslevel[1]);