Class: Wavify::DSP::Effects::Vibrato
- Inherits:
-
EffectBase
- Object
- EffectBase
- Wavify::DSP::Effects::Vibrato
- Defined in:
- lib/wavify/dsp/effects/vibrato.rb,
sig/effects.rbs
Overview
Pitch modulation effect using a short modulated delay line.
Constant Summary collapse
- BASE_DELAY_SECONDS =
0.006- DEPTH_DELAY_SECONDS =
0.004
Constants inherited from EffectBase
Instance Method Summary collapse
-
#initialize(rate: 5.0, depth: 0.5, mix: 1.0) ⇒ Vibrato
constructor
A new instance of Vibrato.
- #latency ⇒ Object
- #process_sample(sample, channel:, sample_rate:) ⇒ Object
- #tail_duration ⇒ Object
Methods inherited from EffectBase
#apply, #build_runtime, #flush, #lookahead, #process, #reset
Constructor Details
#initialize(rate: 5.0, depth: 0.5, mix: 1.0) ⇒ Vibrato
Returns a new instance of Vibrato.
11 12 13 14 15 16 17 |
# File 'lib/wavify/dsp/effects/vibrato.rb', line 11 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
#latency ⇒ Object
41 42 43 |
# File 'lib/wavify/dsp/effects/vibrato.rb', line 41 def latency @mix >= 1.0 ? maximum_delay : 0.0 end |
#process_sample(sample, channel:, sample_rate:) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/wavify/dsp/effects/vibrato.rb', line 19 def process_sample(sample, channel:, sample_rate:) dry = sample.to_f line = @delay_lines.fetch(channel) write_index = @write_indices.fetch(channel) mod = @lfo.value_at(channel_phase_offset(channel)) delay_samples = @base_delay_samples + (@depth_delay_samples * ((mod + 1.0) / 2.0)) wet = read_fractional_delay(line, write_index, delay_samples) line[write_index] = dry @write_indices[channel] = (write_index + 1) % line.length @lfo.next_value if channel == (@runtime_channels - 1) (dry * (1.0 - @mix)) + (wet * @mix) end |
#tail_duration ⇒ Object
35 36 37 38 39 |
# File 'lib/wavify/dsp/effects/vibrato.rb', line 35 def tail_duration return 0.0 if @mix.zero? maximum_delay end |