Class: SynthBlocks::Fx::Waveshaper

Inherits:
Object
  • Object
show all
Defined in:
lib/synth_blocks/fx/waveshaper.rb

Overview

waveshaper, source www.musicdsp.org/en/latest/Effects/41-waveshaper.html amount can go from 1 to … oo the higher a the stronger is the distortion

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount) ⇒ Waveshaper

Create waveshaper instance

amount

Amount can be from 0 to oo



14
15
16
# File 'lib/synth_blocks/fx/waveshaper.rb', line 14

def initialize(amount)
  @amount = amount
end

Instance Attribute Details

#amountObject (readonly)

Waveshaper amount



10
11
12
# File 'lib/synth_blocks/fx/waveshaper.rb', line 10

def amount
  @amount
end

Instance Method Details

#run(input) ⇒ Object

run waveshaper



19
20
21
# File 'lib/synth_blocks/fx/waveshaper.rb', line 19

def run(input)
  input * (input.abs + amount) / (input ** 2 + (amount - 1) * input.abs + 1)
end