Class: Wavify::DSP::Effects::Tremolo
- Inherits:
-
EffectBase
- Object
- EffectBase
- Wavify::DSP::Effects::Tremolo
- Defined in:
- lib/wavify/dsp/effects/tremolo.rb,
sig/effects.rbs
Overview
Amplitude modulation effect using a sine LFO.
Constant Summary
Constants inherited from EffectBase
Instance Method Summary collapse
-
#initialize(rate: 5.0, depth: 0.5, mix: 1.0) ⇒ Tremolo
constructor
A new instance of Tremolo.
-
#process_sample(sample, channel:, sample_rate:) ⇒ Float
Processes a single sample for one channel.
Methods inherited from EffectBase
#apply, #build_runtime, #flush, #latency, #lookahead, #process, #reset, #tail_duration
Constructor Details
#initialize(rate: 5.0, depth: 0.5, mix: 1.0) ⇒ Tremolo
Returns a new instance of Tremolo.
8 9 10 11 12 13 14 |
# File 'lib/wavify/dsp/effects/tremolo.rb', line 8 def initialize(rate: 5.0, depth: 0.5, mix: 1.0) super() @rate = validate_positive!(rate, :rate) @depth = validate_unit!(depth, :depth) @mix = validate_unit!(mix, :mix) reset end |
Instance Method Details
#process_sample(sample, channel:, sample_rate:) ⇒ Float
Processes a single sample for one channel.
22 23 24 25 26 27 28 29 |
# File 'lib/wavify/dsp/effects/tremolo.rb', line 22 def process_sample(sample, channel:, sample_rate:) dry = sample.to_f mod = 1.0 - (@depth * ((Math.sin(@phase) + 1.0) / 2.0)) wet = dry * mod advance_phase! if channel == (@runtime_channels - 1) (dry * (1.0 - @mix)) + (wet * @mix) end |