Forums > MaxMSP

zigzag~ and curve~ (exponential ramp) functionality

Sep 08 2014 | 5:16 pm


I’m working with zigzag and would like to modify its linear ramp output. There’s already an older thread asking about something similar in terms of how would you ‘marry’ zigzag~ with an object like curve~, which accepts multiple ramps and is flexible enough but can only work at control rate and hence is not useful to me.

I think that scaling zigzag~’s value would be overkill, requiring at least three buffers to store the scaling info (minimum and max) plus the curve value, and a complex enough system of arithmetic operations to fetch these values with three different index~ objects.

Is there a solution to this problem? Should this be on a feature list?


Sep 08 2014 | 6:23 pm

i might not be understanding why you’d need at least three buffers…
but… if you think in terms within range 0-1(or even -1 and 1)… just for the zigzag~ portion…, then you can create any curved output you want from there by addressing different phases of cycle~(different curves can be achieved: the first 1/4 and last 1/4 can give equal-power curves, or scaling an entire half like i’ve done below gives standard ‘s’-curve).
on the other hand, feature-request isn’t a bad idea either, since curvatures other than 0.5 or -0.5(according to the curve~ object) would be made easy and users could ramp between any value range, etc.

— Pasted Max Patch, click to expand. —
Sep 08 2014 | 8:15 pm

Hi Raja,

Your idea is good but not applicable to my current project. I’m gonna explain myself further:

I’m using a function object to control the frequency envelope of an oscillator. Why function and not table? I like the elegance and simplicity of function, in that I can input a couple of points and control curvature. As you know, function is designed to work with curve~, but curve~ is not useful to me because it only works at control-rate and what I want is a continuous envelope at the signal-rate, hence my choice of working with zigzag~.

Now that this is clear, I hope this next bit is gonna be understandable. Suppose I have this trajectory drawn in function (in Hz since we’re talking about frequencies): 0 500 250 1000 0

zigzag~ will output this trajectory linearly, and I need it to be exponential whenever I draw a curve. I have made this patch that has all the above issues solved except for the ‘juicy’ part, where the Frequency output from zigzag~ has to be converted to a (0-1.) range to work with exponential curves and scaled back to the original Frequency range (0-1000 according to the function object). I hope you can understand it as I made my best to make it as transparent as possible.


PS: BTW, forget that thing about the 3 buffers. In this patch I devised a more clever approach (l33t).

-- Pasted Max Patch, click to expand. --

  • This reply was modified 2 years by  radiotonga.
Sep 08 2014 | 10:25 pm

Have you tried experimenting with putting the output of a function/line~ combo through a log~, sqrt~, or pow~? I would be curious to see how it worked out. Just a theory.

Edit: I wasn’t able to check your patch because I am computerless, so I apologize if I already mentioned something you just posted. :P

  • This reply was modified 2 years by  neceq.
Sep 08 2014 | 10:34 pm

Well, in my patch I attempt to replicate the internal functionality of curve~ with pow~ objects. That part could be applied to the output of line~ but would be totally worthless since curve~ does this so well on its own.

Perhaps my own goal is absurd, but in the end I’m just looking for a way to implement such a nice way of drawn envelopes (function) to a continuous signal-rate. curve~ is just control-rate (44.1 samples minimum resolution).

Sep 08 2014 | 11:16 pm

ah, much clearer, i understand now, you want the curve-style messages out of ‘function’…
that reminds me, though, if you look in the ‘techno~’ helpfile the ‘technoui.js’ interface coupled with techno~ does this nicely already… or you may even be able to look in the .js file(max/cycling’74/jsui-library/technoui.js) to help you figure out the curve calculation.

(i agree though, adding curvature to zigzag~ so it could be used at signal rate with function/ramp-list with curvature params would be ideal)

Sep 09 2014 | 8:39 am

Yeah well, technoui.js is not very flexible (for instance, you can only have a fixed number of points, like a step-sequencer), and I’m very rusty on JS so I’ll just have to figure out the complex way. Objects like function are very good for visual-oriented sketching. I will contact the guys at Cycling and make the request anyhow.

Sep 09 2014 | 9:50 am

Ok, here’s my masterwork for posterity…

(it goes to show how much DSP/list processing you could avoid with one single object, in case zigzag~ ever gets updated with this feature)

-- Pasted Max Patch, click to expand. --

Viewing 8 posts - 1 through 8 (of 8 total)

Forums > MaxMSP