Class: SynthBlocks::Fx::EnvelopeDetector
- Inherits:
-
Object
- Object
- SynthBlocks::Fx::EnvelopeDetector
- Defined in:
- lib/synth_blocks/fx/compressor.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(srate, tc: ms) ⇒ EnvelopeDetector
constructor
A new instance of EnvelopeDetector.
- #run(input, state) ⇒ Object
- #set_coef ⇒ Object
- #tc=(tc) ⇒ Object
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_coef ⇒ Object
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 |