< Back to IRCAM Forum

Filter BPF points by proximity

Hi all,

I’m working with a BPF that represents a natural phenomenon, and I would like to use it to create a sliding tempo-graph. However, there are frequently too many points very close together on the x-axis to be notationally useful, and I would like to eliminate points that are under a certain proximity threshold (i.e. "remove the next point from the BPF if x-distance from the last is < 0.2). I tried the “reduce-points” object which helps somewhat but does not specifically filter in this way. I’ve attached a graphic to demonstrate visually what I mean. Any help is much appreciated!

Thanks,
J

Hi Justin,

Can you send the bpf?
By the way in your example, concerning the first two points you removed the first one instead of the second why? Just checking

Best
K

Yes it’s probably a mistake, I was eyeballing and deleting points by hand. Hopefully the idea is clear (to not allow line segments under a certain x-distance). BPF is below, thanks again!

bpf-patch.omp (1.6 KB)

Hello,

Your case can be very easily dealt with by an omloop which compares adjacent x-points of a BPF and collects them when the distance is greater than . “reduce-points” is rather meant for (often very large) BPF’s with equally spaced X-points, if one wants to reduce the data. It does not quite fit to your case.
Hope this can help.
Marco

Dear Justin,

As Marco (Estudio) states, it is with a loop macro that this can be done. However, i prefer doing like this (using a lisp function):

here is the code (folder to be imported in the workspace including both lisp function and the patch):
bpffiltering.zip (2.3 KB)

Notice that the result is not the same as your first example, since having missed two points < 0.02 the curve is not the same.

Best
K

Since there’s no 'setf available when patching, changing structure needs special handling, probably using recursion or pure functional approaches - often quite messy in the graphics.

Here’s an approach which loops through the bpf-points as usual, but adjusting the ‘by’-function to either skip (cddr) or include (cdr) the next element based on the difference between adjacent x’s:

Thank you for all your solutions! Karim’s patch worked perfectly.

Justin

1 Like