Averaging/smoothing a ctrl object output

daz1761's icon

I have MIDI cc messages incoming from an analog light sensor ranging between the values of 0-127.  The problem is that the readings are extremely noisy.  For example, if the sensor is reading 60, it will be fluctuating between the late 50's and mid 60's value as the sample rate is quite high (~20hz).  I tried the smoother object but I couldn't get it to work.  The light sensor is controlling a few mix sliders.  I just want them to be smooth and not twitch erratically like they are now.

woyteg's icon

you tried the [slide] object? why didn't it work? post patch?

daz1761's icon

Sorry, its probably because I'm new to Max. Here is my code, its without the smoother object

GraphDemoSmooth.maxpat
Max Patch
spectro's icon
Max Patch
Copy patch and select New From Clipboard in Max.

While a rather jittery controller input won't help and may indeed need smoothing as well - The issue is in turning the 127 steps of the slider into a smooth gain value for an audio signal - Something like line~ (added in first 'channel' of your patch) should help.

daz1761's icon

Many thanks, although the sliders are twitching like mad, the audio is pretty smooth. No clicking, etc. Its good enough for demo purposes until I learn more about Max. Do I need to add the line object to the other channels? Is it possible you could tell me what the line object is doing? Also, what does the dollar sign mean?

Chris Muir's icon

Here's a thread from a couple years back that discusses various methods:
https://cycling74.com/forums/smoothing-out-numbers/

daz1761's icon

Thanks :-)

Emmanuel J's solution seems to work best for me at the moment.