I’ve almost completed my first audio plugin (a compressor) in JUCE, I’m just stuck on figuring out how to convert Attack/Release values from an AudioParameterFloat into a millisecond value.
I’ve looked at using chrono and ctime, but I suppose there might be an easier way using JUCE. If anyone could give me an idea of how to tackle this that might be easier, I would highly appreciate it.
I simply just want to know how to convert a float into a unit of time is all. I don’t necessarily want you to complete the algorithm for me. Just want a method or idea of how I can convert some arbitrary float value into a ms or second value.
Time will have to be reduced to a number of samples… so use the sample rate to calculate the time in samples. Check out the LinearSmoothedValue class for an example.
To add to what @Rail_Jon_Rogut said you’ll almost definitely be doing all your time->samplecount calculations in prepareToPlay(), which is where you’ll find out the incoming sample rate for future processBlock() callbacks.
I don’t think it’s been said clearly hear, but you want to use the float value to scale whatever the range of data is that you want to represent. So let’s say that your attack parameter goes from 0-1000ms, to convert the float to the time you would take float_value * 1000. Hope this helps.