Forums > Gen

translate msp [line~] into gen~ [counter]

July 7, 2013 | 4:03 am


I am trying to get the same functionality from [line~] inside gen~. I would like to send [counter] instructions as follows:

go to 1. in X ms;

go to 0. immediately;

stay at 0. for Y ms.

X and Y will be variable.

The main challenge is working out how to tell [counter] to wait. I’m fairly sure there isn’t a direct equivalent to [line~] in the gen world. The MaxMSP version is below fwiw:


– Pasted Max Patch, click to expand. –


Thanks for looking

July 7, 2013 | 5:57 am

to tell a gen~ operator output to "wait", the basic trick is to use a [?] or [sah] operator. What do you mean by [counter] btw ? the actual Max object ? because there is none in your patch, and there is no [counter] operator in gen afaik… there’s [accum] though
I’ll try and see what i can do…

July 7, 2013 | 6:22 am

There most certainly is a counter operator in gen~, although it was not among the early basic list of operators. It counts samples, of course. About the only differences you’ll notice is that you’ll have to add the "reset on next" count stuff yourself, and the additions of modes of counting [up/down/updown] are left as an "exercise to the genner."

In connection to a little piece of gen~ mischief I was putting together, I realized that it would be very useful to have something in the toolbox that would smooth an input over N samples – which I think is basically what you have in mind. Implementing it proved a more challenging task than I initially assumed. While I languished in the Slough of Despond, I mentioned my suffering to Emmanuel Jourdan [who is owed a drink by quite a number of you by now, and many more by me personally], who kindly suggested that I consider something like this (which you should paste into an empty gen~ object):

– Pasted Max Patch, click to expand. –

Perhaps it may prove to be as instructive to you as it was to me.

Rock on, B.

July 7, 2013 | 6:26 am

Hi vichug
[counter] in gen~ works like [accum] and [+=]. Did you find it?

Recently, I have seen related solutions using [accum] and I am now trying (for reasons of skills development and patch v. CPU optimization) to roll my own. I could be wrong but I believe that using [accum] in a polyphonic context can make excessive demands on memory and/or CPU.

This solution from Peter McCullough and leafcutter. TBH I can’t recall why this one didn’t turn out to be perfect, maybe it’s just the polyphonic load on my machine?


– Pasted Max Patch, click to expand. –



July 7, 2013 | 6:42 am





I will have a hacky Sunday, thank you gents


July 7, 2013 | 6:46 am

Hah… by the time i refreshed the page, i just finished finding what seems like a solution… probably useless by now, but here it is anyway :


– Pasted Max Patch, click to expand. –


even more useless, as i don’t use the most recent version of Max (6.O.8) that’s certainley why i see no [counter] :) and i indeed do use accum, but to achieve this you’ll have to somehow count somehting ? so using accum or count is maybe unavoidable ? not sure but….

July 7, 2013 | 7:40 am

@noob_meister: latch is a easier solution to do sample & hold (new in Max 6.1.x).

July 7, 2013 | 7:52 am


Ah, no [counter] in gen~ for you at the moment. I think the reason I want to avoid using [accum] or [+=] with no upper limit is to test a solution where the [accum], [counter] or whatever is constrained between 0. and 1. to see if I get a noticeable improvement in CPU usage. Apologies for the "duplication of effort"; your solution is a useful addition/alternative to leafcutter’s.


yes, I think I see where the clues left by yourself and Gregory are leading. Using the objects’ reference as, erm, reference is the difference that latch truly samples or holds, where sah is either on or off? I could use latch to do the "waiting" part of my MSP solution?

Thank you again

July 7, 2013 | 1:27 pm

You betcha, Brendan. Good call!

July 9, 2013 | 8:59 am

Almost there gents; driving [latch] with a DIY rectangle wave for "off" and "on".

Some confusion remains in syncing the control signal ("wait") to the central phasor.

Maybe I need to spend time with that good old Zen and the Silent Patch tutorial ;¬)


– Pasted Max Patch, click to expand. –


July 13, 2013 | 5:36 am

Even closer:


– Pasted Max Patch, click to expand. –



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