function with curve mode and line output [SOLVED]

Christophe Burkman's icon

Hi there,
Having some trouble using function with line to create ramping value with different speed.
The curve function allows me to ease in and or ease out the ramping from 0.0 to 1.0
As seen in the below patch, with linear mode no problem. With curve mode and only 2 points it seems to be ok. But with curve mode and more than two points values from line are far out of range.
Despite my research i could not find any solution.
Is this a bug or am i doing something wrong please ?
Thank you.

Max Patch
Copy patch and select New From Clipboard in Max.


tyler mazaika's icon

In curve mode, [function] outputs 3 values for each point (x, y, curve), not 2 from the 2nd outlet. You'll note the outlet says points in [curve~] format, not [line] format.

Fortunately you can just as easily go from [line] --> [function] where [line] is driving lookups of values from the [function] object by passing in increasing x values.

double_UG's icon

use curve~

TFL's icon

To my knowledge, [line] only works linearly, and so the lists coming from [function]'s second outlet are misnterpreted.

From the [line] documentation:

Use various list combinations to reach a target value.
In one list combination, the first number specifies a starting value, followed by a comma and a number pair. The first number in the pair specifies the target value. The second number of the pair specifies the total amount of time (in milliseconds) in which line should reach the target value. In that amount of time, numbers are output regularly in a line from the currently stored value to the target value.

An example of this type of list is 0, 1 1000 0 1000. In this example, line would go from the starting value of 0 to 1 in one second, then back down to 0 in one second. Once the first ramp has reached its target value, the next one starts. A subsequent list, float, or int in the left inlet clears all ramps yet to be generated.

In another combination, the first number specifies a target value, not followed a comma, and the second number specifies a total amount of time (in milliseconds) in which line should reach the target value. The third number, which is optional, sets the grain. Grain will affect the time interval at which numbers are sent out. Once grains are set in a list, they will override the default until manually reset.

An example of this type of list is 1 1000 100. In this example, line would go from the current value to 1 in a second, outputting a value every 100 milliseconds.

If the list has an even number of elements greater than three, each pair of elements is considered a destination-ramptime pair in a breakpoint function. If the list has an odd number of elements greater than three, the last element will be ignored.

If you look closely, your second example (function in curve mode with only two points), the curve has no effect, the number grows from 0 to 1 linearly.

Christophe Burkman's icon

Thanks for your feedback.

Indeed tyler mazaika, your solution made the trick.
Placing line before function allows me to send X values and getting Y accordingly to the slope of the curve.
As seen in the following patch, all slider fill in the same timing, 5 sec, but with different ramp speed of their respective curves.

Thanks a lot !

Max Patch
Copy patch and select New From Clipboard in Max.


max's icon

Hello,
Yes, put the line before the function do the trick. But it's not possible anymore to change the function on the fly. Do you know how I could use the line output of the function in curve mode ?
Thanks

max's icon

I revive this post.
For the moment, I have to use a snapshot object at the output of the curve~, which is much less precise since the values ​​are scanned a bit randomly (even if my snapshot is very fast)

someone could help please ?

Thanks !

Roman Thilenius's icon

it might be less "randomly" when overdrive is on in the runtime and the audio vectorsize is not too long?

max's icon

thanks Roman. yes for sure, but the line output (not in audio) seems the most accurate. But i don't manage to make it working with function in curve mode.