function~ as adsr with flonums as parameters

marlon brando's icon

Hi,

Anyone help me with this?

Just want the function to be an adsr, and have flonums connected to it that I can modulate with velocity,lfos,stepsequencers etc

cheers

Luke Hall's icon

If you want to visualise your adsr with [function] then you can change the values of existing points with a list of three numbers " " as mentioned in the helpfile. You might want to set up some logic so that a point cannot pass another point, a "minimum"/"maximum" message to a [flonum] would achieve this.

lh

marlon brando's icon

Great !

Thank you !

marlon brando's icon

thereishopeforus@hotmail.com wrote on Tue, 31 March 2009 17:33If you want to visualise your adsr with [function] then you can change the values of existing points with a list of three numbers " " as mentioned in the helpfile. You might want to set up some logic so that a point cannot pass another point, a "minimum"/"maximum" message to a [flonum] would achieve this.

lh

Hey,

Could I use a combination of append, prepend and set or setdomain?

Or something like pak and setrange?

Cheers

Luke Hall's icon

Here's an example of using the [function] object as a display and [flonum] boxes to set the points. The logic doesn't allow a point to get too close to the next or previous point. If you want the [flonum]s to be modulated by an lfo, for example, you might want to look into using [scale] as well.

lh

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

marlon brando's icon

Great!

Thank you very much!

Is it possible to make this generate exponential curves?

Luke Hall's icon

Use [line~] or [curve~] on the [function] output and this will alter the envelope. If you want to display curved envelopes then perhaps you should look at Emmanuel Jourdan's ej.function javascript which loads into a [jsui] it's pretty special.

lh

cebec's icon

thereishopeforus@hotmail.com wrote on Tue, 07 April 2009 14:20...
If you want to display curved envelopes then perhaps you should look at Emmanuel Jourdan's ej.function javascript which loads into a [jsui] it's pretty special.
...http://www.e--j.com/

I recommend using this along with mxjcurve, too. This combination is the heart of a lot of my patches and I really appreciate the work emmanuel and martin put into them.

marlon brando's icon

thereishopeforus@hotmail.com wrote on Tue, 07 April 2009 12:20Use [line~] or [curve~] on the [function] output and this will alter the envelope. If you want to display curved envelopes then perhaps you should look at Emmanuel Jourdan's ej.function javascript which loads into a [jsui] it's pretty special.

lh

Thanks,

Could you please show how you would "bend it" with curve~?

Would it also be possible to get visual feedback of this?

Cheers @ happey easter

Luke Hall's icon

Something like the patch below should work. The message formatting for [curve~] is detailed in the help file. It shouldn't be too difficult if you want to set a different curve value for each break point too. The [scope~] object will give you some visual feedback if that's what you're after. There isn't a built in way of showing the curves on something like [function] apart from the ej.function javascript I mentioned previously. You could try writing your own drawing instructions to an [lcd] though.

lh

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

marlon brando's icon

Thanks a lot!

One tiny question, what object is best to use if I want to replace the sprintf object with something else?

Cheers

Luke Hall's icon

Have a look at [pak]. Something like [pak 3 0. 0] with the [flonum] connected to the second inlet should do it.

lh

Roman Thilenius's icon

Quote:
Is it possible to make this generate exponential curves?

this question comes up often here.

the easiest way would be to simply scale the output values.

Luke Hall's icon

I often just use [*~] on the output of [line~], essentially squaring the output to give a curvier envelope. However this means that the [function] object is showing misleading values on the y axis.

This made me think a bit about how to do something similar with the signal yet keep the points in [function] display as an accurate representation of the envelope level. Here's what I've come up with. It uses two [function] objects, one as an input device and accurate display and another which isn't, but will generate the correct signal when passed through [pow~].

lh

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

marlon brando's icon

This is so helpful!

Is it possible to have only the decay stage exponential, and the
attack and release linear?

Luke Hall's icon

Probably best to head back to [curve~] to do this, the trick is to get the list you send to [curve~] correct. Here's an example patch. Another cool thing is that you can get s-curves if you place a breakpoint midway on the diagonal lines and set the first curve factor positive and the second negative, for an exponential then logarithmic curve respectively. Obviously you need to add another inlet to your [pak] for each breakpoint there is in the [function] object. You could script this if you wanted it done automatically, or simply just set a maximum number and don't use the extra inputs.

lh

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