class SynthBlocks::Core::MoogFilter
Public Class Methods
new()
click to toggle source
create new instance
# File lib/synth_blocks/core/moog_filter.rb, line 9 def initialize @in1 = @in2 = @in3 = @in4 = 0 @out1 = @out2 = @out3 = @out4 = 0 end
Public Instance Methods
run(input, fc, res)
click to toggle source
runs the filter on the input value fc is the cutoff frequency (not in Hz but from 0..1) res is the resonance from 0..4
# File lib/synth_blocks/core/moog_filter.rb, line 18 def run(input, fc, res) f = fc * 1.16; fb = res * (1.0 - 0.15 * f * f); input -= @out4 * fb; input *= 0.35013 * (f*f)*(f*f); @out1 = input + 0.3 * @in1 + (1 - f) * @out1; # Pole 1 @in1 = input; @out2 = @out1 + 0.3 * @in2 + (1 - f) * @out2; # Pole 2 @in2 = @out1; @out3 = @out2 + 0.3 * @in3 + (1 - f) * @out3; # Pole 3 @in3 = @out2; @out4 = @out3 + 0.3 * @in4 + (1 - f) * @out4; # Pole 4 @in4 = @out3; return @out4; end