RobinSchmidt / RS-MET

Codebase for RS-MET products (Robin Schmidt's Music Engineering Tools)
Other
56 stars 6 forks source link

chaotic algorithms and (in)stability #300

Open RobinSchmidt opened 4 years ago

RobinSchmidt commented 4 years ago

How about visualizing chaos?

hmm...how? i guess, i could draw mandelbrot-sets and bifurcation diagrams and the likes - is that what you mean?

I dunno what I mean.

May be unrelated: Can you improve my chaotic algorithms which I use to create analog-esque filters? Can you solve explosions? [Do you have any mathematical tools or the brain power for this?] Essentially parameters need to be limited based on samplerate. (or somehow antialiased?)

Originally posted by @elanhickler in https://github.com/RobinSchmidt/RS-MET/issues/298#issuecomment-589314328

RobinSchmidt commented 4 years ago

so - with explosions, you mean your algo becomes unstable for certain settings? how is this related to the samplerate? is it such it tends to become more unstable when the sample-rate is lowered?

elanhickler commented 4 years ago

The less samplerate the less you can push to high frequencies with self-oscillation before you get ugly noise.

elanhickler commented 4 years ago

Oh, and it's ok to limit frequency or other parameters, the problem is it's very fiddly to limit the parameters per possible sample rate. I'd like the filter to be able to run at any sample rate and even low sample rate in order to get a lo fi sound.

elanhickler commented 4 years ago

I spoke to someone who has done lots of analog filter modelling about my chaotic algorithms. He said it's possible to solve the issue.

so, the filters whose code you posted on pastebin suffer from the problem of having a fictitious unit delay in the feedback, that means your feedback is not (obviously) instantaneous, and that makes the filter unstable at lower sample rates. This also means the sound changes slightly at different sample rates, especially when the cutoff is high. This can probably be fixed given their simple formulation, but requires some magic. Taking care of a filter algorithm such as those you showed me is probably in the 1-2 weeks ballpark".

I also can't afford his prices at the moment and sounds like it's some serious work. So if you really want to you could take a crack at it, but I'll be happy just setting up an internal samplerate / resampler so that the algorithms won't explode so easily and also sound the same regardless of external samplerate.

RobinSchmidt commented 4 years ago

ah - the unit delay in the feedback path. i wanted to suggest something from ODE solvers: even if the ODE (system) itself is stable, the numerical solution procedure can explode. this is sometimes called numerical instability. and it gets worse when your solver's stepsize gets larger (i.e. the samplerate goes down). these are probably two equivalent viewpoints on the same thing.

one ad-hoc idea: if the instability/explosion starts out as a parasitic oscillation at the nyquist-frequency (i sometimes observed instabilities manifesting themselves this way), it may (or may not) be helpful to insert a nyquist blocker into the feedback path. this is really just very ad-hoc. this idea (if the filter is y[n] = 0.5*(x[n]+x[n-1])) can probably also be reframed in terms of using trapezoidal integration rather than Euler steps...but this is really just some off-the-cuff talk now - don't take it too seriously

RobinSchmidt commented 4 years ago

if the instability/explosion starts out as a parasitic oscillation at the nyquist-frequency (i sometimes observed instabilities manifesting themselves this way)

here this is happening for a PDE in the spatial domain:

https://en.wikipedia.org/wiki/Finite_difference_method#Comparison https://en.wikipedia.org/wiki/File:HeatEquationExplicitApproximate.svg

elanhickler commented 4 years ago

so to implement that I just need to have a 2 sample buffer, record the output each sample, and basically average the results of the previous sample and the next sample as the output?

RobinSchmidt commented 4 years ago

yes - indeed - but as said, the idea may very well turn out to be crap. but maybe worth a try nevertheless. if you can point me to the mentioned code at pastebin, i could take a closer look myself

elanhickler commented 4 years ago

Robin, a few UI crashes were fixed in your code base, you should use all of my codebase for building the plugin: https://gitlab.com/Hickler/Soundemote read the readme, everything is there that you need, make sure everything is latest.

project: Soundemote\AudioPlugins\FlowerChildFilter\FlowerChildFilter.jucer

load up the vst as an effect, use on a sawtooth, play around with the plugin... hmm... well I think I solved all the explosions by limiting the parameters per possible samplerate... Find a filter you like and disable my parameter limiting by commenting out some if statements, you'll see something like this on most filters. A few filters don't have that as they explode but don't sound bad. You can still try to improve those, it gets a bit noisy/grainy.

image