deciBels in NormalisableRange using lambdas


#1

I’m trying to create a NormalisableRange which converts decibels to gain, used in a master volume slider. However, my current code produces junk values…

NormalisableRange<float> decibelRange = NormalisableRange<float>(-144.0f, 6.0f, 
		[](float start, float end, float gain) { return Decibels::gainToDecibels(gain, start); },
		[](float start, float end, float dB) { return Decibels::decibelsToGain(dB, start); }
		);

addParameter (gainParam = new AudioParameterFloat("volume", "Volume" , decibelRange,	-6.0f));

What am I doing wrong?


#2

Turns out I’m an idiot. Didn’t convert the decibels to normalised value in applyGain call…