maximecb/noisecraft

What scale is the filter cutoff in?

ElizabethHudnott opened this issue · 3 comments

I tried to a create a patch that sets a filter cutoff value using the structure:

cutoff = (monoseq_frequency * knob_value) / 22050

The idea is that the cutoff could be set to a particular harmonic of the oscillator frequency. But it didn't work. Almost no sound gets through when the knob is set to 10.

I also tried putting my desired value in Hertz directly into the cutoff input but that doesn't work either.

Hi there. The cutoff input ranges from 0 to 1, with 0 being fully closed, and 1 being fully opened.

You can see the implementation here: https://github.com/maximecb/noisecraft/blob/main/public/synth.js#L197

I couldn't tell you the frequency in Hz that the input range corresponds to. You might have to reverse engineer it 😅

But if you do, please write back and we can add your findings in the comments to document the behavior.

Thank you for directing me to the correct piece of code.

So there's an invocation of Math.pow. So it looks like in order to convert a linear frequency value into a suitable input value for the filter I would need some kind of logarithm node.

And then c is feed into some equations that calculate the filter's internal state, v0 and v1. It's kind of hard to read as I'm only just beginning to learn about filter design. Is this doing something different from the ordinary BiquadFilterNode?

Is this doing something different from the ordinary BiquadFilterNode?

If you mean the web audio API node then it is not using that no. It's based on C++ code for a filter that I found online a few years ago. It looks like the same logic as this one, as far as I can tell: https://dsp.stackexchange.com/questions/9250/implementation-of-basic-2-pole-low-pass-filter