AudioDeviceManager::LevelMeter issue

Hi,
I was investigating the LevelMeter struct and the getLevelGetters associated and I found out that in the AudioDeviceManager::audioDeviceCallBackInt function which is in charge of calling the sucessive callbacks registered in the AudioDeviceManager calls in the beggining both the LeverInputGetter function and the output version. Shouldn’t the outuput version go to the end? At the begining the function reports 0 level as it expected.

void AudioDeviceManager::audioDeviceIOCallbackInt (const float** inputChannelData,
int numInputChannels,
float** outputChannelData,
int numOutputChannels,
int numSamples)
{
const ScopedLock sl (audioCallbackLock);

inputLevelGetter->updateLevel (inputChannelData, numInputChannels, numSamples);
outputLevelGetter->updateLevel (const_cast<const float**> (outputChannelData), numOutputChannels, numSamples);

if (callbacks.size() > 0)
{

. //some code
}
----
for (int i = callbacks.size(); --i > 0;)
{
----
}
A better place for doing the outputlevelGetter?
}

My seccond question is:
Why callling the succesive callbacks registered with a tempbuffer as output and then sum them ? Shouldn’t it be better call the callback with the outputbuffer and the function called be in charge of sum the samples? It’s a pity that as deviceManger can register more than one callback all the callbacks begin with a empty or spurious output buffer and we can not chaining the outputs.

Thanks for reading me

I’ll investigate moving the output level calculation. You’re right that it would seem to make more sense to compute the output level at the end of the function, after all of the IO callbacks have run.

For your second question, you should not make any assumptions about the order in which AudioIODeviceCallbacks are called. The documentation for AudioIODeviceCallback::audioDeviceIOCallback says:

The initial contents of [outputChannelData] is undefined, so the callback function must fill all the channels with zeros if its output is silence. Failing to do this could cause quite an unpleasant noise!

If you want to sum the output channels yourself, then you should only register a single AudioIODeviceCallback, and do the summing inside this function. This will also allow you to control precisely the order in which your audio callbacks are called.

1 Like

Things have been a bit busy here so this got delayed a bit, but I’ve moved the output level calculation now:

1 Like