Parameter smoothing in gen~

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

Hi guys,
trying to do parameter smoothing in gen~.
Any strategy?
I've tried this following simple thingie but doesn't provide the required amount of smoothing.
Have to use audio rate parameters outside of gen~ (i.e. using sig~ )

thanks
a.

brendan mccloskey's icon

Hi Alfonso

Gregory Taylor's response to my recent "line~ as counter" question here might help. Very nice interpolation idea.

Brendan

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

In itself the strategy works well, it's just that the argument for mix should be much closer to 1. This setup behaves similar to slide~.

alfonso santimone's icon

many thanks guys! useful infos!

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

I just made this gen~ patch inspired by supercollider's "lag3". Very useful for parameter smoothing. Unlike line~ it has a smooth start and end, in some cases producing less unwanted artifacts.

kleine's icon

Great - thanks!

Ernest's icon

I made this, it's simple. For faster response the .01 could be higher (and .99 changed the two coefficients still add up to 1). I think it could be twice or more faster, but I didn't need it.

One nice thing is, with faster audio rates, the difference between samples is smaller, so the coefficients don't need to change when sample rate changes.

Capture.jpg
jpg
jesse sutton-jones's icon

Im trying to do exactly this but I can't find the 'history' object! What does it do and where can I get it?

achzo's icon

use gen?

Graham Wakefield's icon

The mix/history combo is the same as a one pole (and Ernest's example is also a one pole).

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

Tarik's is three one poles in series, with some code for calculating the desired coefficient from a duration (and constant target threshold). BTW, in Tarik's code the abs() is unnecessary, so the onepole() is still equivalent to mix+history. Here's the same, slightly re-arranged:

Wetterberg's icon

ooh. Pretty!

simon ho's icon

I know this thread is a bit old, but for anyone interested, the gen~ "slide" object (introduced in Max 7) works as a slew limiter and takes attributes for fall time and rise time.

Ernest's icon

Hi, this is from another example in the cycling 74 distribution which testing showed to be about three times as efficient as the gen~ slide object:

ramp0(in1, inc){ // linearly ramps to new val for in1 @ stepsize inc
    History prev;
    prev = prev + inc * (in1 -prev);        
    return prev;
}

simon ho's icon

Ernest, this looks neat. I'm just getting started with Gen. How does one implement this solution in a patch?

Ernest's icon

One puts ones own functions at the top of the gen codebox code, then calls them just like built-in functions. Im going to be gone for a while, I hope you can figure it out )

👽'tW∆s ∆lienz👽's icon

@SimonHo, try pasting it in a 'codebox' object from within gen~, you could reduce it to:
History prev;     
prev = prev + in2 * (in1 -prev); \\linear ramp         
out1 = prev;
then attach outlets and inlets to get to the outer patcher(in1 is the input-signal, in2 is the stepsize/increment/slope), and try input into inlets and scope~ the outlet

(...but the gen~ 'slide' object has a logarithmic/exponential response, just thought i'd mention).

Ernest's icon

No, thats incorrect, the slide object can create a curve in either direction as well as just linear, and the equation for the curves are defined for the equivalent max object whose name I forget, and its not a logarithmic curve.

What I was saying is if you only want stepwise linear function then its not very efficient, and the reason is, it doesnt have to look at all five input values to determine what to do. And that's why Im ill these days. I never used to have to say things like this, but since Trump took over everyone goes around saying other people are wrong. I guess its because Trump did it and he was president and most emotional maturity in this country didnt advance much after middle school, so people think its the right thing to do now. It used not to be a problem here because it was meant to be about scientific stuff here, but who cares these days. I just listened to the Icelandic Prime Minister explain a pandemic should be solved by scientists but not politicians, which is why Iceland has no covid epidemic and people are dancing on the streets here. But since about the time Apple decided to regard developers as a source of income, even development software has become politicized. Let alone social media. people just want to say they are right and other people are wrong, wihtout actually caring that much what they say how are other people are wrong is also wrong. People dont actually try to collaborate any more. Which is why I quit and I was wrong to come back, but I felt I should let you people have what I did, for what reason Im not sure any more. I have someone working at cycling 74 telling me what hed like me to add my synth and I cant even install the most recent Max build because Microsoft's now joined in and Windows Defender refuses to let me install Max any more. I said that on the release note thread and I had to argue with people in five messages explaining that I dont have Norton installed five times. There was a time I didnt need to do that. So you folks are on your own now. Im going back to hospital for cancer. Have a nice day.

👽'tW∆s ∆lienz👽's icon

everyone goes around saying other people are wrong

i never said anything like this... there's no possibility of wrong or right in comprehending different kinds of slope accessed in various forms of smoothing, it's just math functions.

you had an emotional response perhaps based on past trauma(your mention of trump, etc. speaks to this), i understand how it is, Ernest, don't take it personally, come and go as you please, you'll find unconditional acceptance here. no harm intended. may you make a swift recovery. i wish you well 🙏

Ernest's icon

since you edited your response, no,. I already am familiar with that far too well. Its too difficult to admit you are wrong, isnt it? Well It isnt actually my problem, and as its important to you to be condesdending to me about my emotional attitude before pretending you care about my health, which is also symptomatic of the trump era, I dont have anything further to say at all.

Ernest's icon

You just should edit it one more time to say its a parabolic and then you can be as rightful as much as you want.

👽'tW∆s ∆lienz👽's icon

even before i edited, i never said anything close to "ernest is wrong" in fact, it was always only addressed to Simon. you were never addressed by me, Ernest, until you said "no thats incorrect"(which i assumed was addressed to me).
if you think you were ever addressed or attacked by any of my wording prior to that, this article is definitely for you:
https://en.wikipedia.org/wiki/Narcissistic_personality_disorder

Ernest's icon

What you can now do is explain why the article you just agreed with on FIR/IIR has feedback and feedforward the other away around than normally depicted, and also, why you have redifined 'logarithmic' to be the same as 'inverse exponential.' I leave it to you to explain that to your friends, Im insane.

👽'tW∆s ∆lienz👽's icon

🤗 You're not insane, Ernest, just going through hard times... been that way for awhile for many of us("I wanna know have you ever seen the rain..."). I meant no harm, again.

if i could comment on something you wrote, bear with me, it's no insult:
"it was meant to be about scientific stuff here"
you come from a high-level of thought. i hold much respect for your knowledge and understanding.
but perhaps if people sometimes use our minds too much, we end up locking ourselves into thinking patterns which make us get our ego too easily perturbed - i think it can be a result of just charging with such drive and passion inside our heads for so long - that amount of focus can be toxic, makes us think these small/petty things like Max/MSP or FIR/IIR are something to identify our pride over.
sometimes if you just let go, breathe, meditate, try to let the mind go quiet, life can get better.
i dunno... you can assume what you want about me, i just meant this last thing as a suggestion from my heart.
apologies if i've upset you ✌️

Peter Nyboer's icon

Here are all the approaches to data smoothing in gen~ from above, unified in a single patch for easy comparison.

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