Does this object/concept exist? What's the name for it?

Chadwick Wood's icon

Hi, I'm looking for an object that does something simple, but not sure if it already exists (or what it's called):

I'd like an object that's has at least 1 signal rate input, and 1 signal rate output. The output is just some stored value (let's say it starts at zero), and the input "steers" the stored valued of the output... if the input is positive, the output increases. Negative input -> decrease. Zero input -> no change. And the absolute value of the input is essentially the rate of change of the output.

At control rate, this is simple to make of course. At signal rate, I could think of ways to make this with basically a +~ feeding back into itself (with some small delay), and the other input of the +~ being the "steering" input.

But, I wondered if this is already an object that exists, and also what the name of this concept is. It almost seems like a kind of filter. I need it for an idea!

Christopher Dobrian's icon

You can DIY super-quick in gen~.

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

History history_1(0);
div_2 = in1 / SAMPLERATE;
add_3 = div_2 + history_1;
out1 = add_3;
history_1_next_4 = fixdenorm(add_3);
history_1 = history_1_next_4;

Chadwick Wood's icon

Thank you! This looks like just the thing. So, you're dividing by the sample rate so that the rate of change is <input> per second? I'm very novice with gen~ (but I am a programmer, so I think I get what's going on here).

Is there a name for this kind of thing? I'd like to learn more about it, and having some conceptual term would help in me finding more reading. I want to use this idea to create signals that interact with each other (e.g. one signal that "chases" the value of another, etc) and would love to find examples of this.

Christopher Dobrian's icon

So, you're dividing by the sample rate so that the rate of change is <input> per second?

Yes.

Is there a name for this kind of thing?

This specific algorithm would be called an "accumulator". (There's an accum object in Max, a plusequals~ object in MSP, and an accum object in gen~.)

I want to use this idea to create signals that interact with each other (e.g. one signal that "chases" the value of another, etc) and would love to find examples of this.

See slide~ and rampsmooth~. Or any of a variety of lowpass filters. Or DIY in gen~, etc.

Roman Thilenius's icon

- measure delta (delay the input for 1 sample and substract input from last input)
- check if delta is positive or negative (or 0?) using comparison operators
- if 0 then -1
- accumulate

finding a good name is the hardest part.

my control rate version is called -> parsons encoder, but that is of course only one of many possible applications for the same algo.

but "deltahistorymeter" wouldnt sound very interesting and is difficult to remember.

-110

teeshirtguy5's icon

hey all

hope you dont mind me adding to this thread but this is very useful for a similar problem i have but i cant quite work out how to make fit

i'm trying to make a sort of rhythmic magnet, i have two counter objects inside Gen~ one is giving me the master clock from the transport, and the other is free running clock controlled by a foot pedal

i'm trying to make it so that the freerunning clock always has a tendency to 'magnetize' to the master clock, smoothly over time, say over 16 beats

i also need it to take into account phase difference between the clocks, and to account for this in the curvature of the changing rate, so that once the rates are the same they are also in phase, i understand that the phase change is the integral of rate adjustment, and i can see sort of how it would all work but i cant seem to find a solution that works

thanks!