trouble smoothing signals!

Senka Ortiz's icon

Hello! I'm a relative beginner trying to make a patch that (in part) reacts to sound in the presence of 1 or more blobs. My instinct has been to use a >=1 function -> sel 1 but it hasn't been working, the audio is choppy, I think because the signal is constantly refreshing. I wonder if there is something I can do instead to make it smoother? I've attached a screenshot of part of my patch as the failure it currently is and my patch in full. I'm using reworked pieces of this glorious tutorial https://tinapple.notion.site/Tracking-Blob-Tracking-9b5b314087074429808b53bf4598e4de

Help! smoothing signals!.maxpat
Max Patch

Jan M's icon

Hello Senka,

to smooth a signal a typical way is to use an weighted average formula: y(k) = (1-b)*x(k) + b*y(k-1)

where b is the smoothing amount (between 0 an 1) k is the current number and k-1 the previous number.

Luckily it is the same formula used for a onepole lowpass filter in audio.

What you can do is transform your blob-count into a signal, pass it though [onepole~] with a low cutoff frequency. The lower the the cutoff frequency, the stronger the smoothing. Then make the signal binary with [>~ <blob-count>] and pass the signal to [edge~] to detect changes from 0 to 1 (or 1 to 0)

lopass-filter-smoothing-example.maxpat
Max Patch

Hope that helps!

Senka Ortiz's icon

Thank you so much this is exactly what I needed! Incredible!

TFL's icon

Not sure if going into audio domain is the easiest way in your case, you want to filter a changing integer, not a discrete float signal.

Instead, I would use [change] to filter out repetitions constantly restarting audio and maybe [speedlim] to limit changes to happen too quickly.

There's also a similar thing to onepole~ but in event domain called [p smoov] that you'll find easily in the forum. Put an [int] and a [change] after it and it should work similarly.