Class: Wavify::DSP::Effects::Phaser
- Inherits:
-
EffectBase
- Object
- EffectBase
- Wavify::DSP::Effects::Phaser
- Defined in:
- lib/wavify/dsp/effects/phaser.rb,
sig/effects.rbs
Overview
Modulated all-pass phase shifting effect.
Constant Summary collapse
- MAX_STAGES =
32- TAIL_AMPLITUDE =
1.0e-6- MAX_ALLPASS_COEFFICIENT =
0.9- REFERENCE_SAMPLE_RATE =
44_100.0
Constants inherited from EffectBase
Instance Method Summary collapse
-
#initialize(rate: 0.5, depth: 0.7, feedback: 0.2, mix: 0.5, stages: 4) ⇒ Phaser
constructor
A new instance of Phaser.
- #process_sample(sample, channel:, sample_rate:) ⇒ Object
- #tail_duration ⇒ Object
Methods inherited from EffectBase
#apply, #build_runtime, #flush, #latency, #lookahead, #process, #reset
Constructor Details
#initialize(rate: 0.5, depth: 0.7, feedback: 0.2, mix: 0.5, stages: 4) ⇒ Phaser
Returns a new instance of Phaser.
13 14 15 16 17 18 19 20 21 |
# File 'lib/wavify/dsp/effects/phaser.rb', line 13 def initialize(rate: 0.5, depth: 0.7, feedback: 0.2, mix: 0.5, stages: 4) super() @rate = validate_positive!(rate, :rate) @depth = validate_unit!(depth, :depth) @feedback = validate_feedback!(feedback) @mix = validate_unit!(mix, :mix) @stages = validate_stages!(stages) reset end |
Instance Method Details
#process_sample(sample, channel:, sample_rate:) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/wavify/dsp/effects/phaser.rb', line 23 def process_sample(sample, channel:, sample_rate:) dry = sample.to_f coefficient = modulated_coefficient(channel) wet = process_allpass_chain(dry + (@feedback_samples.fetch(channel) * @feedback), channel, coefficient) @feedback_samples[channel] = wet @lfo.next_value if channel == (@runtime_channels - 1) (dry * (1.0 - @mix)) + (wet * @mix) end |
#tail_duration ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/wavify/dsp/effects/phaser.rb', line 33 def tail_duration return 0.0 if @mix.zero? pole = [MAX_ALLPASS_COEFFICIENT, @feedback.abs].max decay_samples = (Math.log(TAIL_AMPLITUDE) / Math.log(pole)).ceil (@stages * decay_samples) / REFERENCE_SAMPLE_RATE end |