ADSR Envelope


#1

Hoping someone can point me in the right direction!

The line.to() function will not accept the AudioParamerFloat. I have tried various methods and am compiling fine, but can not return the sliders value or the parameters value.

Any help would be greatly appreciated, as of now my idea is to pass the value and multiply by 100, etc.



#2

Not an expert but afaik lineTo() accepts floats, and when you get() you get a float (no pun huehue). So the problem is you aren’t really getting any values from your slider at all, that’s why it doesn’t return anything at get(). Just follow the same steps adding the parameters to be sure you didn’t miss anything: Parameters tutorial


#3

It’s not that it’s not passing values, the values are not updating.

When I created the number of voices increment slider, the only way to do so was to utilize a pointer to pass the object that was creating the parameter for the slider. I tried using the getValueFromText() and getTextFromValue() lambdas which would not work. I can pass a value but it will not update based on parameter changes. Reasoning my increment slider text box is in decimal places, although that is multiplied by 100 which is indeed 8 voices.

The voices do update based on slider changes.


#4

When using attackValue->getValue() as shown the contents will be updated once at runtime, by getting the initial value. However, the program has compile errors when using attackValue which in my opinion should be working fine.


#5

This is, because you construct the path in the constructor of the component and you never update it.
A solution is, to move it into the paint, so it is always updated when paint is called.
Don’t forget to call internalPath1.clear(); before refilling the path.
Then you might have to trigger the repaint from a timer, or any other callback, that could indicate, that your value has changed (e.g. a Slider::Listener to attackValue).

I would have provided corrected snippets, but I can’t copy and paste from your screenshots. Hence it is better to use markup to copy code into your posts, add three backticks ``` on a single line before and after the code you copy into the post:

    ``` 
    // your code here
    ```

For your compiler error it would be helpful, if you could show the actual error message (here a screenshot would be ok, so it’s nicely formatted from your IDE)


#6

The compiler error when using only attackValue is as shown.

snippet5

This was the other solution I thought possible which is also only sending one initial value at runtime. I tried placing the code in paint, which also did not update.


#7

Like I said, putting the code into paint makes it using the current value, when painting. But you still have to trigger the paint by calling repaint().
You can do this from a continuous timer or from the sliderValueChanged() callback.


#8

Any ideas on updating the text box to a specified value? At this point is it required to create a custom text box? I read on the forum, lambdas are not working for the AudioParameterFloat at this time.


#9

Which text box? The one of a slider? They work just fine for me.

You can add a lambda for the parameter, and when using an AudioProcessorValueTreeState::SliderAttachment, the lambda is copied into the slider, so that the behaviour of the values in the host and the text box is the same. You can change the slider’s lambda after the attachment was created, if you want to have different behaviour.


#10

Thanks a million! It’s working well.