Plug-ins, Hosts, Apps,
Hardware, Soundware
Developers
(Brands)
Videos Groups
Whats's in?
Banks & Patches
Download & Upload
Music Search
KVR
   
KVR Forum » DSP and Plug-in Development
Thread Read
Filters to Nyquist?
Goto page 1, 2, 3  Next
guitarbro
KVRist
- profile
- pm
- www
PostPosted: Sun Sep 12, 2010 8:35 pm reply with quote
This is for Synthedit but applies to DSP in general.

Most filters go to quarter sample rate but
are there any stable filters that can go to Nyquist?
i have tried the Tarrabia filters but they are unstable at low frequencies.
^ Joined: 03 Dec 2009  Member: #220947  Location: muskegon MI
antto
KVRAF
- profile
- pm
- www
PostPosted: Sun Sep 12, 2010 10:23 pm reply with quote
erm, not to "quarter sample rate" like some rule
but yes, lots of filters need oversampling to handle the full range
for example an SVF needs 4x
from the SE filters i think just the moog is oversampled, but IIRC it doesn't have good tuning (which means at a different sampling rate with the same cutoff the resonanse will be somewhere else, which is not good)
----
It doesn't matter how it sounds..
..as long as it has BASS and it's LOUD!
^ Joined: 04 Sep 2006  Member: #118997  Location: 127.0.0.1
mystran
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Sun Sep 12, 2010 11:27 pm reply with quote
Any general digital IIR filter can go up to Nyquist quite happily, although the response near Nyquist tends to get a bit ugly at least when using bilinear transform.

The only structures that tend to have problems are those that have been converted from the analog domain by preserving the topology, yet are forced to add some extra delay to avoid delay-free feedback loops; SVF and Moog-ladders being the most famous. The reason these are still used in synths is that they happen to have some other nice properties, for example with regards to time variation and/or coefficient calculation... and it helps if you want to mimic analog non-linearities at which point you need some oversampling anyway.

Not sure what the Tarrabia filters would be specifically, but some structures (direct forms for example) are quite sensitive to numeric precision which only gets worse at low-frequencies and high-Q. Usually not an issue with 2nd order filters in audible range (even with single-precision) though.
----
<- my plugins | my music -> @Soundcloud
^ Joined: 11 Feb 2006  Member: #97939  Location: Helsinki, Finland
guitarbro
KVRist
- profile
- pm
- www
PostPosted: Sun Sep 12, 2010 11:35 pm reply with quote
Like i said stable meaning relatively constant response throughout.
^ Joined: 03 Dec 2009  Member: #220947  Location: muskegon MI
aciddose
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Sun Sep 12, 2010 11:55 pm reply with quote
actually a svf dosn't require 4x, it requires 2x with feedback compensation. actually to make it go fully to nyquist with zero feedback would require infinite time-slices unless i'm mistaken. that's the thing to note - it's stability depends upon how much feedback is applied. with 100% feedback it becomes stable at nyquist.

xhip's filters go to nyquist using this method.

3x and 4x decrease the feedback required at high frequencies, but at the cost of increased computation.

non-linearity doesn't require oversampling if implemented correctly and if dropped off at higher frequencies. audibly the results are the same, but without considerable aliasing that leaving the shaping at full magnitude would result in. (when i say "correctly", i mean in the svf at least the shaping is not applied to the signal at the input, making it dependent only upon filter feedback/frequency)

a good example is a model of a diode and capacitor in parallel in a RC.D circuit.

[A] [resistor] [B] -> [C] [cap] + [D] [diode] -> [ground]

the RC circuit is a simple lossy integrator

B = (A - C) / resistor;
C += B;

the RD.C circuit is as follows:

B = inv_diode_function(A - C) / resistor;
C += B;
D = C;

inv_diode_function can be = max(0, n^2) for a very simple example. the actual inverse diode function would be required for accuracy.

i'll spell it out for you incase you're not catching on: to implement the non-linearity at the input of the OTA in a svf, we end up with the same circuit as outlined above. so to model that, apply the inverse diode function to the delta for input to the integrators in the svf.

considering ordinary unbiased OTAs, a very good approximation is inv_diode_function(n) = n * (0.9 + 0.1 * n*n)
Last edited by aciddose on Mon Sep 13, 2010 3:27 am; edited 1 time in total
^ Joined: 07 Dec 2004  Member: #50793  
Z1202
KVRist
- profile
- pm
PostPosted: Mon Sep 13, 2010 12:41 am reply with quote
aciddose wrote:
actually a svf dosn't require 4x, it requires 2x with feedback compensation. actually to make it go fully to nyquist with zero feedback would require infinite time-slices unless i'm mistaken.
Not really: http://www.native-instruments.com/en/products/producer/reakt or-5/overview/core-technology/dsp-articles (the first and the third articles are of interest).

Regards,
{Z}
^ Joined: 11 Apr 2002  Member: #2472  
aciddose
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Mon Sep 13, 2010 1:07 am reply with quote
Z1202 wrote:
Not really


those articles just outline some of the stuff i've already posted. nothing there suggests any way to eliminate the need for feedback - also i said "zero feedback", i meant "zero oscillation" meaning "full feedback".

while it's possible to add all kinds of computation to stabilize a svf, i'm talking about using only the basic svf and adjusting the coefficients to stabilize it.

(when it comes to musical applications, the very simple 2x oversample and feedback adjustments perform better making them more practical with limited cpu power)

what were you referring to when you say "not really" ?
^ Joined: 07 Dec 2004  Member: #50793  
Z1202
KVRist
- profile
- pm
PostPosted: Mon Sep 13, 2010 1:19 am reply with quote
aciddose wrote:
Z1202 wrote:
Not really


those articles just outline some of the stuff i've already posted. nothing there suggests any way to eliminate the need for feedback - also i said "zero feedback", i meant "zero oscillation" meaning "full feedback".

while it's possible to add all kinds of computation to stabilize a svf, i'm talking about using only the basic svf and adjusting the coefficients to stabilize it.

(when it comes to musical applications, the very simple 2x oversample and feedback adjustments perform better making them more practical with limited cpu power)

what were you referring to when you say "not really" ?
Maybe I misunderstood your reference to the feedback, I thought you refer to feedback prewarping to compensate the frequency response distortion. I don't understand how can one eliminate feedback in the SVF, it's a part of the SVF design by definition. When I said not really, I meant you can build an SVF which works up to Nyquist cutoff without zero-length time slices. No prewarping is needed either, except for the usual cutoff prewarping for the BLT.

Regards,
{Z}
^ Joined: 11 Apr 2002  Member: #2472  
aciddose
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Mon Sep 13, 2010 1:43 am reply with quote
yeah.. there is a way, there are multiple ways with various trade-offs. all of them require modification of the code of the svf though by adding additional elements and thus computation - which is what i don't like about them.

i was just talking about the minimum requirements to make the filter stable without modifying it.

edit: i should clarify also, my definition of stable is as posted below - obviously using the minimum possible method results in the resonance of the filter being higher than it should be. in most cases it isn't a problem, but if it is for you the solution is to either use more timeslices or a more complex method of stabilization which doesn't introduce such issues.
Last edited by aciddose on Mon Sep 13, 2010 1:56 am; edited 1 time in total
^ Joined: 07 Dec 2004  Member: #50793  
mystran
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Mon Sep 13, 2010 1:51 am reply with quote
guitarbro wrote:
Like i said stable meaning relatively constant response throughout.


"Stable" has a well-defined meaning when it comes to filters, and it means the impulse response has bounded in amplitude, which translates to all the system poles being inside the unit circle on z-plane (with the usual convention of z^-1 to signify a unit delay).

edit: my point is, if you say "unstable" everyone is going to assume it blows up. If you mean "relatively constant response" say "relatively constant response" Wink
----
<- my plugins | my music -> @Soundcloud
^ Joined: 11 Feb 2006  Member: #97939  Location: Helsinki, Finland
Z1202
KVRist
- profile
- pm
PostPosted: Mon Sep 13, 2010 3:44 am reply with quote
aciddose wrote:
i was just talking about the minimum requirements to make the filter stable without modifying it.
I'd say, the above statement makes an assumption about the existence of the discrete implementation of the SVF. The fact that the Chamberlin implementation is the most known one doesn't mean it's the only one. OTOH, if you're talking about optimizing the computations, then I'd agree that it's probably the cheapest one, however if you modulate the parameters at audio rate, then the prewarping computation costs will/may outweigh the benefits of the cheap base implementation. Personally I find the imperfections of Chamberlin implementation (even with prewarping) high enough to justify the usage of a more CPU-intensive implementation, however that's of course a matter of taste.

Edit: BTW we were talking about 2x to 4x oversampling needed with the Chamberlin implementation, which is another factor in CPU usage comparison.

Regards,
{Z}
^ Joined: 11 Apr 2002  Member: #2472  
aciddose
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Mon Sep 13, 2010 4:48 am reply with quote
there is actually no warping preformed.

you just need to limit maximum feedback value dependent upon frequency:

feedback = 3*min(1-q, 1 - 2 * c * (1 - c*0.5))

that's no more expensive that other implementations of the filter, for sure.

edit: sorry, that was wrong, since the coefficient was internally multiplied by two, it needs to be cut in half here. i hadn't realized that optimization was there.

the correct one is:

feedback = 3*min(1-q, 1 - c * (1 - c*0.25))
^ Joined: 07 Dec 2004  Member: #50793  
guitarbro
KVRist
- profile
- pm
- www
PostPosted: Tue Sep 14, 2010 12:39 am reply with quote
mystran wrote:
guitarbro wrote:
Like i said stable meaning relatively constant response throughout.


"Stable" has a well-defined meaning when it comes to filters, and it means the impulse response has bounded in amplitude, which translates to all the system poles being inside the unit circle on z-plane (with the usual convention of z^-1 to signify a unit delay).

edit: my point is, if you say "unstable" everyone is going to assume it blows up. If you mean "relatively constant response" say "relatively constant response" Wink

sorry i actually just started getting in deep with filters, and it does "blow up".

thanks aciddose but what does Resistor mean in that code? is it an separate
equation or a comment?
^ Joined: 03 Dec 2009  Member: #220947  Location: muskegon MI
aciddose
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Tue Sep 14, 2010 2:02 am reply with quote
well if we were dealing with the electronic circuit, the voltage presented at B would be equal to the difference between A, B, divided by the resistance, then that voltage would become a current via the diode equation and capacitor charge, draining the voltage into C and D, followed by recomputing the A,B divided by resistance on and on in circles. there are various ways to get better approximations and several are implemented in spice.

for us however - since we're not interested in currents or exact voltages and times, and we're also working in a discrete time situation (sampled signals) we only need to care that the resistor is some fraction between 0 and 1, that the diode applies a non-linear shape to that result, and that the capacitor acts to integrate the shaped result from the diode.

there are errors here because of sample delay which can be corrected for by oversampling, or by prewarping coefficients if we are willing to give up other accuracies.

for most musical applications however that just doesn't matter and the simplified model is just to assume that a resistor is a scaling/biasing element, a diode is a shaping element and a capacitor is an integrator.

there are cases where a diode can act as an integrator or scaling/biasing element, a resistor can act as a noise source and all sorts of other interesting properties - however unless you're trying to do a circuit model that doesn't matter.
^ Joined: 07 Dec 2004  Member: #50793  
Z1202
KVRist
- profile
- pm
PostPosted: Tue Sep 14, 2010 2:10 am reply with quote
aciddose wrote:
there are errors here because of sample delay which can be corrected for by oversampling, or by prewarping coefficients if we are willing to give up other accuracies.
IMHO quite often the best method to correct the sample delay is to eliminate the problem altogether by using an integration technique corresponding to the bilinear transform, such as trapezoid integration used in http://www.simulanalog.org/statevariable.pdf or (which is more or less equivalent) the method described in the articles I posted a link to earlier. This way you get BLT frequency responses.

Regards,
{Z}
^ Joined: 11 Apr 2002  Member: #2472  
All times are GMT - 8 Hours

Printable version
Page 1 of 3
Goto page 1, 2, 3  Next
Display posts from previous:   
ReplyNew TopicPrevious TopicNext Topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Username: Password:  
KVR Developer Challenge 2012