/
multi_out_ugens.rb
48 lines (38 loc) · 1.18 KB
/
multi_out_ugens.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
module Scruby
module Audio
module Ugens
class OutputProxy < Ugen
attr_reader :source, :control_name, :output_index
def initialize( rate, source, output_index, name = nil )
super rate
@source, @control_name, @output_index = source, name, output_index
end
def index
@source.index
end
def add_to_synthdef; end
end
class MultiOutUgen < Ugen
def initialize( rate, *channels )
super rate
@channels = channels
end
def self.new( rate, *args )
super( rate, *args ).channels #returns the channels but gets instantiated
end
private
def output_specs
channels.collect{ |output| output.send :output_specs }.flatten
end
end
class Control < MultiOutUgen #:nodoc:
def initialize( rate, *names )
super rate, *names.collect_with_index{|n, i| OutputProxy.new rate, self, i, n }
end
def self.and_proxies_from( names )
Control.new( names.first.rate, *names )
end
end
end
end
end