< Back to IRCAM Forum

Stretching and compressing dynamically a bpf

Hi all,
I would like to know how (with a lisp function, or with a patch) a bpf can be stretched and compressed horizontally by means of another bpf. In particular, assuming that the number of points is the same for both bpfs, if a x point value – that I name here k – of the second bpf is > 1, the first bpf should be horizontally stretched by multiplying its corresponding x-coordinate by k. If 0 < k < 1 the bpf should be horizontally compressed by multiplying the x-coordinate by k.
I don’t know if there’s already a function hidden somewhere in OM or in some of its libraries that does what I’m looking for. Thanks as usual for your support.
Best regards,
Francesco Vitale

Dear Francesco,

Trying to help here but your question is rather obscure. What do you mean by length of points ?
what is a point value k ?
Can you give a simpler description of your problem ?

Best
K

Dear Karim,
sorry if my previous messages was unclear. I’m correcting it now. The point value is the y-coordinate of the second bpf.

Still unclear.
Can you send a MWE (Minimum Working Example) patch. this would be clearer.
Because after all there are tools such as bpf-scale for such matters.

Best
K

Dear Karim,
unfortunately I’ve no examples to send at the moment, but I will soon post it here if needed. I will try to explain better what I’m looking for. For example, in the OM SuperVP library, like in Audiosculpt, there’s the Dynamic Time Stretching controlled with a bpf curve. Now, instead of stretching and compressing a sound wave, what I’m trying to do is to stretch and compress a bpf by means of another bpf curve. Tell me if it’s still too obscure.
Best,
Francesco

No , thanx now i get you 100%.
It is a dynamic stretching you are looking for.
I think this can be done.
will look into it,.
Best
K

Dear Karim,
you got it completely right. As I didn’t manage to build a patch that does this dynamic stretching, all I can give you at the moment is a visual rendition of the wanted process. Here’s an example. Taking this bpf as a starting point

one should be able to stretch and compress it like this: with the y values of another bpf, used as a stretch/compression factor.
Best,
Francesco

Hmmm,
Maybe something like this:

Here is the patch:
dynamic_stretch 2.omp (9.9 KB)

Best
K

That’s brilliant, Karim, as usual. I have one question: what is the logic behind the dynamic stretch/contraction bpf? I’m asking this because it happens many times that the resulting stretched/compressed curve is a bpc and not a bpf (see the image):

.
Best,
Francesco

Dear Francesco,

sorry talked fast.
you should apply on the x axes.
best
K

Thanks, it seems to work now correctly: see image


Best, Francesco

Dear Karim,
maybe I’m missing out something important, but I’m encountering some problems with your solution. Here’s a simple patch. As you can see, if I use the control bpf to compress and then to stretch a curve everything seems to work, but if I invert the values of the control bpf in order to stretch and then to compress the curve the result is wrong. Why is this happening?
Best,
Francesco
dynamic_stretch 4.omp (254.9 KB)

That is because you got some wrong patching
How about this:
37
best
k

Dear Karim,
even with your correction, the wrong result is still there:

Here’s the patch so maybe you can see if you can reproduce the error dynamic_stretch 4-1.omp (256.2 KB) (256.2 KB)
Best,
Francesco

P.S. As you can see from the patch I did not use fully your corrections. In fact, if I had used them, I’d have an even stranger result (what is that?):

Dear Francesco,

If you expect the result to be coherent, you should be more careful in the programing of the scaling and sampling. You should stick to our first patch.
So this i presume is what you expect it:

However, i must admit that the miniview is faulty. Just open the editor, and you have your compressed sine. No ?

here is the patch:
dynamic_stretch 5.omp (216.8 KB)

Note that it is better to start with a straight forward bpf control (simple one, then sample it).

Best
K

Dear Karim,
thanks for your patience. The wrong result I was noticing is not in the miniview (which is faulty indeed), but in the bpf as showed in the editor. I can see the problem even in your screenshot (I highlighted it with the red circle).

In fact there are some extra points added without reason to a portion of the bpf that distort it!
Why is this happening remains a mystery to me.
Best,
Francesco

sorry but i don’t seem to understand your extra points thing.
Your bpf has as much points as the original one that amounts to 3016.
Unless you don’t know what you really want here.

Dear Karim,
here’s the comparison enclosed in a patch.
dynamic_stretch 5.omp (129.4 KB)
This is the actual wrong result with the curve distorted:

and this is the bpf as it should be (the displaced points causing the distortion have been cleaned by hand):
right
Do you see the issue now?
Best,
Francesco

No difference: