Module: SynthBlocks::Utils

Defined in:
lib/synth_blocks/utils.rb

Overview

Some simple utils

Instance Method Summary collapse

Instance Method Details

#bitreduce(input, bits = 8) ⇒ Object

a simple bitreducer using rounding bits is the number of bits you want to reduce to



6
7
8
# File 'lib/synth_blocks/utils.rb', line 6

def bitreduce(input, bits=8)
  (input * bits.to_f).round.to_f / bits.to_f
end

#simple_waveshaper(input, a) ⇒ Object

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



13
14
15
# File 'lib/synth_blocks/utils.rb', line 13

def simple_waveshaper(input, a)
  input * (input.abs + a) / (input ** 2 + (a - 1) * input.abs + 1)
end