Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tb303filter peaks in wrong direction in example. How to solve that? #45

Closed
01GOD opened this issue May 31, 2021 · 7 comments
Closed

tb303filter peaks in wrong direction in example. How to solve that? #45

01GOD opened this issue May 31, 2021 · 7 comments

Comments

@01GOD
Copy link

01GOD commented May 31, 2021

Been looking at that filter emulation. Would like to use it, but it has "issues". In the example in the cookbook, it peaks in the wrong direction. Basically on the actual instrument, the filter "screams" when the filter is high, not when it is low. But on the example of the emulation, it does the opposite. Maybe that is why it sounds so horribly "wrong".

Was looking at the code in this project and also the filter emulation code. Wasn't obvious how to solve that. Are there some more parameters in that filter that can be added to the init to make it more usable also?

Thanks in advance.

PS: Was looking at it now. Maybe there is a link between something in the "distortion" or resonance and the co frequency that is wrongly backwards in the filter emulation.

Update: Initial guess after tracing the issue through the source code is that the issue is located somewhere between line 87 and 109 in tbvcf.c in /Sources/soundpipe/modules/tbvcf.c located at: https://github.com/AudioKit/AudioKit/blob/b7b68ce544f5009e12ef439d56130187dedaec25/Sources/soundpipe/modules/tbvcf.c

That or the original it was converted from wasn't right either...or it's simply not compatible with soundpipe as both are currently.

This also seems to possibly be a good reference. Has some info showing that the original emulation (http://www.csounds.com/manual/html/tbvcf.html) had some issues and maybe shows useful info or workarounds.

Here is a VCS3 (also a diode ladder) filter emulation to also reference. Maybe it is better/easier also:
https://github.com/VoggLyster/DiodeLadderFilter/blob/master/Source/PluginProcessor.cpp

@emurray2
Copy link
Member

After some testing and research, I found the same issue you mentioned. This video is a great explanation of how a ladder filter works which I used as a reference: ECE4450 Moog Ladder Filters Analyzed (Analog Circuits for Music Synthesis, Georgia Tech course). At 1:32 in the video, Dr. Lanterman mentions something called the "quadratic roots of unity." This subject seems to be the root cause of this issue. If you take a look at the diagram in the video at this point, there is a parameter, −ωc. This is the cutoff in terms of radians per second. Maybe the Soundpipe implementation on this filter has the parameter as **+ωc instead? I'm not saying this is the cause, but it's starting to make sense.

As you mentioned, the diode latter filter usually peaks when the cutoff frequency parameter is higher. I can confirm that observation by a video of a diode latter filter I found here Oakley Sound TB-303 Diode Ladder VCF. Here's an additional video with the original TB-303 Instrument too Roland TB-303 Bass Line In Action. You can tell when both of the demos turn the cutoff frequency up, the "scream" or "flutter"-- as some call it-- becomes apparent.

In addition to this, I think the resonance and distortion parameters start out really high in the Cookbook example. Therefore, as soon as you try to turn the cutoff frequency down, the system will oscillate out of control. Thankfully, something shuts off the audio to save my ears.

I think you are doing the right thing and looking in the right place with the Soundpipe code. That is where all the DSP code for the filter is. I'm not sure yet if adding more parameters would help, but I think I will dig deeper and look at it some more. That way, I can be sure I understand how everything works.

In the meantime, @aure (creator of AudioKit) and @PaulBatchelor (creator of Soundpipe) may be able to offer additional feedback on this issue.

@PaulBatchelor
Copy link

It's been a while since I looked at tbvcf, but from what I recall it was never really much of an "emulation" to begin with, more of an empirically tuned biquad filter with loose associations with the tb303 filter sound.

This is a filter I'd probably avoid and maybe even deprecate.

Soundpipe also has sp_diode, which is based off of Will Pirkle's diode ladder filter, which should be something closer to the TB-303 filter. At the very least, it'll sound better:

https://www.willpirkle.com/virtual-analog-diode-ladder-filter/
https://github.com/AudioKit/AudioKit/blob/b7b68ce544f5009e12ef439d56130187dedaec25/Sources/soundpipe/modules/diode.c

But honestly, if you're a purist looking for a real tb303 filter emulation, these may all fall short, as these are just generic filter topologies structures that are similar, and not a physical model of the actual 303 circuit.

The VCS3 code mentioned above uses JUCE-specific oversampling, which wouldn't be portable. But other than that, I don't see why you couldn't make a soundpipe version of that code. However, there is no license currently for that codebase. For that code to be ported to soundpipe, a license would needed to be added and it would need to be compatible with the MIT license that Soundpipe has.

@01GOD
Copy link
Author

01GOD commented Jul 30, 2021 via email

@eljeff
Copy link
Member

eljeff commented Jul 30, 2021

https://www.youtube.com/watch?v=WamlDmvT_20

@eljeff
Copy link
Member

eljeff commented Jul 30, 2021

Somewhat ridiculously the Csound team prefers to add a new one rather than replacing that one or merging a pull request with an accurate emulation because “some projects may be based on that wrong emulation”.

I got to actually give it to them on this one ... I used to use some software with a totally borked implementation of a flanger, and it was so badass - unwieldy to control, hard to tame, and would blow up, but the sound was incredible. The developer eventually 'fixed' the flanger, and well, I didn't use that software anymore. Those sounds are now stuck in the ether of that time period.

I would love to still have that broken flanger around, so I can appreciate their response.

@01GOD
Copy link
Author

01GOD commented Jul 31, 2021

@eljeff That is what versioning IS FOR. Haha. This is github. 21st century now.

Not saying swift 1-3 was excusable, but updates that fix huge mistakes are important to do. Typing this on an apple butterfly keyboard that doesn't type some keys properly (needs to go to an apple store) and that was an apple hardware engineering fail, and CERTAINLY hope apple has upgraded that design, regardless of people that like randomly functional keyboard keys.

@aure
Copy link
Member

aure commented Aug 1, 2021

I'd say this is not a cookbook issue, so I'd rather have the discussion moved to SoundpipeAudioKit.

@aure aure closed this as completed Aug 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants