Class: Deftones::Effects::StereoWidener
- Inherits:
-
Core::Effect
- Object
- Core::Effect
- Deftones::Effects::StereoWidener
- Defined in:
- lib/deftones/effect/stereo_widener.rb
Instance Attribute Summary collapse
-
#width ⇒ Object
Returns the value of attribute width.
Attributes inherited from Core::Effect
Instance Method Summary collapse
-
#initialize(width: 0.5, context: Deftones.context, **options) ⇒ StereoWidener
constructor
A new instance of StereoWidener.
- #process_effect_block(input_block, num_frames, _start_frame, _cache) ⇒ Object private
Methods inherited from Core::Effect
#multichannel_process?, #normalize_channel_output, #process, #process_effect
Constructor Details
#initialize(width: 0.5, context: Deftones.context, **options) ⇒ StereoWidener
Returns a new instance of StereoWidener.
8 9 10 11 |
# File 'lib/deftones/effect/stereo_widener.rb', line 8 def initialize(width: 0.5, context: Deftones.context, **) super(context: context, **) @width = width.to_f end |
Instance Attribute Details
#width ⇒ Object
Returns the value of attribute width.
6 7 8 |
# File 'lib/deftones/effect/stereo_widener.rb', line 6 def width @width end |
Instance Method Details
#process_effect_block(input_block, num_frames, _start_frame, _cache) ⇒ Object (private)
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/deftones/effect/stereo_widener.rb', line 15 def process_effect_block(input_block, num_frames, _start_frame, _cache) stereo_input = input_block.fit_channels(2) width = @width.to_f.clamp(0.0, 1.0) left = Array.new(num_frames) right = Array.new(num_frames) num_frames.times do |index| left_sample = stereo_input.channel_data[0][index] right_sample = stereo_input.channel_data[1][index] mid = (left_sample + right_sample) * (1.0 - width) side = (left_sample - right_sample) * width left[index] = mid + side right[index] = mid - side end Core::AudioBlock.from_channel_data([left, right]) end |