Forums > MaxMSP

Pitch Envelope via [function]

December 2, 2011 | 12:06 am

I’m kicking myself because I know this is very simple and I even solved it a few months ago but now I can’t remember what I did and I lost my patch! Basically I’m just trying to create a pitch envelope/glissando via the function object and I can’t seem to figure out how to get a completely smooth ramp. Ideally I need the function’s line list to come out as floats instead of signal using line~. Basically doing exactly what you would do with the line object and a message but with function instead of the message. Why can’t I get this?

– Pasted Max Patch, click to expand. –
December 2, 2011 | 12:17 am

[rampsmooth~] Is that all you’re missing?

December 2, 2011 | 12:43 am

Nope, that doesn’t do it.

Can [line] not work with [function] the way [line~] does?

December 2, 2011 | 1:40 am

Nope, it unfortunately can’t. There are several third party objects that do this. I think there’s on in the ejies, and there’s also one called lines.

That said, this may not be a situation that calls for that. My general rule of thumb is that I only use snapshot~ if there’s a highly compelling reason to downsample to control rate, knowing all the irregularity of timing that comes with it, and I generally prefer to use snapshot~ only when I’m triggering it with a bang, so I’m not adding a bunch of events to the scheduler that I may or may not need.

In my experience, this is the type of operation that can be done at signal rate without a huge penalty. Here’s an example that uses matrix~ to do that. It also enables you to do all manner of other crazy things such as frequency shifting particular partials, etc. if you add more inlets. If you’re concerned about CPU usage, you could downsample the hell out of the matrix~ part using poly~ (well, that’s the Max5 way, there may be something newer with Max6)

In terms of math, I’d totally recommend vexpr. It takes some getting used to, but once you get it, you can do a ton of operations with minimal effort, and this is really helpful on an additive synth.

Anyways, pardon the verbosity, but I hope this can be helpful.

– Pasted Max Patch, click to expand. –
December 2, 2011 | 1:46 am

You need to give snapshot~ an update time parameter if you aren’t externally clocking it.

line doesn’t take lists like line~ does.

But what I really don’t get is why you are not just staying in the MSP domain. What is the advantage to moving back to the event domain?

December 2, 2011 | 2:47 am

@Peter: That’s an interesting solution that I’ll have to study.

@Chris: This is not so much about trying to accomplish anything specific but rather more of a "I can’t remember the name of that *insert person/movie/song* and it’s driving me crazy!" kind of situation (if that makes any sense). I have been drilling myself over the past couple of months by seeing if I can spontaneously patch simple operations on the fly, just to make sure I’ve got basics concepts down, and this was such an exercise.

I *swear* I found a simple solution for this around the end of summer but I’ve since lost it. Are you guys sure there is no (non-third party) way to simply get the line format list out of function and straight to a flonum?

And to actually answer your question Chris the only reason that I was going back to the event domain is that the clunky additive engine I built was based on a flonum sending to multiplier objects to create the partials.

If it’s not possible then I will have to chalk this up to me starting to get old and I must have been using [line] with a message (but I swear function was involved!).

December 2, 2011 | 4:03 am

Doesn’t the patch you posted work if you change [snapshot~] to [snapshot~ 1] ?

December 2, 2011 | 5:05 am

I had set the interval from the inspector before I copied it and posted it instead of adding the attribute, which was an oversight on my part. But no, I was getting the same results.

I changed the range of the scale object so you can hear what I’m talking about. You don’t get a smooth glissando with snapshot~. I know I was getting a smooth ramp with my previous solution (that I can’t remember).

– Pasted Max Patch, click to expand. –
December 2, 2011 | 6:21 am

I'm afraid I can't help you with the function object but you can try this if you want:


  1. envelope.png
December 2, 2011 | 2:16 pm

Thanks, I’ve got that solution somewhere on the HD. This was really about a very specific solution that I just can’t seem to remember.

December 2, 2011 | 2:34 pm

I guess this must have been how I did it (and I stayed in the MSP domain, Chris). It just seemed simpler at the time. Sorry for imposing my madness on everyone.

– Pasted Max Patch, click to expand. –
December 2, 2011 | 6:07 pm

I’m glad you found it. I didn’t think that you were going to find a better solution than the snapshot~ one is you were converting back to the event domain.

My last question is why do you have the fundamental there twice? The two left oscillators are at the same frequency.

December 3, 2011 | 12:26 am

Ha, yes, well the answer to that is that it’s a mistake! Like I said before, I’m working on being able to quickly patch particular functions on the fly to test myself. I guess that was the Max equivalent of a typo. :-)

December 3, 2011 | 12:34 am

i agree, you should stay in the frequency domain, then you can just use line~.

when you do you might find out that there is an mtof in your synth
after the note input – you will have to put that into the signal domain
too now when using glide data/signal, for example by using mtof~.


December 3, 2011 | 12:41 am



  1. eeen.jpg
Viewing 15 posts - 1 through 15 (of 15 total)