Class: Deftones::Component::MidSideSplit
- Inherits:
-
Deftones::Core::AudioNode
- Object
- Deftones::Core::AudioNode
- Deftones::Component::MidSideSplit
- Defined in:
- lib/deftones/component/mid_side_split.rb
Defined Under Namespace
Classes: OutputTap
Constant Summary collapse
- SQRT_TWO =
Math.sqrt(2.0)
Instance Attribute Summary collapse
-
#mid ⇒ Object
readonly
Returns the value of attribute mid.
-
#side ⇒ Object
readonly
Returns the value of attribute side.
Attributes inherited from Deftones::Core::AudioNode
Instance Method Summary collapse
-
#initialize(context: Deftones.context) ⇒ MidSideSplit
constructor
A new instance of MidSideSplit.
- #render_output(mode, num_frames, start_frame = 0, cache = {}) ⇒ Object
- #render_output_block(mode, num_frames, start_frame = 0, cache = {}) ⇒ Object
Methods inherited from Deftones::Core::AudioNode
#>>, #attach_destination, #attach_source, #block_time, #chain, #channel_count, #channel_count_mode, #channel_interpretation, #connect, #connected?, #default_input_channels, #default_output_channels, #destination_for_connection, #detach_all_destinations, #detach_destination, #detach_source, #disconnect, #dispose, #disposed?, #fan, #get, #immediate, #input_for_index, #inputs, #mix_source_blocks, #multichannel_process?, #name, #normalize_connection_index, #normalize_output_block, #now, #number_of_inputs, #number_of_outputs, #output, #output_for_connection, #output_for_index, #outputs, #process, #raise_connection_index_error!, #reaches_node?, #render, #render_block, #sample_time, #set, #to_destination, #to_frequency, #to_master, #to_midi, #to_output, #to_s, #to_seconds, #to_ticks, #uses_legacy_render_for_block?, #validate_connectable!, #validate_connection_index!
Constructor Details
#initialize(context: Deftones.context) ⇒ MidSideSplit
Returns a new instance of MidSideSplit.
10 11 12 13 14 |
# File 'lib/deftones/component/mid_side_split.rb', line 10 def initialize(context: Deftones.context) super(context: context) @mid = OutputTap.new(parent: self, mode: :mid, context: context) @side = OutputTap.new(parent: self, mode: :side, context: context) end |
Instance Attribute Details
#mid ⇒ Object (readonly)
Returns the value of attribute mid.
8 9 10 |
# File 'lib/deftones/component/mid_side_split.rb', line 8 def mid @mid end |
#side ⇒ Object (readonly)
Returns the value of attribute side.
8 9 10 |
# File 'lib/deftones/component/mid_side_split.rb', line 8 def side @side end |
Instance Method Details
#render_output(mode, num_frames, start_frame = 0, cache = {}) ⇒ Object
16 17 18 |
# File 'lib/deftones/component/mid_side_split.rb', line 16 def render_output(mode, num_frames, start_frame = 0, cache = {}) render_output_block(mode, num_frames, start_frame, cache).mono end |
#render_output_block(mode, num_frames, start_frame = 0, cache = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/deftones/component/mid_side_split.rb', line 20 def render_output_block(mode, num_frames, start_frame = 0, cache = {}) input_block = send(:mix_source_blocks, num_frames, start_frame, cache).fit_channels(2) left = input_block.channel(0) right = input_block.channel(1) output = case mode when :mid Array.new(num_frames) { |index| (left[index] + right[index]) / SQRT_TWO } when :side Array.new(num_frames) { |index| (left[index] - right[index]) / SQRT_TWO } else raise ArgumentError, "Unsupported mid/side output: #{mode}" end Core::AudioBlock.from_channel_data([output]) end |