If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Dispersion Filter
8 posts
• Page 1 of 1
Dispersion Filter
Dispersion is the phenomenon of waves with different frequencies traveling at different speeds. Piano strings, for instance, show noticeable dispersion due to their stiffness, resulting in a characteristic overtone spreading. In DSP, dispersion can be simulated by using allpass filters. The design of filters with specified dispersion features usually requires sophisticated optimization techniques implemented in dedicated, often prohibitively expensive software. However, in 2006 Jonathan S. Abel and Julius O. Smith published a paper where they present a simple, non-iterative approach geared towards allpass dispersion filters of high order. I have implemented their scheme in the schematic below - it works quite well, although the architecture is somewhat messy with some parts in green and others in code. Maybe Ruby would be a more efficient tool for that.
Anyway, I have included a small demo where you can listen to a filtered impulse train. The one filter delays the low frequencies more than the high frequencies, the other is exactly opposite. Quite funny.
Anyway, I have included a small demo where you can listen to a filtered impulse train. The one filter delays the low frequencies more than the high frequencies, the other is exactly opposite. Quite funny.
- Attachments
-
- dispersion.fsm
- (59.76 KiB) Downloaded 1429 times
-
martinvicanek - Posts: 1328
- Joined: Sat Jun 22, 2013 8:28 pm
Re: Dispersion Filter
This is very interesting topic indeed. I'm also currently working on a physical modeling project. Currently my schematic uses least-squares method to estimate the filter coefficients (the filter is both, damping and dispersing filter in one). However it might be a cool side feature to create one that uses FFT windows to analyze overtone peaks decay (and estimate damping filter from that) and also something that would measure dispersion (perhaps overtone detuning). This would come handy in implementing the measured model.
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: Dispersion Filter
That's pretty cool, is that using bandpass shaped group delay or just standard 2nd order continuous low-high/high-low phase delay curve? read a paper that used the former for a similar purpose.
I have been doing physical modelling similar to KG but haven't quite got to the stage where more accurate dispersion is a pressing concern as I've found some issues that seem to affect any IIR allpass with instability appearing when attempting to model nonlinearities (even with static coefficients on the filter itself), will put up a demo showing the problems soon.
I have been doing physical modelling similar to KG but haven't quite got to the stage where more accurate dispersion is a pressing concern as I've found some issues that seem to affect any IIR allpass with instability appearing when attempting to model nonlinearities (even with static coefficients on the filter itself), will put up a demo showing the problems soon.
- dentistguba
- Posts: 13
- Joined: Thu Jan 10, 2013 8:39 pm
Re: Dispersion Filter
dentistguba wrote:That's pretty cool, is that using bandpass shaped group delay or just standard 2nd order continuous low-high/high-low phase delay curve? read a paper that used the former for a similar purpose.
I have been doing physical modelling similar to KG but haven't quite got to the stage where more accurate dispersion is a pressing concern as I've found some issues that seem to affect any IIR allpass with instability appearing when attempting to model nonlinearities (even with static coefficients on the filter itself), will put up a demo showing the problems soon.
Nonlinearities can be implemented by adding new variables to the game...
usually the filter equation is:
y0=b0*x0+b1*x1+...-a1*y1+a2*y2
but you can add
y0=c0*htan(x0)+d1*htan(y1)+...
and similar stuff. Least squares method should have no problem computing it. The instability might still be there though...
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: Dispersion Filter
My problem may actually be due to the delay modulation really as i guess reading out a sample more than once could create extra energy, for stretching out a bunch of samples the level would have to be scaled down so they add up to the same value as before. Just odd that the allpass seems to be the thing which shows up problems, maybe as the phase delay can make the loop loss happen less often for a frequency.
Also I have come close to making my own little allpass design tool which should allow you to set a first order coefficient based on a chosen phase delay at the fundamental, also giving you the delay compensation amount. Just tried out the wolfram alpha algebra rearranging tool on the allpass phase response equation. Seems to just have an accuracy issue though, I converted xoxos' allpass delay compensation to sm which works well but my version drifts away from it.
started trying to rearrange the module which is correct but it's a bit confusing as it seems to be arranged in a strange way and I don't know how to reverse the atan which takes two values in (cos and sin maybe?).
here is where i got to, two delays in parallel with the lower one having the allpass. the 'desired phase delay' part has a phase select knob and outputs the allpass coefficient and the compensated delay length, the coefficient then goes into the xoxos module which outputs the correctly compensated delay. Basically I need to match the delay out of my module to the other to get it working.
Seems like the result is close enough to be a numerical error rather than the whole process being wrong, need someone who understands phase response calculations a bit better to have a look maybe.
Also I have come close to making my own little allpass design tool which should allow you to set a first order coefficient based on a chosen phase delay at the fundamental, also giving you the delay compensation amount. Just tried out the wolfram alpha algebra rearranging tool on the allpass phase response equation. Seems to just have an accuracy issue though, I converted xoxos' allpass delay compensation to sm which works well but my version drifts away from it.
started trying to rearrange the module which is correct but it's a bit confusing as it seems to be arranged in a strange way and I don't know how to reverse the atan which takes two values in (cos and sin maybe?).
here is where i got to, two delays in parallel with the lower one having the allpass. the 'desired phase delay' part has a phase select knob and outputs the allpass coefficient and the compensated delay length, the coefficient then goes into the xoxos module which outputs the correctly compensated delay. Basically I need to match the delay out of my module to the other to get it working.
Seems like the result is close enough to be a numerical error rather than the whole process being wrong, need someone who understands phase response calculations a bit better to have a look maybe.
- Attachments
-
- coeff from desired phase test v2 13-06-2014.fsm
- Testing allpass delay compensation/design
- (24.58 KiB) Downloaded 1337 times
- dentistguba
- Posts: 13
- Joined: Thu Jan 10, 2013 8:39 pm
Re: Dispersion Filter
You have an error in the allpass code.
the "x1=in;" should not be in stage3 after everything - it must be in stage2 before everything.
Otherwise the code has extra 1 sample latency. It is the same phenomenon as in FS stock delay where you can't set zero delay (it will be 1 for both 0 and 1 delay input).
the "x1=in;" should not be in stage3 after everything - it must be in stage2 before everything.
Otherwise the code has extra 1 sample latency. It is the same phenomenon as in FS stock delay where you can't set zero delay (it will be 1 for both 0 and 1 delay input).
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: Dispersion Filter
I beleive the 'X1' there is 'prevIn' with this form which swaps the usual middle delay with the multiplies in the comb parts making a one multiply, two buffer version.
There is sort of an extra delay though as you can see from the wave display when the pure delay time out of the divide is connected to both delays and the 'phase' is zero, The 'high to low' setting of an allpass appears visually to always have a one sample delay from swinging negative before reaching the peak. however, my code seems to be out by one sample at o desired phase and closer as the phase increases, maybe this is due to not seeing a true peak before the visible positive one which would be corrected with, say, 0.5 samples?
i've added a diagram with samples in green lerped in black and the red showing a deviation in the continuous 'infinite' sample rate. I guess also the amplitude envelope could peak along the rise rather than at a visible corner.
maybe my bit of code is ignoring the time it takes for nyquist to reach peak amplitude at the start of the response and this is not always 1 sample despite appearing that way on an fft or diagrams of group delay i've seen.
I may also have simply messed up with all the amounts of PI, wish flowstone would just give a pure answer to trig ops without any conversions, would be easier to control what happens.
There is sort of an extra delay though as you can see from the wave display when the pure delay time out of the divide is connected to both delays and the 'phase' is zero, The 'high to low' setting of an allpass appears visually to always have a one sample delay from swinging negative before reaching the peak. however, my code seems to be out by one sample at o desired phase and closer as the phase increases, maybe this is due to not seeing a true peak before the visible positive one which would be corrected with, say, 0.5 samples?
i've added a diagram with samples in green lerped in black and the red showing a deviation in the continuous 'infinite' sample rate. I guess also the amplitude envelope could peak along the rise rather than at a visible corner.
maybe my bit of code is ignoring the time it takes for nyquist to reach peak amplitude at the start of the response and this is not always 1 sample despite appearing that way on an fft or diagrams of group delay i've seen.
I may also have simply messed up with all the amounts of PI, wish flowstone would just give a pure answer to trig ops without any conversions, would be easier to control what happens.
- dentistguba
- Posts: 13
- Joined: Thu Jan 10, 2013 8:39 pm
Re: Dispersion Filter
I just checked again and it seems the issue is really that the allpass gain lags behind the phase input by a small amount which gets larger as it increases, this means that the correction is right for the given phase shift but overcompensates for the actual result - cutting into the constant one sample delay. Could it be that my code would be spot on for analog but there is some correction in xoxos' code which I've missed? (like how naive low pass filters can miss the cutoff point).
I think the equation i found left out the prewarping so I will add that now and it may fix it.
I think the equation i found left out the prewarping so I will add that now and it may fix it.
- dentistguba
- Posts: 13
- Joined: Thu Jan 10, 2013 8:39 pm
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 55 guests