Class: Deftones::Effects::PingPongDelay
- Inherits:
-
FeedbackDelay
- Object
- Core::Effect
- FeedbackDelay
- Deftones::Effects::PingPongDelay
- Defined in:
- lib/deftones/effect/ping_pong_delay.rb
Instance Attribute Summary
Attributes inherited from FeedbackDelay
Attributes inherited from Core::Effect
Instance Method Summary collapse
-
#initialize(max_delay: 2.0, **options) ⇒ PingPongDelay
constructor
A new instance of PingPongDelay.
- #process_effect_block(input_block, num_frames, start_frame, _cache) ⇒ Object private
Methods inherited from FeedbackDelay
#ensure_delay_line, #process_effect
Methods inherited from Core::Effect
#multichannel_process?, #normalize_channel_output, #process, #process_effect
Constructor Details
#initialize(max_delay: 2.0, **options) ⇒ PingPongDelay
Returns a new instance of PingPongDelay.
6 7 8 9 10 |
# File 'lib/deftones/effect/ping_pong_delay.rb', line 6 def initialize(max_delay: 2.0, **) super(max_delay: max_delay, **) @left_delay_line = DSP::DelayLine.new(@max_delay_samples) @right_delay_line = DSP::DelayLine.new(@max_delay_samples) end |
Instance Method Details
#process_effect_block(input_block, num_frames, start_frame, _cache) ⇒ Object (private)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/deftones/effect/ping_pong_delay.rb', line 14 def process_effect_block(input_block, num_frames, start_frame, _cache) delays = @delay_time.process(num_frames, start_frame) feedbacks = @feedback.process(num_frames, start_frame) source = input_block.fit_channels(2) left = Array.new(num_frames, 0.0) right = Array.new(num_frames, 0.0) num_frames.times do |index| delay_samples = delays[index] * context.sample_rate feedback = feedbacks[index].to_f.clamp(-0.999, 0.999) left_tap = @left_delay_line.read(delay_samples) right_tap = @right_delay_line.read(delay_samples) input_left = input_block.channels == 1 ? input_block.mono[index] : source.channel_data[0][index] input_right = input_block.channels == 1 ? 0.0 : source.channel_data[1][index] @left_delay_line.write(input_left + (right_tap * feedback)) @right_delay_line.write(input_right + (left_tap * feedback)) left[index] = left_tap right[index] = right_tap end Core::AudioBlock.from_channel_data([left, right]) end |