forked from maca/scruby
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MultiOut ugens can accept an array as input, little gem version bump
- Loading branch information
Macario
committed
Aug 19, 2009
1 parent
f7781c6
commit e4a6c7f
Showing
12 changed files
with
147 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
module Scruby | ||
module Ugens | ||
module MultiOut #:nodoc: | ||
def self.included base | ||
base.extend ClassMethods | ||
end | ||
|
||
def initialize rate, channels, *inputs | ||
super rate, *inputs | ||
@channels = Array === channels ? channels : (0...channels).map{ |i| OutputProxy.new rate, self, i } | ||
@channels = @channels.to_da | ||
end | ||
|
||
def output_specs | ||
channels.output_specs.flatten | ||
end | ||
|
||
module ClassMethods | ||
private | ||
def new rate, channels, *inputs | ||
instantiated = super | ||
Array === instantiated ? instantiated : instantiated.channels | ||
end | ||
end | ||
end | ||
|
||
class OutputProxy < Ugen #:nodoc: | ||
attr_reader :source, :control_name, :output_index | ||
class << self; public :new; end | ||
|
||
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 Control < Ugen #:nodoc: | ||
include MultiOut | ||
|
||
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 | ||
new names.first.rate, *names | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.