Morp between filter types

Jun 14, 2013 at 9:39am

Morp between filter types

Hy guys

I was wondering that is it possible to morph between filter types in realtime?

#252758
Jun 14, 2013 at 1:31pm

Nothing?

#252796
Jun 14, 2013 at 1:46pm

the most easy A->B solution was to run 2 filters in parallel and just mix these channels against each other.

#252801
Jun 14, 2013 at 1:49pm

Yap, but I would like to use 3 filter types…

#252802
Jun 14, 2013 at 2:40pm

okay, for three or more filters there are several options how you might want to morph. between all? or only linear, with or without a connection between the first and the last?

when you want morph between the actual parameters of [biquad~], you could use a lowpass instead of a hipass by setting its volume to 0. and inverting the gain input. but of course this is not the same, it gives a totally different transform.

#252804
Jun 14, 2013 at 2:55pm

What I want to get.

A dial from 0-127.

If the dial is on 0, you will get a LowShelf filter, with teh controls.
On 64 a PeakNotch.
On 127 a Highshelf.

For example, on 96 you will be ony halfway between a peaknotch and a highshelf filter…

#252808
Jun 14, 2013 at 2:57pm

What i got now :

3 filtergraphs, the are OK, with the 3 different filters.

Pak’d the coefs, send them to a 4th filtergraph, every filter is there.

I just have to “mix” somehow the 3 lists comes to the pak object…crossfade between the lists :(

But don’t know how…

#252809
Jun 14, 2013 at 9:54pm

I just woke up, with “fresh” mind.

What I need is a crossfader between 3 values…
For example, crossfader can make 0. 60., the values are 1, 2, 3.

Crossfader states
0 = 1
15 = 1.5
30 = 2
45 = 2.5
60 = 3

Any ideas?

#252819
Jun 14, 2013 at 10:27pm

Taked a look after the M4L abstractions, there is a crossfader between 2 inlets, just don’t know, how to add the third :(

Attachments:
  1. crossfade-1.maxpat
#252821
Jun 14, 2013 at 11:59pm

Easiest way: use 3 function objects as lookup tables. Set the domains to 127 ms long, then draw the appropriate shapes for each. Send the 0-127 value in the inlet and you’ll get the interpolated y value out the left outlet.

Way easier than doing the math… (and if you need curves, switch function to curve mode!)

#252825
Jun 15, 2013 at 5:02am

Thank you Peter. Could you post an example? Im not familiar with the mentiomed objects…:(

#252836
Jun 15, 2013 at 6:12am

so you want to do what i called “linear”.

i would still do this by parallel filters and mixing their outputs.

if you want to do it with 1 filter only it will be definitely more work.

#252838
Jun 15, 2013 at 6:17am

Roman, with your idea my problem is still the same. I have to mix between the 3 filtered signals, but only with 1 knob :(

#252840
Jun 15, 2013 at 6:25am

btw, the approach to peform a linear crossfade between the coefficients might give you some quite unexpected results.

#252842
Jun 15, 2013 at 6:32am

Could you explain?

#252843
Jun 15, 2013 at 6:40am

I’ve tried the crossfade between coeffs…
It is slow, slow, slow :(

Roman, could you tell me a bit more about your two ideas? (Paralell filtering and/or making it with 1 filter)

#252845
Jun 15, 2013 at 7:08am

the problem is that the calculation for the coeffs is different for each filter type.

if you have a highpass at 50 Hz and a lowpass at 2500 Hz and you interpolate between the coefficent list, that wont sound much like a linear fade.

i think you would prefer to interpolate between frequency, reonance, gain, and filter type – where the “interpolation” between the type is something you have to build your own. at the same time this part, the morph between two types, can be replaced just fine by mixing two types.

input
|||
biquad-highpass biquad-bandpass biquad-lowpass (all with the same frequency, gain, and q setting)
|||
[*~ 0.] [*~ 0.] [*~ 0.]

then control the mixer with your crossfader (i failed to see your question about it)
it is for 3 sources basically nothing more than 2 for 2 sources.

for 2 sources:

knob
[/ 127.]
|, |
| [* -1.]
| [+ 1.]
|, |
[* 0.] [* 0.] (into right inlets, left inlets are for the 2 filter ouputs)

for 3 sources:

knob
[/ 127.]
[* 2.]
[if ($f1<1.) then $f1 else out2 $f1 ] (or use the [split] object)
|, |
| [- 1.]
|, |
| [+ 1.], | [+ 1.]
| || | (2nd and 3rd both go into the middle [* 0.])
[* 0.] [* 0.] [* 0.]

you will find that the values of the outer ones will hang a bit when moving the knob faster.

but i think it is bad enough to read it like this from the forums. ;)

#252846
Jun 15, 2013 at 8:05am

I see, thank you for the help.
What about this Morhp Device :

http://cycling74.com/forums/topic/morph-filter-a-new-max-for-live-device-for-live-9-filtering-fun-time/

It seems he managed somehow the morphing…I just can’t fogired out how, cause the patch is a bit messy…

#252848
Jun 15, 2013 at 9:19am

There is also a way to let a pattrstorage do the interpolation. Store just the 5 filter coefficients and let pattrstorage do the magic…
The result might be different than expected. If so take Romans advice and simply cross fade multiple filters…

#252852
Jun 15, 2013 at 9:28am

or do it all by hand:

<code>

– Pasted Max Patch, click to expand. –

</code>

#252853
Jun 15, 2013 at 10:41am

Dear Stefan,

Now thats what I was talin about1
Thank you very much!

Could you explain me (sorry I wont be rude or something like this…)

So there are 3 filter types. The coef lists go into the unjoin object, but what happends then?

#252856
Jun 15, 2013 at 11:57am

Hi Snaper,

Glad you checked out my Morph Filter Device, sorry about the messy code. Was quite a quick build and haven’t had time to clean up or comment it yet.

I achieved the filter morphing by using several [filtercoeff~] and one [biquad~] for the actual filtering.

I wanted to morph between five filters so made 5 [filtercoeff~] objects each with controls to change the cutoff, gain, resonance and filtertype.

The [filtercoeff~] object generates 5 signal outputs which are the 5 signal inputs for [biquad~].

I used 5 [scale~] objects, one for each of [biquad~]‘s inputs, to scale between the signal outputs of [filtercoeff~].

I was hoping doing it all at signal rate would make it sound quite smooth and fast. I have another version of the device with built in LFOs. The signal rate LFOs output can go straight into the [scale~] objects which sounds pretty awesome, heh.

#252859
Jun 15, 2013 at 12:52pm

Hy Myr.

I saw your patch, nice, a bit messy, but technically nice.

Got the coeffs and the biwuad, just can’t understand the scale method…

#252864
Jun 15, 2013 at 2:22pm

Stefan :

Your patch is just amazing. Now I’ve created 2 diff. morphing filters (both have 3 types).
…so just would like to morph between the 2 new filters :D

Folloew the patch, but after 0.1 (“Morph parameter”), there is a big jump between the filters.

I think it is because is used the same method for this 2…

#252873
Jun 15, 2013 at 2:34pm

sorry, just had a look at the patch again, looks like i did something more complex than i thought. i used more [scale~] objects, one [scale~] for each pair of [filtercoeff~] you want to morph between, and 5 [selector~] objects, one for each coefficient input of [biquad~]. the [selector~] objects make sure only one signal from each set of [scale~] objects is going through to [biquad~] at a time. so only two filter shapes are morphing between each other, even though there’s five [filtercoeff~].

it’s been a long day and i’m struggling to describe it, heh. i’ll try and cut out a small part of the patch to show it working between just two filters, but it does sound like the Morph Filter does what you’re after.

#252874
Jun 15, 2013 at 2:46pm

ah well looking at Stefan’s patch it uses exactly the same method as i did, except i did it all with signal rate objects.

Stefan’s patch describes the principal perfectly. If you have 3 different filters to morph between you create 3 objects which design the filter coeffs, so [filtergraph~] or [filtercoeff~]. you then create a set of 5 scaling objects, one scale for each coeff, for each filter morph. so for 3 filters you need 2 sets of 5 scale objects. one set of 5 scales for the morph between the first two filters, and another set of 5 scales for the morph between the second and third filter. my Morph Filter has 5 filters so i needed 4 sets of 5 scaling objects.

you then run the outputs of the scaling objects into a selector or join.

#252876
Jun 15, 2013 at 6:27pm

Well, the filtergraph is just a sophisticated way to calculate the five parameters for biquad. Look at the help file for biquad an maybe some literature about digital filters. All you have to interpolate are the biquad values. The filtergraph can also display the resulting frequency shape if its in display mode…
The filter types do not exist for biquad, they only help you to calculate the parameters within filtergraph…
The unjoin will simply cut up the list from filter graph into five floats. These floats then are interpolated with scale (five for each range (0.-1. & 1.-2.)… One could also try to achive this with a vexpr…

hope that helps…

Stefan

#252881
Jun 15, 2013 at 8:03pm

And here is the vexpr version:

<code>

– Pasted Max Patch, click to expand. –

</code>

#252884
Jun 15, 2013 at 9:49pm

A further extension to Stefans biquad coef interpolation, using nodes with normalised weightings:

<code>

– Pasted Max Patch, click to expand. –

</code>

edit- works better with trigger objects now connected properly

#252888
Jun 16, 2013 at 4:33am

Wow, tahnk you so much guys, now everything is clear. :D

Will try to morph between some gen filters :D:D:D

#252909
Jun 19, 2013 at 10:56pm

Stefan,

Can I contact you outside of the forum?

(It seems PMs aren’t working these days…)

#253390

You must be logged in to reply to this topic.