Circuit modeled filter, how to?

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

aciddose wrote:do not be a fool, i said parameters. have you ever used the diode equation? it's a simple function, the one i posted in the source, with the constants calculated a particular way.

"If you do a one pole low pass filter, then put the output in dsp land into a waveshaper you will not get the same result as an unbuffered lowpass filter and waveshaper - period. Look at the graphs"

you did look at my source, didnt you? this is the same output as the circuit. it is exactly the same.
I did look at your code, but why are you bringing it up, I wasn't talking about your code. Do you like talking about your code? I am talking about what I said which you claimed was wrong. What I said stands just fine, and was an example to point out that people that don't know circuit stuff had better learn some to do some models. Do you need me to point it out another way or are you with me yet?

Andrew

Post

what were you talking about then? you've just said that "if you put the output into dspland and blah blah".. well my code does exactly that in dspland and the output is exactly the same.

either you're clearly wrong and refusing to admit that, or you're on mushrooms. i'm leaning toward the mushrooms at this point i think? :help:

Post

Maybe Antti's moog filter implementation paper might be helpful for someone?
http://dafx04.na.infn.it/WebProc/Proc/P_061.pdf
You can also search for it on scholar.google.com and find several relevant articles that cite his.

Post

This is off-topic with regards to OP but then again since this thread is mostly meta anyway, I thought I'd voice my opinion.

I for one don't actually bother with modeling anything for the purpose of modeling anything. But it turns out that often times it has been rather useful to analyze circuits in order to figure out why they sound nice, and someone might say that some things I've written (and hopefully to be released in the near future... yeah right) have turned out to look (and maybe sound, I honestly don't know) a lot like existing well-known circuits.

On the other hand, while my oscillators and filters have drawn inspirations from analog, I never seen a point in trying to replicate something exactly. Rather, I find it much more important to listen to the results, see what can be changed to get something else, and judge by ears what sounds best.

For me, the interesting thing is how to combine the best parts of analog and digital. If for example I've based my oscillators on the concept of saw-core VCO, that doesn't mean it's wave-shape isn't digitally perfect or that I shouldn't stack 8 saws. If they drift, that doesn't mean they shouldn't stay in tune.

Similarly modeling an analog filter might save tons of times compared to designing one from scratch (having kinda tried both ways), but IMHO that doesn't mean one shouldn't see if the result can be tweaked to sound "better" as defined by subjective taste. For example, I might have been using a transistor ladder as a basis of my filter, yet that doesn't stop me from hand tuning the embedded wave-shapers for a compromise between subjective taste, aliasing, and CPU wasted on oversampling. Is the exact type of saturation used in some original really all that important (unless you are trying to sell as an exact model, which I find kinda stupid, 'cos if somebody seriously wants a Model D they should buy a Model D).

My stuff currently sounds like this (dry single-part extract from a "song" I kinda finished earlier today). Does it sound analog? Who cares. Does it sound good? Judge yourself, as I can only speak for my own ears (and I ain't sound designer, plus I'm probably driving the filter too hard). But my point is, I personally like how my code sounds, and that's all that's important to me (well until and if I start trying to sell that stuff ofcourse, so please tell me if it sound totally crap, and yeah I know the transient response might not be exactly right yet).

My point is, modelling can get you interesting things. But I wouldn't consider the analog world the absolute truth, and personally I've wasted some 4 years now trying to come up with something that sufficiently pleases my own ears that I've even considering that I might release that stuff one day. Most of that time has been spent listening, playing, listening, playing, finetuning, playing... and most definitely some code-snippets might have helped me when I started, but in the end I had to learn to derive it all myself, 'cos without the damn math it's seriously hard to figure what should be tweaked to get what kind of difference.

The funny thing is, some 4 years ago, I could barely understand what a transistor is. Now, when I looked at the picture in the OP, it took me something like 4 seconds to figure that it's your basic 4-pole with global feedback, with an OTA design for voltage control. Mind you I've soldered maybe 20 components in my whole life, so I can't say I know anything about electronics for real, but at some point I figure looking into schematics might be a good idea when working with DSP. Haha.

Just my well-meaning 2 cents into this rather heated discussion.

Post

mystran,
to me your demo sounds fine, nice filter with a certain "fatness character".

for the rest of the discussion, I think there is no need to argue/worry.
Actually you can go different ways to rome:
:)

acd describes the method to start at a higher level and model it down to the detail that will be sufficiant to get the sound very close.

andys approach on the other hand is simply starting at lowest level - a true emulation, and then lets decide you which parts you cut out to save some cpu cycles.

I think both ways can lead to nice results.
Image

Post

aciddose wrote:d = a - iclamp(b)
b += d * c
I do not know if this supports your agenda or not, but this code is clearly correct if you think about capacitors this way: they store energy and give it back, so the stored energy should be clamped at a later time since capacitor will start to discharge after external energy runs out. On the other hand, theoretically speaking, I may speculate that you'll probably need to do it the following way:
d = iclamp(a - b)
b += d * c
Since I do think that diode should clamp the energy even if the capacitor is not charged. In your example high-passed output leaves scheme unchanged.
Image

Post

aciddose wrote:what were you talking about then? you've just said that "if you put the output into dspland and blah blah".. well my code does exactly that in dspland and the output is exactly the same.

either you're clearly wrong and refusing to admit that, or you're on mushrooms. i'm leaning toward the mushrooms at this point i think? :help:
You still don't understand what I am saying so let me break it down for you. I'll post the circuit again:

Image

When someone new to analog modeling see this, they might think oh, I'll model that by:

lp += g*(input - lp);
output = diodewaveshaper (lp);

where:
g = 1 - exp (-2*pi*cutoff/samplerate);
and diodewaveshaper () is your favorite approximation of the voltage to voltage transfer function of the diode pair.

which we both know does not model the top circuit. This is actually a model of the bottom circuit, where the diodes are buffered from the low pass filter. Do you agree with this?

Please don't go getting confused by bringing up anything else, just answer the simple question. If this is still too hard I will break it down to even smaller parts.

Andrew

Post

On the other hand, this variant looks even better to me:
d = iclamp( a - b )
b += ( d - b ) * c

("a" being input and "d" being output) But of course, a full-blown non-linear scheme simulation will produce more precise results - emulating system of equations with sequential processing is not possible in the general case, otherwise it would not be a system.

This variant:
d = iclamp( a + b )
b += ( d - b ) * c

will boost a bit of lows.
Last edited by Aleksey Vaneev on Tue Feb 19, 2008 4:39 pm, edited 1 time in total.
Image

Post

andy_FX wrote: which we both know does not model the top circuit. This is actually a model of the bottom circuit, where the diodes are buffered from the low pass filter. Do you agree with this?
Your point is valid. To get anything like the top circuit, one needs to move the saturation into the integrator, which does make it a potential pipeline stall, though whether this actually uses notably more CPU depends on the saturation used, and the possibilities for parallel calculation and what not.

I would argue, that for the sound of the circuit model, the position of the saturation function(s) has a much greater effect than the actual saturation used. So if CPU use is of importance, I'd rather go with a simple waveshaper within the loop, than some exponential thingie outside.

Personally I've used something like (and I'm speaking from my head so might make mistakes):

lp += g*waveshape(in - lp);

Not really all that much more complex, but gives you the "asymmetric" behavior, and sounds rather more interesting even with something as simple as your basic third-order symmetric saturation polynomial.

Now (hopefully getting closer to the original topic) doing a 4-pole with feedback with poles (essentially) like the above, does actually sound kinda nice. The character is different from the classic transistor ladder, but depending on taste, not necessarily for the worse.

Moving the coefficient within the waveshaper (waveshape(g*(in-lp))) is another possibility which has the effect of making the thing more non-linear the higher the cutoff, but in steadystate that naturally only make a difference in the input/output gains required for specific response.

Yet another interesting variation is shaping the new state (which again sounds totally different, and IIRC I didn't like this one for general purpose filter):

lp = waveshape( lp + g*(in-lp) );

Oh, and the distortion possibilities don't stop there.. one can do stuff like:

lp = waveshape( (1-g)*lp ) + g*in;

...

Everyone of those sounds different. There are probably more. And most definitely andy has a valid point that if one is trying to model a specific circuit, then it is necessary to analyze where and how the non-linearities make their effects, instead of just dropping some shaping in some random place (and the most boring two of those random places being input and output).

Anyway, I thought I'd share a practical advice when one goes fooling around with non-linearities in various places: In many cases a lot of annoying problems can be avoided by making sure that any waveshapers one goes poking side feedback loops have a gain strictly less than 1 (or abs(1) at least), in other words:
abs(waveshape(x)) <= abs(x), for any x.

That way when one has a stable linear system, there are less (usually some though) places where non-linearities can make it unstable (or cause it to just hit the "rails" and stay there). If you still get some nasty behavior, it's then easier to figure out what went wrong and why.

I won't go trying to draw circuits for the above examples, 'cos I personally don't care all that much about modeling specific circuits (I care about the ideal functions that aciddose(?) spoke of), but just wanted to point out to any newbie (if any) reading this that even with a single, simple soft-saturating waveshaper, there are tons of places to poke it in to get lots of different types of distortion.


Oh and finally I'd like to mention that oftentimes to get something sound "fatter" it might help to add some noise somewhere, and just like with non-linearities, you get different effects when you make different things noisy (and yes, I do mean per-sample noise modulation!). If a given circuit to be modeled has specific components/signal-paths that tend to be specifically noisy, then those might well have an important effect on it's sound character.

Post

mystran wrote:
Your point is valid. To get anything like the top circuit, one needs to move the saturation into the integrator...
So for someone that doesn't know circuits how to they know to move the waveshaper into the integrator as you have correctly pointed out? What happens when the circuit is slightly more complicated?

Andrew

Post

"What happens when the circuit is slightly more complicated?"

well, that is the thing. there is no "more complicated" circuit. all you need to understand are the basic rules of I, R and C. L is actually just a product of the previous three.

the example i posted with the function applied to the output during current calculation actually is the most correct and also most processing optimal. you can parallel process mine while the others you can not. the clamp function should be processed at the end of each stage, actually _after_ the output exactly as certain individuals are arguing is incorrect and then stored until the next sample.

most importantly you'll not be suffering from delay in that calculation beyond the single sample as you will in the others.

you must simply look at these things with a more open mind.. you can use the inverse of the saturation function (current) or the function itself (voltage) and you can apply these functions in several places and optionally at many points in the function. you simply haven't been noticing that the function i posted so long ago is indeed exactly what you're arguing is incorrect. the only difference is that we do not take the output from that point, we store it.

ultimately, it would still be correct to take the output at that point if you were to apply the inverse function to return linearity later in the chain.

n == (n^2)/n

Post

aciddose wrote:"What happens when the circuit is slightly more complicated?"

well, that is the thing. there is no "more complicated" circuit. all you need to understand are the basic rules of I, R and C. L is actually just a product of the previous three.
If these rules are important to learn how to model circuits then how do I learn these I, R and C rules you talk about? (I'm being a circuit newby can you tell?)

Andrew

Post

wouldn't surprise me in the least if you were serious, andrew.

try google, and get off my lawn.

http://www.vias.org/feee/wrapnt_dc5.html (one of thousands of similar tutorials)
(sorry if this is too hard for you, it depends upon the assumption you already know your ABC's and 123's from preschool)

Post

aciddose wrote:wouldn't surprise me in the least if you were serious, andrew.

try google, and get off my lawn.

http://www.vias.org/feee/wrapnt_dc5.html (one of thousands of similar tutorials)
(sorry if this is too hard for you, it depends upon the assumption you already know your ABC's and 123's from preschool)
So I have to read some circuit tutorials to work this stuff out, is that what you are saying? How about the ones I posted already, you think they will help? Ok, so we will need to learn some basic circuit theory, and some probably something about laplace space you think? How about anything to do with unit delays and z-plane stuff?

Excellent, all sounding good. Now, how about some practical computer tools that I could use? Do you know anything that is cross platform and free?

Andrew

Post

www.gnu.org

"Ok, so we will need to learn some basic circuit theory, and some probably something about laplace space you think? How about anything to do with unit delays and z-plane stuff?"

no, no, no, no.

you do not need to learn any of that. only if you want to be accurately "modeling" components in the circuit or UNDERSTANDING why things work they way they do. all you need to do in order to correctly model signal flow and macro-model each section of a circuit is a function generator and scope, you can use any spice simulator for this if you want to use schematics as your sources.

ultimately though, you do not even need that. all you need to do is look at the input and output, and understand the conditions under which the signal is being processed. this is called black-box modeling. this is how i wrote the source for your r/c/clamp circuit.

what you DO need is a basic high-school education about linear algebra, trigonometry and functions/graphing to implement anything in code at all. if you're dumb enough to lack the ability to learn the basics of dsp, why the hell would you be trying to do "circuit modeling".

Post Reply

Return to “DSP and Plugin Development”