Skip to content

Commit

Permalink
Ugen with multichannel inputs returns a DelegatorArray @ShDh mx
Browse files Browse the repository at this point in the history
  • Loading branch information
Macario committed Jul 25, 2009
1 parent af0fe0c commit 48242a9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/scruby.rb
Expand Up @@ -38,6 +38,7 @@ module Scruby
require "scruby/core_ext/string"
require "scruby/core_ext/symbol"
require "scruby/core_ext/typed_array"
require "scruby/core_ext/delegator_array"

require "scruby/audio/ugens/ugen"
require "scruby/audio/ugens/ugen_operations"
Expand Down
3 changes: 1 addition & 2 deletions lib/scruby/audio/ugens/ugen.rb
Expand Up @@ -120,7 +120,7 @@ def new rate, *inputs
return instantiate( rate, *inputs ) unless size > 1 #return an Ugen if no array was passed as an input

inputs = inputs.map{ |input| input.instance_of?( Array ) ? input.wrap_to( size ) : Array.new( size, input ) }.transpose
inputs.map{ |new_inputs| new rate, *new_inputs }
DelegatorArray.new inputs.map{ |new_inputs| new rate, *new_inputs }
end


Expand All @@ -142,7 +142,6 @@ def params
{}
end

private
def instantiate *args
obj = allocate
obj.__send__ :initialize, *args
Expand Down
6 changes: 4 additions & 2 deletions spec/audio/ugen_spec.rb
Expand Up @@ -10,6 +10,8 @@
require "scruby/core_ext/string"
require "scruby/core_ext/fixnum"
require "scruby/core_ext/array"
require "scruby/core_ext/delegator_array"


include Scruby
include Audio
Expand Down Expand Up @@ -208,7 +210,7 @@ def as_ugen_input; 0; end
end

it "should return an array of Ugens if an array as one arg is passed on instantiation" do
Ugen.new( :audio, 1, [2, 3] ).should be_instance_of(Array)
Ugen.new( :audio, 1, [2, 3] ).should be_instance_of(DelegatorArray)
end

it do
Expand Down Expand Up @@ -252,7 +254,7 @@ def as_ugen_input; 0; end
ugens.should have(4).ugens
end

it "should return an array of ugens with correct inputs" do
it "should return an delegator array of ugens with correct inputs" do
ugens = Ugen.new( :audio, 100, [210, 220, 230, 240] )
ugens.zip( [@i_1, @i_2, @i_3, @i_4] ).each do |e|
e.first.inputs.should eql( e.last )
Expand Down

0 comments on commit 48242a9

Please sign in to comment.