What are my options for curved envelopes

withakay's icon

Hi,

I am looking for an adsr~ but with a curved logarithmic response. Is there a way to do this with out resorting to externals? I have been trying to cobble something together with curve~ but my lack of Max-fu is seriously letting me down, any masters care to lend a hand?

Roman Thilenius's icon

use buffers for each of the segments, then you can do the math totally in max.

brendan mccloskey's icon

Hi withakay
oooh curved envelopes, hours of endless fun. I'm certainly no master of Max-fu (maybe white belt). If you want a dynamically variable envelope, then the [curve~] object is cool. There are several variants on the hanning window approach - filling a buffer with samples to generate a curved window, and you can even roll your own. I've attached a patch demonstrating these three approaches, with citations too natch.

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

No doubt there are numerous other methods, but option anxiety is the killer!

Brendan

withakay's icon

thanks for your replies, I shall investigate...

Luke Hall's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Here's a way to use [function] with [curve~] to set different curves for breakpoint transition, hopefully you'll find it useful!

withakay's icon

@Luke

I think this is the closest to I want a want - or at least what I *think* I want ;)

Thanks

pid's icon

hi withakay. problem is none of the examples above are signal rate. just stick a [pow~] after the [adsr~] and use the the [adsr~] data to shift between 1. values. although if all you want is a steep exp slope to segments, [*~] the [adsr~] output with itself. in Max6 you will want to look at the rather fantastic [gen~] example "gen~.7_segment_envelope.maxpat". if signal rate does not matter, all the above are excellent examples. my fave for gui interface is to write the curve of [ej.function] to a [buffer~] and read through it with [index~] or whatever, or just a simple message to [curve~]. it is possible to build a very intricate adsr-like schedular driven system for use in midi-triggered poly~s etc with just [curve~].

withakay's icon

Hi pid,

I tried using [pow~] but tbh I don't really get what you mean. I had considered [*~] the output of [adsr~] but that creates the oposite curve for the attack portion to one I want (exponential rather than logarithmic?).

To be clear, I am trying to achieve something like this:

2861.adsr.png
png
Roman Thilenius's icon

well you must use the distortion funcction always on the given range, for example for the range
between volume of hold and volume of release (1.1 to 0.0)

kthozoid's icon

it looks like Toshiro Yamada's sa.function might be useful.

pid's icon
Max Patch
Copy patch and select New From Clipboard in Max.

starting points:

but you should really get gen~ - supersimple and awesome in gen~...

withakay's icon

@pid

wow, very comprehensive! I actually discovered [change~] whilst I was trying to make a frequency divider and realised I could use that to simulate a signal rate 'bang' when the envelope move to a new stage I wasn't sure about how to do it, but you have an example in your pow-by-sections!

I am a little baffled by the sqrt example (I know it is a bad example anyway but), I don't see where you are getting a root from. Oh, I suppose selector input 1 is the root of input 2?

Anyway, I really appreciate the input (from everyone!) I have a lot to grok

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

just for laughs I present the naive solution I came up with before seeing the latest responses

Rob Ramirez's icon

in case you don't already have enough options, you should also check out the new jit.path object, which allows you define a series of points and will automatically calculate a spline path through those points.
you can also edit and visualize the path with the corresponding jit.gl.path object.

the help file should be enough to get you started.
let me know if you have any questions.

t's icon
Max Patch
Copy patch and select New From Clipboard in Max.

here is one solution with curve~. you can easily modify the attack, decay and release slopes. they can be either logarithmic or exponential, so it is no problem to generate an envelope from your picture. and it also has a sustain mode:)

$Adam's icon

Hi,

I made an external some time ago called [sadam.envelopeGenerator] to create curved functions automatically for the [function] object, which can be connected to [line~] then. You have to enter your function in [expr]-style and then the external will update your [function] accordingly. You can access it as part of the sadam library here: http://www.sadam.hu/software

Hope that helps,
Ádám