Class: SynthBlocks::Fx::EnvelopeDetector

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(srate, tc: ms) ⇒ EnvelopeDetector

Returns a new instance of EnvelopeDetector.



5
6
7
8
9
# File 'lib/synth_blocks/fx/compressor.rb', line 5

def initialize(srate, tc: ms)
  @sample_rate = srate
  @ms = tc
  set_coef()
end

Instance Method Details

#run(input, state) ⇒ Object



20
21
22
# File 'lib/synth_blocks/fx/compressor.rb', line 20

def run(input, state)
  input + @coef * ( state - input )
end

#set_coefObject



11
12
13
# File 'lib/synth_blocks/fx/compressor.rb', line 11

def set_coef
  @coef = Math.exp( -1000.0 / ( @ms * @sample_rate) )
end

#tc=(tc) ⇒ Object



15
16
17
18
# File 'lib/synth_blocks/fx/compressor.rb', line 15

def tc=(tc)
  @ms = tc
  set_coef()
end