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
Cheap non-linear zero-delay filters
Goto page Previous  1, 2, 3 ... 8, 9, 10 ... 14, 15, 16  Next
Richard_Synapse
KVRist
- profile
- pm
PostPosted: Thu May 24, 2012 4:45 am reply with quote
Just for the lulz...here's a first simple model I cooked up using mystrans method. It's a 2-pole lowpass filter with nonlinear feedback, inspired by the Korg MS stuff.

This filter has some sweet spots (I really dig the sound of its self-oscillation), but it needs work. The differential equations I used as a starting point are:

dy1/dt = f*(in - y1 - g(r*y2))
dy2/dt = f*(y1 - y2 + g(r*y2))

where 'r' is resonance, 'g()' is the nonlinear function. Certainly additional equations are needed to improve the sound, I keep it as simple as possible. Any suggestions welcome!

The code:
Quote:

// evaluate the non-linear gain
double t = tanhXdX(r * yl2);

// solve the linearized system
double denom = f* f * r* t + f *(f + 1) + f + 1;
double y1 =(-f* r *t *yl2 + (f + 1)* yl1 + f* (f + 1)* in) / denom;
double y2 = (f* yl2 + yl2 + f * yl1 + f* f* in) / denom;

// update state
yl1 += f*2 * (in - y1 - r*t*y2);
yl2 += f*2 * (y1 + r*t*y2 - y2);
----
Synapse Audio Software - www.synapse-audio.com

Last edited by Richard_Synapse on Thu May 24, 2012 7:13 am; edited 1 time in total
^ Joined: 19 Dec 2010  Member: #245936  
Ichad.c
KVRist
- profile
- pm
- e-mail
- www
PostPosted: Thu May 24, 2012 5:06 am reply with quote
Damn you Richard - that was exacly the structure that I was desperately trying to solve, you shouldn't make it look so easy Crying or Very sad Crying or Very sad Crying or Very sad

I got stuck on the notion that there is dual feedback from the output - thus 2 diffent denominators! Mad

Now my head really hurts.
^ Joined: 08 Feb 2012  Member: #274678  Location: South - Africa
karrikuh
KVRist
- profile
- pm
PostPosted: Thu May 24, 2012 6:27 am reply with quote
Richard_Synapse wrote:
This filter has some sweet spots (I really dig the sound of its self-oscillation), but it needs work. The differential equations I used as a starting point are:

dy1/dt = f*(in - y1 - r*g(y2))
dy2/dt = f*(y1 - y2 + r*g(y2))

That's exactly the 2-pole filter I use in my synth!

Richard_Synapse wrote:

// evaluate the non-linear gain
double t = tanhXdX(r * yl2);


This is not strictly in accordance with your equations. Your code realizes a filter with the resonance gain r pre-saturator, while your equations have r at the output of g().
Richard_Synapse wrote:
// solve the linearized system
double denom = f* f * r* t + f *(f + 1) + f + 1;
double y1 =(-f* r *t *yl2 + (f + 1)* yl1 + f* (f + 1)* in) / denom;
double y2 = (f* yl2 + yl2 + f * yl1 + f* f*  in) / denom;


You don't need solve the whole feedback loop for both integrator outputs. Instead, just solve for y2, then all inputs for the first lowpass stage are available and you can compute y1 in the traditional way (probably cheaper).
----
Official Charlatan home page: www.blaukraut.info
Official Charlatan thread on KVR
^ Joined: 06 Apr 2008  Member: #177841  
Richard_Synapse
KVRist
- profile
- pm
PostPosted: Thu May 24, 2012 7:15 am reply with quote
karrikuh wrote:
This is not strictly in accordance with your equations. Your code realizes a filter with the resonance gain r pre-saturator, while your equations have r at the output of g().


True- fixed Smile

karrikuh wrote:
You don't need solve the whole feedback loop for both integrator outputs. Instead, just solve for y2, then all inputs for the first lowpass stage are available and you can compute y1 in the traditional way (probably cheaper).


Yeah, I just copy+pasted straight from Maxima.

Richard
----
Synapse Audio Software - www.synapse-audio.com
^ Joined: 19 Dec 2010  Member: #245936  
Robin from www.rs-met.com
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Thu May 24, 2012 10:03 am reply with quote
karrikuh wrote:
Richard_Synapse wrote:
This filter has some sweet spots (I really dig the sound of its self-oscillation), but it needs work. The differential equations I used as a starting point are:

dy1/dt = f*(in - y1 - r*g(y2))
dy2/dt = f*(y1 - y2 + r*g(y2))

That's exactly the 2-pole filter I use in my synth!


so, where does this system come from? is this an RLC-circuit or mass-spring-damper system (which are, if i'm not mistaken, mathematically the same thing)?
----
^ Joined: 08 Mar 2004  Member: #15959  Location: Berlin, Germany
karrikuh
KVRist
- profile
- pm
PostPosted: Thu May 24, 2012 10:31 am reply with quote
Robin from www.rs-met.com wrote:
karrikuh wrote:
Richard_Synapse wrote:
This filter has some sweet spots (I really dig the sound of its self-oscillation), but it needs work. The differential equations I used as a starting point are:

dy1/dt = f*(in - y1 - r*g(y2))
dy2/dt = f*(y1 - y2 + r*g(y2))

That's exactly the 2-pole filter I use in my synth!


so, where does this system come from? is this an RLC-circuit or mass-spring-damper system (which are, if i'm not mistaken, mathematically the same thing)?

I got it from Antti Houvilainen's thesis:
http://www.dsprelated.com/showabstract/139.php
(Figure 4.4, page 28 )
----
Official Charlatan home page: www.blaukraut.info
Official Charlatan thread on KVR
^ Joined: 06 Apr 2008  Member: #177841  
Robin from www.rs-met.com
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Thu May 24, 2012 10:46 am reply with quote
cool. now that i'm finished with Vadim's book, i needed something new to read anyway. THX. Very Happy
----
^ Joined: 08 Mar 2004  Member: #15959  Location: Berlin, Germany
Richard_Synapse
KVRist
- profile
- pm
PostPosted: Thu May 24, 2012 12:05 pm reply with quote
I got the rough concept from the Stinchombe paper about the MS10/20. It's not really a MS filter though, the resemblance is just that the output is clipped then fed back into the first capacitor. In the ladder filters the output gets fed back to the input, but this doesn't seem to work well for a two-stage 12dB filter (maybe there's a way but I haven't seen it yet).

Richard
----
Synapse Audio Software - www.synapse-audio.com
^ Joined: 19 Dec 2010  Member: #245936  
mystran
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Thu May 24, 2012 12:14 pm reply with quote
Richard_Synapse wrote:

karrikuh wrote:
You don't need solve the whole feedback loop for both integrator outputs. Instead, just solve for y2, then all inputs for the first lowpass stage are available and you can compute y1 in the traditional way (probably cheaper).


Yeah, I just copy+pasted straight from Maxima.

Richard


You can copy-paste the solution for one output, then remove that output from the set of equations/unknowns and resolve. This will give you rest of the unknowns in terms of what's already solved.

That typically results in less work. It's not really ideal, and I already have a method for generating better code, but it's still very much work-in-progress. Razz
----
<- my plugins | my music -> @Soundcloud
^ Joined: 11 Feb 2006  Member: #97939  Location: Helsinki, Finland
Robin from www.rs-met.com
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Thu May 24, 2012 12:16 pm reply with quote
Richard_Synapse wrote:
I got the rough concept from the Stinchombe paper about the MS10/20.


ah - OK, thanks. yes, this must then be the same filter as in Antti's thesis.
----
^ Joined: 08 Mar 2004  Member: #15959  Location: Berlin, Germany
mystran
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Thu May 24, 2012 12:32 pm reply with quote
Richard_Synapse wrote:
I got the rough concept from the Stinchombe paper about the MS10/20. It's not really a MS filter though, the resemblance is just that the output is clipped then fed back into the first capacitor. In the ladder filters the output gets fed back to the input, but this doesn't seem to work well for a two-stage 12dB filter (maybe there's a way but I haven't seen it yet).


For two sided RC model:


  V1 -> ---R---o----C--- <- V2
               |
               v Vout


We observe that voltage over the resistor Vres = V1-Vout and voltage over the capacitor is Vout-V2 (ie Vout = Vcap + V2, Vres = V1-Vcap-V2), so we have

footnote: I'm "measuring" voltages over the components "backwards" from right to left; this is safe as long as it's consistent and saves a bunch of negations.. it makes perfect sense if you think of Vres and Vcap as voltage drops over the components

 dVcap/dt = (V1-Vcap-V2)/(R*C)
  Vout = Vcap + V2


Discretize (for example) as:

 yOut = vCap + f*(v1-yOut-v2) + v2
 vCap += 2*f*(v1-yOut-v2)


Observe that in the special case of v2 = 0, this is just the usual low-pass. In the special case of v1 = 0, the output is v2+lp(-v2) which for one-pole is clearly valid high-pass and "vCap" here is just the voltage over capacitor (ie Q/C where Q is the charge stored) and no-longer a ground-referenced absolute voltage (yOut is still ground referenced).
----
<- my plugins | my music -> @Soundcloud
^ Joined: 11 Feb 2006  Member: #97939  Location: Helsinki, Finland
Ichad.c
KVRist
- profile
- pm
- e-mail
- www
PostPosted: Thu May 24, 2012 1:22 pm reply with quote
Richard_Synapse wrote:
.. the resemblance is just that the output is clipped then fed back into the first capacitor.
Richard


That depends on on which Korg chip your talking about; for the people who haven't yet read Tim's excellent paper, the first version was a Sallen-Key design, the second was an OTA design. The Sallen key had diode limiting in the feedforward path, and the OTA version had the diodes in the feedback path.

In my honestly moronic opinion - your filter looks closer to a Sallen-Key than an OTA. So maybe - for variation - you could move the TanhXdX, and maybe even add the asymmetrical resonace that Tim refers to.

Andrew
^ Joined: 08 Feb 2012  Member: #274678  Location: South - Africa
Richard_Synapse
KVRist
- profile
- pm
PostPosted: Thu May 24, 2012 1:53 pm reply with quote
Ichad.c wrote:
Richard_Synapse wrote:
.. the resemblance is just that the output is clipped then fed back into the first capacitor.
Richard


That depends on on which Korg chip your talking about; for the people who haven't yet read Tim's excellent paper, the first version was a Sallen-Key design, the second was an OTA design. The Sallen key had diode limiting in the feedforward path, and the OTA version had the diodes in the feedback path.

In my honestly moronic opinion - your filter looks closer to a Sallen-Key than an OTA. So maybe - for variation - you could move the TanhXdX, and maybe even add the asymmetrical resonace that Tim refers to.

Andrew


Yeah, I built the Sallen Key version in PSpice, the OTA version I haven't looked at yet. Soundwise the SK version is a matter of taste, however, I only like the self-resonance so I ended up with a mix of both structures. When a signal is driven through the Korg35 chip, it seems to affect both the cutoff and resonance, which is truely weird. Not really a fan of that...also an authentic model of that will be a lot harder to derive.

Richard
----
Synapse Audio Software - www.synapse-audio.com
^ Joined: 19 Dec 2010  Member: #245936  
Ichad.c
KVRist
- profile
- pm
- e-mail
- www
PostPosted: Thu May 24, 2012 2:08 pm reply with quote
Richard_Synapse wrote:
.. so I ended up with a mix of both structures.
Richard


Now that's the beauty of digital, we decide what's cool or not Smile
^ Joined: 08 Feb 2012  Member: #274678  Location: South - Africa
aciddose
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Thu May 24, 2012 4:07 pm reply with quote
they're both the same sallen-key structure. the ota version just uses otas instead of transistors for the trans-conductive elements and does away with the a-symmetrical buffer. the result is that the revised version (in the ms-20 r2) is all odd-harmonic, while the ms-10, ms-10 r1, and ms-20 are balanced even-harmonic with the clipper in the signal path.

the best filter of all is the transistor based without clipping in the feedback path.

http://soundcloud.com/aciddose/resszor
http://soundcloud.com/aciddose/resszorb

(pad mixed in, only the ramp + res sound is of interest.)

the frequency modulation is due to direct modulation of the current through the transistors. the effect is identical to subtracting the signal from the base voltage - you're just changing the VBE.

the feedback is NOT modulated. there is a significant dc offset and the clippers are applied to the dc-biased signal. this results in the clipping having more effect on one side than the other. solution? apply an a-symmetrical clipping.

http://soundcloud.com/aciddose/ressy-pulse
^ Joined: 07 Dec 2004  Member: #50793  
All times are GMT - 8 Hours

Printable version
Page 9 of 16
Goto page Previous  1, 2, 3 ... 8, 9, 10 ... 14, 15, 16  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