Class: Wavify::DSP::Effects::AutoPan
- Inherits:
-
EffectBase
- Object
- EffectBase
- Wavify::DSP::Effects::AutoPan
- Defined in:
- lib/wavify/dsp/effects/auto_pan.rb,
sig/effects.rbs
Overview
Stereo sine-LFO auto-panner.
Constant Summary
Constants inherited from EffectBase
Instance Method Summary collapse
-
#initialize(rate: 0.5, depth: 1.0) ⇒ AutoPan
constructor
A new instance of AutoPan.
-
#process_sample(sample, channel:, sample_rate:) ⇒ Float
Processes a single sample for one stereo channel.
Methods inherited from EffectBase
#apply, #build_runtime, #flush, #latency, #lookahead, #process, #reset, #tail_duration
Constructor Details
#initialize(rate: 0.5, depth: 1.0) ⇒ AutoPan
Returns a new instance of AutoPan.
8 9 10 11 12 13 |
# File 'lib/wavify/dsp/effects/auto_pan.rb', line 8 def initialize(rate: 0.5, depth: 1.0) super() @rate = validate_positive!(rate, :rate) @depth = validate_unit!(depth, :depth) reset end |
Instance Method Details
#process_sample(sample, channel:, sample_rate:) ⇒ Float
Processes a single sample for one stereo channel.
21 22 23 24 25 26 27 28 29 |
# File 'lib/wavify/dsp/effects/auto_pan.rb', line 21 def process_sample(sample, channel:, sample_rate:) raise InvalidParameterError, "AutoPan requires stereo input" unless @runtime_channels == 2 position = Math.sin(@phase) * @depth left_gain, right_gain = constant_power_pan_gains(position) output = sample.to_f * (channel.zero? ? left_gain : right_gain) advance_phase! if channel == 1 output end |