Class: Deftones::Component::Split

Inherits:
Deftones::Core::AudioNode show all
Defined in:
lib/deftones/component/split.rb

Defined Under Namespace

Classes: OutputTap

Instance Attribute Summary collapse

Attributes inherited from Deftones::Core::AudioNode

#context, #input

Instance Method Summary collapse

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, #output, #output_for_connection, #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) ⇒ Split

Returns a new instance of Split.



8
9
10
11
12
# File 'lib/deftones/component/split.rb', line 8

def initialize(context: Deftones.context)
  super(context: context)
  @left = OutputTap.new(parent: self, channel: 0, context: context)
  @right = OutputTap.new(parent: self, channel: 1, context: context)
end

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



6
7
8
# File 'lib/deftones/component/split.rb', line 6

def left
  @left
end

#rightObject (readonly)

Returns the value of attribute right.



6
7
8
# File 'lib/deftones/component/split.rb', line 6

def right
  @right
end

Instance Method Details

#number_of_outputsObject Also known as: numberOfOutputs



14
15
16
# File 'lib/deftones/component/split.rb', line 14

def number_of_outputs
  2
end

#output_for_index(index) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/deftones/component/split.rb', line 20

def output_for_index(index)
  case index
  when 0 then @left
  when 1 then @right
  else raise_connection_index_error!(:output_index, index, number_of_outputs)
  end
end

#render_channel(_channel, num_frames, start_frame = 0, cache = {}) ⇒ Object



28
29
30
# File 'lib/deftones/component/split.rb', line 28

def render_channel(_channel, num_frames, start_frame = 0, cache = {})
  render_channel_block(_channel, num_frames, start_frame, cache).mono
end

#render_channel_block(channel, num_frames, start_frame = 0, cache = {}) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/deftones/component/split.rb', line 32

def render_channel_block(channel, num_frames, start_frame = 0, cache = {})
  input_block = send(:mix_source_blocks, num_frames, start_frame, cache)
  output_channel = if input_block.channels == 1
                     input_block.channel(0)
                   elsif channel < input_block.channels
                     input_block.channel(channel)
                   else
                     Array.new(num_frames, 0.0)
                   end
  Core::AudioBlock.from_channel_data([output_channel])
end