Convert float to ms for attack/release on a compressor


#1

Hello everyone,

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.

Thanks!
Erik


#2

That completely depends on your DSP algorithm. How are we supposed to know what you did there and then covert it for you?


#3

Hey, totally fair – didn’t think about that.

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.


#4

And how do we know what 0.5f means for your specific algorithm? Is it 5ms or 500ms or 5 seconds?

There is no “standard” for converting floats (which are just arbitrary numbers) to anything human readable.


#5

What do you mean by a “millisecond” value? You shouldn’t be converting anything, values in C++ have no concept of units, just types.


#6

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.

Rail


#7

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.


#8

Well, my bad guys. I guess I need to go back to the drawing board and understand what my problem is a bit better. I appreciate the help.


#9

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.


#10

attack = jmap(value0To1, 5.f, 1000.f) ?