Module: Ruck::UGen::MultiChannelTarget

Included in:
Generators::WavOut
Defined in:
lib/ruck/ugen/ugen.rb

Instance Method Summary collapse

Instance Method Details

#add_source(ugen) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/ruck/ugen/ugen.rb', line 103

def add_source(ugen)
  if ugen.is_a? Array
    ugen.each { |u| add_source u }
    return self
  end

  if ugen.out_channels.length == 1
    @in_channels.each { |chan| chan.add_source ugen.out(0) }
  else
    1.upto([ugen.out_channels.length, @in_channels.length].min) do |i|
      @in_channels[i-1].add_source ugen.out(i-1)
    end
  end

  self
end

#in(chan) ⇒ Object



140
141
142
# File 'lib/ruck/ugen/ugen.rb', line 140

def in(chan)
  @in_channels[chan]
end

#in_channelsObject



136
137
138
# File 'lib/ruck/ugen/ugen.rb', line 136

def in_channels
  @in_channels
end

#remove_source(ugen) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/ruck/ugen/ugen.rb', line 120

def remove_source(ugen)
  if ugen.is_a? Array
    ugen.each { |u| remove_source u }
    return
  end

  # remove all outputs of ugen from all inputs of self
  @in_channels.each do |in_chan|
    ugen.out_channels.each do |out_chan|
      in_chan.remove_source out_chan
    end
  end

  self
end