Morp between filter types
Hy guys
I was wondering that is it possible to morph between filter types in realtime?
Nothing?
the most easy A->B solution was to run 2 filters in parallel and just mix these channels against each other.
Yap, but I would like to use 3 filter types...
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.
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...
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...
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?
Taked a look after the M4L abstractions, there is a crossfader between 2 inlets, just don't know, how to add the third :(
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!)
Thank you Peter. Could you post an example? Im not familiar with the mentiomed objects...:(
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.
Roman, with your idea my problem is still the same. I have to mix between the 3 filtered signals, but only with 1 knob :(
btw, the approach to peform a linear crossfade between the coefficients might give you some quite unexpected results.
Could you explain?
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)
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.]
|, |
| [+ 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. ;)
I see, thank you for the help.
What about this Morhp Device :
It seems he managed somehow the morphing...I just can't fogired out how, cause the patch is a bit messy...
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...
or do it all by hand:
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?
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.
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...
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...
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.
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.
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
And here is the vexpr version:
A further extension to Stefans biquad coef interpolation, using nodes with normalised weightings:
edit- works better with trigger objects now connected properly
Wow, tahnk you so much guys, now everything is clear. :D
Will try to morph between some gen filters :D:D:D
Stefan,
Can I contact you outside of the forum?
(It seems PMs aren't working these days...)