Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

implemented BufIO classes, refactored Multi Out Ugens

  • Loading branch information...
commit 74a8e8e3e1c461ea23f0c921a2b5c2727be528d6 1 parent 8080ee0
@maca authored
View
7 lib/scruby.rb
@@ -19,12 +19,13 @@
require 'rubygems'
require 'arguments'
require 'rosc'
+require 'eventmachine'
require 'yaml'
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
module Scruby
- VERSION = '0.2.2'
+ VERSION = '0.2.5'
end
require "scruby/core_ext/object"
@@ -42,6 +43,8 @@ module Scruby
require "scruby/ugens/ugen"
require "scruby/ugens/ugen_operations"
require "scruby/ugens/multi_out_ugens"
+require "scruby/ugens/panner"
+require "scruby/ugens/buffer_read_write"
require "scruby/ugens/in_out"
require "scruby/ugens/operation_ugens"
@@ -57,5 +60,7 @@ module Scruby
require "scruby/bus"
require "scruby/buffer"
+require "scruby/ticker"
+
include Scruby
include Ugens
View
3  lib/scruby/core_ext/proc.rb
@@ -1,5 +1,5 @@
class Proc
- # Returns an array of symbols corresponding to the argument names
+
def arguments
case self.arity
when -1..0 then []
@@ -7,6 +7,5 @@ def arguments
else self.to_sexp[2][1][1..-1].collect{ |arg| arg[1] }
end
end
-
alias :value :call
end
View
93 lib/scruby/ticker.rb
@@ -0,0 +1,93 @@
+module Scruby
+ Thread.new do
+ EventMachine.run do
+ EM.set_quantum 5
+
+ EM.error_handler do |e|
+ puts e
+ end
+ end
+ end
+
+ # A timer will call a given block periodically. The period is specified in beats per minute.
+ class Ticker
+ attr_reader :start, :tick, :interval
+ attr_accessor :tempo, :resolution, :size, :loop
+
+ def initialize tempo = 120, size = 16, resolution = 1, loop = true, &block
+ @tempo , @resolution, @size, @loop = tempo , resolution, size, loop
+ @interval = 60.0 / @tempo
+ @tick = 0
+ @block = block
+ end
+
+ named_args_for :initialize
+
+ def block &block
+ @block = block
+ end
+
+ def run
+ return self if @timer
+ @start = Time.now
+ @timer = EventMachine::PeriodicTimer.new @interval * 0.01 do
+ if @next.nil? or Time.now >= @next
+ dispatch
+ @tick += @resolution
+ next_time
+ end
+ end
+ self
+ end
+
+ def index
+ return @tick unless @size
+ tick = @tick % @size
+ if tick == 0 and @tick > 0 and !@loop
+ stop
+ nil
+ else
+ tick
+ end
+ end
+
+ def next_time
+ @next = @start + @tick * @interval
+ end
+
+ def stop
+ @timer.cancel if @timer
+ @timer = nil
+ @next = nil
+ @tick = 0
+ self
+ end
+
+ def running?
+ not @timer.nil?
+ end
+
+ def dispatch
+ @block.call index if @block
+ end
+ end
+
+ class Scheduler < Ticker
+ def initialize opts = {}
+ super
+ @queue = []
+ end
+
+ def dispatch
+ if blocks = @queue[index]
+ blocks.each{ |b| b.call }
+ end
+ end
+
+ def at tick, &proc
+ @queue[tick] ||= []
+ @queue[tick].push proc
+ end
+ end
+
+end
View
99 lib/scruby/ugens/buffer_read_write.rb
@@ -0,0 +1,99 @@
+module Scruby
+ module Ugens
+ class PlayBuf < Ugen
+ include MultiOut
+
+ class << self
+ def kr channels, bufnum = 0, rate = 1.0, trigger = 1.0, start = 0.0, loop = 0.0, doneAction = 0
+ new :control, channels, bufnum, rate, trigger, start, loop, doneAction
+ end
+
+ def ar channels, bufnum = 0, rate = 1.0, trigger = 1.0, start = 0.0, loop = 0.0, doneAction = 0;
+ new :audio, channels, bufnum, rate, trigger, start, loop, doneAction
+ end
+ named_args_for :kr, :ar
+ end
+ end
+
+ class TGrains < Ugen
+ include MultiOut
+
+ def initialize rate, channels, *inputs
+ raise ArgumentError.new("#{ self.class } instance needs at least two channels.") unless channels > 1
+ super
+ end
+
+ class << self
+ def ar channels, trigger = 0, bufnum = 0, rate = 1, centerPos = 0
+ new :audio, channels, trigger, bufnum, rate, centerPos
+ end
+ named_args_for :ar
+ end
+ end
+
+ class BufRd < Ugen
+ include MultiOut
+
+ class << self
+ def kr channels, bufnum = 0, phase = 0.0, loop = 1.0, interpolation = 2
+ new :control, channels, bufnum, phase, loop, interpolation
+ end
+
+ def ar channels, bufnum = 0, phase = 0.0, loop = 1.0, interpolation = 2
+ new :audio, channels, bufnum, phase, loop, interpolation
+ end
+ named_args_for :kr, :ar
+ end
+ end
+
+ class BufWr < Ugen
+ class << self
+ def kr input, bufnum = 0, phase = 0.0, loop = 1.0
+ new :control, bufnum, phase, loop, *input.to_array
+ end
+
+ def ar input, bufnum = 0, phase = 0.0, loop = 1.0
+ new :audio, bufnum, phase, loop, *input.to_array
+ end
+ named_args_for :kr, :ar
+ end
+ end
+
+ class RecordBuf < Ugen
+ class << self
+ def kr input, bufnum = 0, offset = 0.0, rec_level = 1.0, pre_level = 0.0, run = 1.0, loop = 1.0, trigger = 1.0, doneAction=0
+ new :control, bufnum, offset, rec_level, pre_level, run, loop, trigger, doneAction, *input.to_array
+ end
+
+ def ar input, bufnum = 0, offset = 0.0, rec_level = 1.0, pre_level = 0.0, run = 1.0, loop = 1.0, trigger = 1.0, doneAction=0
+ new :audio, bufnum, offset, rec_level, pre_level, run, loop, trigger, doneAction, *input.to_array
+ end
+ named_args_for :kr, :ar
+ end
+ end
+
+ class ScopeOut < Ugen
+ class << self
+ def kr input, bufnum = 0
+ new :control, bufnum, *input.to_array
+ end
+
+ def ar input, bufnum = 0
+ new :audio, bufnum, *input.to_array
+ end
+ named_args_for :kr, :ar
+ end
+ end
+
+ class Tap < Ugen
+ class << self
+ def ar bufnum = 0, num_channels = 1, delay_time = 0.2
+ n = SampleRate.ir.neg * 3
+ PlayBuf.ar num_channels, bufnum, 1, 0, n, 1
+ end
+ named_args_for :ar
+ end
+ end
+
+ end
+end
View
25 lib/scruby/ugens/in_out.rb
@@ -1,11 +1,7 @@
module Scruby
module Ugens
- class In < MultiOutUgen
- #:nodoc:
- def initialize rate, channels, bus
- super rate, *(0...channels).map{ |i| OutputProxy.new rate, self, i }
- @inputs = [bus]
- end
+ class In < Ugen
+ include MultiOut
class << self
# New In with :audio rate, inputs should be valid Ugen inputs or Ugens, arguments can be passed as an options hash or in the given order
@@ -16,18 +12,11 @@ def ar bus, channels = 1
def kr bus, channels = 1
new :control, channels, bus
end
-
- def params #:nodoc:
- {:audio => [[:bus, nil], [:channels, 1], [:mul, 1], [:add, 0]], :control => [[:bus, nil], [:channels, 1], [:mul, 1], [:add, 0]]}
- end
-
- private
- def new *args; super; end
end
end
class Out < Ugen
- # ar and kr should be use for instantiatio
+ # ar and kr should be use for instantiation
def initialize *args
super
@channels = []
@@ -48,14 +37,6 @@ def kr bus, *inputs
inputs.peel!
new :control, bus, *inputs; 0.0 #Out has no output
end
-
-
- def params #:nodoc:
- {:audio => [[:bus,nil], [:inputs, []], [:mul, 1], [:add, 0]], :control => [[:bus,nil], [:inputs, []], [:mul, 1], [:add, 0]]}
- end
-
- private
- def new *args; super; end
end
end
end
View
48 lib/scruby/ugens/multi_out_ugens.rb
@@ -1,7 +1,30 @@
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 }
+ end
+
+ private
+ def output_specs
+ channels.collect{ |output| output.send :output_specs }.flatten
+ end
+
+ module ClassMethods
+ def new *args
+ super.channels #returns the channels but gets instantiated, TODO: Maybe not a good idea
+ 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
@@ -11,29 +34,16 @@ def initialize rate, source, output_index, name = nil
def index; @source.index; end
def add_to_synthdef; end
+
end
- class MultiOutUgen < Ugen #:nodoc:
- def initialize rate, *channels
- super rate
- @channels = channels
- end
-
- def self.new rate, *args
- super.channels #returns the channels but gets instantiated, TODO: Maybe not a good idea
- end
-
- private
- def output_specs
- channels.collect{ |output| output.send :output_specs }.flatten
- end
- end
-
- class Control < MultiOutUgen #:nodoc:
+ class Control < Ugen #:nodoc:
+ include MultiOut
+
def initialize rate, *names
- super rate, *names.collect_with_index{|n, i| OutputProxy.new rate, self, i, n }
+ 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
View
137 lib/scruby/ugens/panner.rb
@@ -0,0 +1,137 @@
+module Scruby
+ module Ugens
+ class Pan2 < Ugen
+ include MultiOut
+
+ class << self
+ def ar input, pos = 0.0, level = 1.0
+ new :audio, 2, input, pos, level
+ end
+
+ def kr input, pos = 0.0, level = 1.0
+ new :control, 2, input, pos, level
+ end
+ named_args_for :ar, :kr
+ end
+ end
+
+ class LinPan2 < Pan2; end
+
+ class Pan4 < Ugen
+ include MultiOut
+
+ class << self
+ def ar input, xpos = 0.0, ypos = 0.0, level = 1.0
+ new :audio, 4, input, xpos, ypos, level
+ end
+
+ def kr input, xpos = 0.0, ypos = 0.0, level = 1.0
+ new :control, 4, input, xpos, ypos, level
+ end
+ named_args_for :ar, :kr
+ end
+ end
+
+ class Balance2 < Ugen
+ include MultiOut
+
+ class << self
+ def ar left, right, pos = 0.0, level = 1.0
+ new :audio, 2, left, right, pos, level
+ end
+
+ def kr left, right, pos = 0.0, level = 1.0
+ new :control, 2, left, right, pos, level
+ end
+ named_args_for :ar, :kr
+ end
+ end
+
+ class Rotate2 < Ugen
+ include MultiOut
+
+ class << self
+ def ar x, y, pos = 0.0
+ new :audio, 2, x, y, pos
+ end
+
+ def kr x, y, pos = 0.0
+ new :control, 2, x, y, pos
+ end
+ end
+ end
+
+ class PanB < Ugen
+ include MultiOut
+
+ class << self
+ def ar input, azimuth = 0, elevation = 0, gain = 1
+ new :audio, 4, input, azimuth, elevation, gain
+ end
+
+ def kr input, azimuth = 0, elevation = 0, gain = 1
+ new :control, 4, input, azimuth, elevation, gain
+ end
+ named_args_for :ar, :kr
+ end
+ end
+
+ class PanB2 < Ugen
+ include MultiOut
+
+ class << self
+ def ar input, azimuth = 0, gain = 1
+ new :audio, 3, input, azimuth, gain
+ end
+
+ def kr input, azimuth = 0, gain = 1
+ new :control, 3, input, azimuth, gain
+ end
+ named_args_for :ar, :kr
+ end
+ end
+
+ class BiPanB2 < Ugen
+ include MultiOut
+
+ class << self
+ def ar a, b, azimuth, gain = 1
+ new :audio, 3, a, b, azimuth, gain
+ end
+
+ def kr a, b, azimuth, gain = 1
+ new :control, 3, a, b, azimuth, gain
+ end
+ end
+ end
+
+ class DecodeB2 < Ugen
+ include MultiOut
+
+ class << self
+ def ar num_channels, w, x, y, orientation = 0.5
+ new :audio, num_channels, w, x, y, orientation
+ end
+
+ def kr num_channels, w, x, y, orientation = 0.5
+ new :control, num_channels, w, x, y, orientation
+ end
+ end
+ end
+
+ class PanAz < Ugen
+ include MultiOut
+
+ class << self
+ def ar num_channels, input, pos = 0.0, level = 1.0, width = 2.0, orientation = 0.5
+ new :audio, num_channels, input, pos, level, width, orientation
+ end
+
+ def kr num_channels, input, pos = 0.0, level = 1.0, width = 2.0, orientation = 0.5
+ new :control, num_channels, input, pos, level, width, orientation
+ end
+ named_args_for :ar, :kr
+ end
+ end
+ end
+end
View
29 lib/scruby/ugens/ugen.rb
@@ -115,8 +115,8 @@ def == other
class << self
#:nodoc:
+ private
def new rate, *inputs
-
if rate.kind_of? Array
rate = RATES.slice rate.collect { |rate| # get the highest rate, raise error if rate is not defined
rate = rate.to_sym
@@ -147,15 +147,13 @@ def new rate, *inputs
output.to_da
end
-
- def synthdef #:nodoc:
- @@synthdef
+ def instantiate *args
+ obj = allocate
+ obj.__send__ :initialize, *args
+ obj
end
- def synthdef= synthdef #:nodoc:
- @@synthdef = synthdef
- end
-
+ public
def valid_input? obj
case obj
when *VALID_INPUTS then true
@@ -163,15 +161,18 @@ def valid_input? obj
end
end
+ def synthdef #:nodoc:
+ @@synthdef
+ end
+
+ def synthdef= synthdef #:nodoc:
+ @@synthdef = synthdef
+ end
+
def params
{}
end
-
- def instantiate *args
- obj = allocate
- obj.__send__ :initialize, *args
- obj
- end
+
end
end
end
View
68 lib/scruby/ugens/ugen_defs.yaml
@@ -339,25 +339,6 @@ BufRateScale:
:control:
- - :bufnum
-
-BufRd:
- :control:
- - - :bufnum
- - 0
- - - :phase
- - 0
- - - :loop
- - 1
- - - :interpolation
- - 2
- :audio:
- - - :bufnum
- - 0
- - - :phase
- - 0
- - - :loop
- - 1
- - - :interpolation
- - 2
BufSampleRate:
:scalar:
- - :bufnum
@@ -372,25 +353,6 @@ BufSamples:
:control:
- - :bufnum
-
-BufWr:
- :control:
- - - :bufnum
- - 0
- - - :phase
- - 0
- - - :loop
- - 1
- - - :inputArray
- - "[]"
- :audio:
- - - :bufnum
- - 0
- - - :phase
- - 0
- - - :loop
- - 1
- - - :inputArray
- - "[]"
COsc:
:control:
- - :bufnum
@@ -2362,18 +2324,6 @@ PitchShift:
- 0
- - :timeDispersion
- 0
-PlayBuf:
- :audio:
- - - :bufnum
- - 0
- - - :rate
- - 1
- - - :trigger
- - 1
- - - :startPos
- - 0
- - - :loop
- - 0
Pulse:
:audio:
- - :freq
@@ -2870,24 +2820,6 @@ TExpRand:
- 1
- - :trig
- 0
-TGrains:
- :audio:
- - - :trigger
- - 0
- - - :bufnum
- - 0
- - - :rate
- - 1
- - - :centerPos
- - 0
- - - :dur
- - 0.1
- - - :pan
- - 0
- - - :amp
- - 0.1
- - - :interp
- - 4
TIRand:
:control:
- - :lo
View
328 spec/buffer_read_write_spec.rb
@@ -0,0 +1,328 @@
+require File.expand_path(File.dirname(__FILE__)) + "/helper"
+
+require "scruby/control_name"
+require "scruby/env"
+require "scruby/ugens/ugen"
+require "scruby/ugens/ugen_operations"
+require "scruby/ugens/operation_ugens"
+require "scruby/ugens/multi_out_ugens"
+require "scruby/ugens/ugens"
+require "scruby/ugens/buffer_read_write"
+
+include Scruby
+include Ugens
+
+class MockUgen < Ugen
+ class << self; public :new; end
+end
+
+
+describe 'Buffer Read Ugens' do
+ shared_examples_for 'Buffer reader Ugen' do
+ before do
+ @proxies = @class.send @method, *@params
+ @inputs ||= @params
+ @instance = @proxies.first.source
+ end
+
+ it "should have correct rate" do
+ @instance.rate.should == @rate
+ end
+
+ it "should return an array of output proxies" do
+ @proxies.should be_a(Array)
+ @proxies.should have(@channels).proxies
+ @proxies.each_with_index do |proxy, i|
+ proxy.source.should be_a(@class)
+ proxy.should be_a(OutputProxy)
+ proxy.output_index.should == i
+ end
+ end
+
+ it "should set inputs" do
+ @instance.inputs.should == @inputs
+ end
+ end
+
+ shared_examples_for 'Buffer reader Ugen with control rate' do
+ before do
+ @method = :kr
+ @rate = :control
+ end
+ it_should_behave_like 'Buffer reader Ugen'
+ end
+
+ shared_examples_for 'Buffer reader Ugen with audio rate' do
+ before do
+ @method = :ar
+ @rate = :audio
+ end
+ it_should_behave_like 'Buffer reader Ugen'
+
+ it "should just accept audio inputs if rate is audio" # do
+ # lambda { @class.new( :audio, MockUgen.new(:control) ) }.should raise_error(ArgumentError)
+ # end
+ end
+
+ describe PlayBuf, 'Two channel' do
+ before do
+ @class = PlayBuf
+ @channels = 2
+ @inputs = 1.0, 1.0, 1.0, 1.0, 1.0, 1.0
+ @params = @channels, *@inputs
+ end
+
+ it_should_behave_like 'Buffer reader Ugen with control rate'
+ it_should_behave_like 'Buffer reader Ugen with audio rate'
+ end
+
+ describe PlayBuf, 'Four channel' do
+ before do
+ @class = PlayBuf
+ @channels = 4
+ @inputs = 1.0, 1.0, 1.0, 1.0, 1.0, 1.0
+ @params = @channels, *@inputs
+ end
+
+ it_should_behave_like 'Buffer reader Ugen with control rate'
+ it_should_behave_like 'Buffer reader Ugen with audio rate'
+ end
+
+ describe TGrains, 'Two Channel' do
+ before do
+ @class = TGrains
+ @channels = 2
+ @inputs = 1.0, 1.0, 1.0, 1.0
+ @params = @channels, *@inputs
+ end
+
+ it_should_behave_like 'Buffer reader Ugen with audio rate'
+
+ it "should require at least two channels" do
+ lambda { @class.new :audio, 1, *@params[1..-1] }.should raise_error(ArgumentError)
+ end
+ end
+
+ describe TGrains, 'Four Channel' do
+ before do
+ @class = TGrains
+ @channels = 4
+ @inputs = 1.0, 1.0, 1.0, 1.0
+ @params = @channels, *@inputs
+ end
+
+ it_should_behave_like 'Buffer reader Ugen with audio rate'
+
+ it "should require at least two channels" do
+ lambda { @class.new :audio, 1, *@params[1..-1] }.should raise_error(ArgumentError)
+ end
+ end
+
+ describe BufRd, 'Two channel' do
+ before do
+ @class = BufRd
+ @channels = 2
+ @inputs = 1.0, 1.0, 1.0, 1.0
+ @params = @channels, *@inputs
+ end
+
+ it_should_behave_like 'Buffer reader Ugen with control rate'
+ it_should_behave_like 'Buffer reader Ugen with audio rate'
+
+ it "should require audio rate for phase"
+ end
+
+ describe BufRd, 'Four channel' do
+ before do
+ @class = BufRd
+ @channels = 4
+ @inputs = 1.0, 1.0, 1.0, 1.0
+ @params = @channels, *@inputs
+ end
+
+ it_should_behave_like 'Buffer reader Ugen with control rate'
+ it_should_behave_like 'Buffer reader Ugen with audio rate'
+ end
+
+end
+
+describe 'Buffer write Ugens' do
+ shared_examples_for 'Buffer writter Ugen' do
+ before do
+ @buff_ugen = @class.send @method, *@params
+ end
+
+ it "should have correct rate" do
+ @buff_ugen.rate.should == @rate
+ end
+
+ it "should set inputs" do
+ @buff_ugen.inputs.should == @inputs
+ end
+ end
+
+ shared_examples_for 'Buffer writter Ugen with control rate' do
+ before do
+ @rate = :control
+ @method = :kr
+ end
+ it_should_behave_like 'Buffer writter Ugen'
+ end
+
+ shared_examples_for 'Buffer writter Ugen with audio rate' do
+ before do
+ @rate = :audio
+ @method = :ar
+ end
+ it_should_behave_like 'Buffer writter Ugen'
+ end
+
+ describe BufWr, 'array input' do
+ before do
+ @class = BufWr
+ @array = [MockUgen.new(:audio, 1, 2)]*4
+ @inputs = 1, 2, 3, *@array
+ @params = @array, 1, 2, 3
+ end
+ it_should_behave_like 'Buffer writter Ugen with audio rate'
+ it_should_behave_like 'Buffer writter Ugen with control rate'
+
+ it "should require phase to be audio rate"
+ end
+
+ describe BufWr, 'single input' do
+ before do
+ @class = BufWr
+ @array = MockUgen.new(:audio, 1, 2)
+ @inputs = 1, 2, 3, @array
+ @params = @array, 1, 2, 3
+ end
+ it_should_behave_like 'Buffer writter Ugen with audio rate'
+ it_should_behave_like 'Buffer writter Ugen with control rate'
+
+ it "should require phase to be audio rate"
+ end
+
+ describe RecordBuf, 'array input' do
+ before do
+ @class = RecordBuf
+ @array = [MockUgen.new(:audio, 1, 2)]*4
+ @inputs = 1, 2, 3, 4, 5, 6, 7, 8, *@array
+ @params = @array, 1, 2, 3, 4, 5, 6, 7, 8
+ end
+ it_should_behave_like 'Buffer writter Ugen with audio rate'
+ it_should_behave_like 'Buffer writter Ugen with control rate'
+
+ it "should require phase to be audio rate"
+ end
+
+ describe RecordBuf, 'single input' do
+ before do
+ @class = RecordBuf
+ @array = MockUgen.new(:audio, 1, 2)
+ @inputs = 1, 2, 3, 4, 5, 6, 7, 8, @array
+ @params = @array, 1, 2, 3, 4, 5, 6, 7, 8
+ end
+ it_should_behave_like 'Buffer writter Ugen with audio rate'
+ it_should_behave_like 'Buffer writter Ugen with control rate'
+
+ it "should require phase to be audio rate"
+ end
+
+ describe ScopeOut, 'array input' do
+ before do
+ @class = ScopeOut
+ @array = [MockUgen.new(:audio, 1, 2)]*4
+ @inputs = 1, *@array
+ @params = @array, 1
+ end
+ it_should_behave_like 'Buffer writter Ugen with audio rate'
+ it_should_behave_like 'Buffer writter Ugen with control rate'
+
+ it "should require phase to be audio rate"
+ end
+
+ describe ScopeOut, 'single input' do
+ before do
+ @class = ScopeOut
+ @array = MockUgen.new(:audio, 1, 2)
+ @inputs = 1, @array
+ @params = @array, 1
+ end
+ it_should_behave_like 'Buffer writter Ugen with audio rate'
+ it_should_behave_like 'Buffer writter Ugen with control rate'
+
+ it "should require phase to be audio rate"
+ end
+
+ describe Tap, 'single input' do
+ before do
+ @inputs = 5, 1, 0, SampleRate.ir.neg * 3, 1, 0
+ @buff_ugen = Tap.ar( 5, 2, 3 ).first.source
+ end
+
+ it "should be instance of PlayBuf" do
+ @buff_ugen.should be_a(PlayBuf)
+ end
+
+ it "should have correct rate" do
+ @buff_ugen.rate.should == :audio
+ end
+
+ it "should set inputs" do
+ @buff_ugen.inputs.should == @inputs
+ end
+ end
+
+ describe Tap, 'single input' do
+ before do
+ @inputs = 5, 1, 0, SampleRate.ir.neg * 3, 1, 0
+ @channels = 1
+ @proxies = Tap.ar( 5, @channels, 3 )
+ end
+
+ it "should have one proxy" do
+ @proxies.should have(@channels).proxy
+ end
+
+ it "should be instance of PlayBuf" do
+ @proxies.each{ |p| p.source.should be_a(PlayBuf) }
+ end
+
+ it "should have correct rate" do
+ @proxies.each{ |p| p.source.rate.should == :audio }
+ end
+
+ it "should set inputs" do
+ @proxies.each{ |p| p.source.inputs == @inputs }
+ end
+ end
+
+ describe Tap, 'multi input' do
+ before do
+ @inputs = 5, 1, 0, SampleRate.ir.neg * 3, 1, 0
+ @channels = 4
+ @proxies = Tap.ar( 5, @channels, 3 )
+ end
+
+ it "should have one proxy" do
+ @proxies.should have(@channels).proxy
+ end
+
+ it "should be instance of PlayBuf" do
+ @proxies.each{ |p| p.source.should be_a(PlayBuf) }
+ end
+
+ it "should have correct rate" do
+ @proxies.each{ |p| p.source.rate.should == :audio }
+ end
+
+ it "should set inputs" do
+ @proxies.each{ |p| p.source.inputs == @inputs }
+ end
+ end
+
+ #LocalBuf
+ #MaxLocalBufs
+ #ClearBuf
+end
View
2  spec/buffer_spec.rb
@@ -9,6 +9,8 @@
require "scruby/server"
require File.join( File.expand_path(File.dirname(__FILE__)), "server")
+
+
include Scruby
View
1  spec/core_ext/core_ext_spec.rb
@@ -1,6 +1,7 @@
require File.expand_path(File.dirname(__FILE__)) + "/../helper"
+
describe Numeric do
before :all do
@bin_op = mock 'binop'
View
10 spec/core_ext/delegator_array_spec.rb
@@ -12,6 +12,10 @@
include Scruby
include Ugens
+class MockUgen < Ugen
+ class << self; public :new; end
+end
+
class SinOsc < Ugen
class << self
@@ -92,12 +96,12 @@ class Env; end
end
it "should blow pass nil" do
- actual = eval %{ d(1,2,3) #{ @op } Ugen.new(:audio, 2)}
- expected = BinaryOpUGen.new(@op.to_sym, [1,2,3], Ugen.new(:audio, 2) )
+ actual = eval %{ d(1,2,3) #{ @op } MockUgen.new(:audio, 2)}
+ expected = BinaryOpUGen.new(@op.to_sym, [1,2,3], MockUgen.new(:audio, 2) )
actual.should == expected
end
- it "should allow passing an Ugen Array" do
+ it "should allow passing an MockUgen Array" do
eval %{ SinOsc.ar([100, [100, 100]]) #{@op} SinOsc.ar }
end
end
View
22 spec/in_out_spec.rb
@@ -17,12 +17,8 @@ def self.ar freq = 440.0, phase = 0.0
end
end
-describe In, Out, 'instantiation' do
-
- it "should not instantiate with #new" do
- lambda { In.new :audio, 1, 2 }.should raise_error
- lambda { Out.new :audio, 1, 2 }.should raise_error
- end
+class MockUgen < Ugen
+ class << self; public :new; end
end
describe In do
@@ -71,7 +67,7 @@ def self.ar freq = 440.0, phase = 0.0
end
it "should accept one ugen" do
- @ugen1 = Ugen.new :audio
+ @ugen1 = MockUgen.new :audio
Out.kr( 1, @ugen1 ).should == 0.0
@@ -84,9 +80,9 @@ def self.ar freq = 440.0, phase = 0.0
end
it "should accept several inputs from array" do
- @ugen1 = Ugen.new :audio
- @ugen2 = Ugen.new :audio
- @ugen3 = Ugen.new :audio
+ @ugen1 = MockUgen.new :audio
+ @ugen2 = MockUgen.new :audio
+ @ugen3 = MockUgen.new :audio
Out.kr 1, [@ugen1, @ugen2, @ugen3]
@sdef.children.should have(4).ugens
@@ -96,9 +92,9 @@ def self.ar freq = 440.0, phase = 0.0
end
it "should accept several inputs" do
- @ugen1 = Ugen.new :audio
- @ugen2 = Ugen.new :audio
- @ugen3 = Ugen.new :audio
+ @ugen1 = MockUgen.new :audio
+ @ugen2 = MockUgenMockUgen.new :audio
+ @ugen3 = MockUgenMockUgen.new :audio
Out.kr 1, @ugen1, @ugen2, @ugen3
@sdef.children.should have(4).ugens
View
58 spec/multiout_ugen_spec.rb
@@ -9,35 +9,35 @@
include Scruby
include Ugens
-describe MultiOutUgen do
- before do
- sdef = mock( 'sdef', :children => [] )
- Ugen.should_receive( :synthdef ).and_return( sdef )
- @proxies = MultiOutUgen.new( :audio, 1, 2, 3 )
- @multi = sdef.children.first
- end
-
- it "should return an array of channels" do
- @proxies.should be_instance_of( Array )
- @proxies.should == [1,2,3]
- end
-
- it "should be instace of Control" do
- @multi.should be_instance_of( MultiOutUgen )
- end
-
- it do
- @multi.rate.should == :audio
- end
-
- it do
- @multi.channels.should == [1,2,3]
- end
-
- it do
- @multi.inputs.should == []
- end
-end
+# describe MultiOut do
+# before do
+# sdef = mock( 'sdef', :children => [] )
+# Ugen.should_receive( :synthdef ).and_return( sdef )
+# @proxies = MultiOutUgen.new( :audio, 1, 2, 3 )
+# @multi = sdef.children.first
+# end
+#
+# it "should return an array of channels" do
+# @proxies.should be_instance_of( Array )
+# @proxies.should == [1,2,3]
+# end
+#
+# it "should be instace of Control" do
+# @multi.should be_instance_of( MultiOutUgen )
+# end
+#
+# it do
+# @multi.rate.should == :audio
+# end
+#
+# it do
+# @multi.channels.should == [1,2,3]
+# end
+#
+# it do
+# @multi.inputs.should == []
+# end
+# end
describe Control do
before do
View
12 spec/operation_ugens_spec.rb
@@ -11,14 +11,18 @@
include Scruby
include Ugens
+class MockUgen < Ugen
+ class << self; public :new; end
+end
+
describe UnaryOpUGen do
::RATES = :scalar, :demand, :control, :audio
before do
- @scalar = Ugen.new :scalar
- @demand = Ugen.new :demand
- @control = Ugen.new :control
- @audio = Ugen.new :audio
+ @scalar = MockUgen.new :scalar
+ @demand = MockUgenMockUgen.new :demand
+ @control = MockUgenMockUgen.new :control
+ @audio = MockUgenMockUgen.new :audio
end
describe UnaryOpUGen do
View
224 spec/panner_spec.rb
@@ -0,0 +1,224 @@
+require File.expand_path(File.dirname(__FILE__)) + "/helper"
+
+require "scruby/control_name"
+require "scruby/env"
+require "scruby/ugens/ugen"
+require "scruby/ugens/ugen_operations"
+require "scruby/ugens/multi_out_ugens"
+require "scruby/ugens/ugens"
+require "scruby/ugens/panner"
+
+include Scruby
+include Ugens
+
+class MockUgen < Ugen
+ class << self; public :new; end
+end
+
+
+describe 'Panner' do
+ shared_examples_for 'Panner' do
+ before do
+ @pan = @class.send @method, *@params
+ @inputs ||= @params
+ @instance = @pan.first.source
+ end
+
+ it "should have correct rate" do
+ @instance.rate.should == @rate
+ end
+
+ it "should return an array of output proxies" do
+ @pan.should be_a(Array)
+ @pan.should have(@channels).proxies
+ @pan.each_with_index do |proxy, i|
+ proxy.source.should be_a(@class)
+ proxy.should be_a(OutputProxy)
+ proxy.output_index.should == i
+ end
+ end
+
+ it "should set inputs" do
+ @instance.inputs.should == @inputs
+ end
+
+ it "should accept control rate inputs unless rate is audio" do
+ @class.new :control, 1, MockUgen.new(:control), MockUgen.new(:audio)
+ end
+ end
+
+ shared_examples_for 'Panner with control rate' do
+ before do
+ @method = :kr
+ @rate = :control
+ end
+ it_should_behave_like 'Panner'
+ end
+
+ shared_examples_for 'Panner with audio rate' do
+ before do
+ @method = :ar
+ @rate = :audio
+ end
+ it_should_behave_like 'Panner'
+
+ it "should just accept audio inputs if rate is audio" # do
+ # lambda { @class.new( :audio, MockUgen.new(:control) ) }.should raise_error(ArgumentError)
+ # end
+ end
+
+
+ describe Pan2 do
+ before do
+ @class = Pan2
+ @ugen = MockUgen.new :audio, 1, 2
+ @params = @ugen, 0.5, 1.0
+ @channels = 2
+ end
+ it_should_behave_like 'Panner with audio rate'
+ it_should_behave_like 'Panner with control rate'
+
+ it "should have keyword args" do
+ @class.ar( @ugen, :level => 2.0 ).first.source.inputs.should == [@ugen, 0.0, 2.0]
+ end
+ end
+
+ describe LinPan2 do
+ before do
+ @class = LinPan2
+ @ugen = MockUgen.new :audio, 1, 2
+ @params = @ugen, 0.5, 1.0
+ @channels = 2
+ end
+ it_should_behave_like 'Panner with audio rate'
+ it_should_behave_like 'Panner with control rate'
+
+ it "should have keyword args" do
+ @class.ar( @ugen, :level => 2.0 ).first.source.inputs.should == [@ugen, 0.0, 2.0]
+ end
+ end
+
+ describe Pan4 do
+ before do
+ @class = Pan4
+ @ugen = MockUgen.new :audio, 1, 2
+ @params = @ugen, 0.5, 0.5, 1.0
+ @channels = 4
+ end
+ it_should_behave_like 'Panner with audio rate'
+ it_should_behave_like 'Panner with control rate'
+
+ it "should have keyword args" do
+ @class.ar( @ugen, :level => 2.0 ).first.source.inputs.should == [@ugen, 0.0, 0.0, 2.0]
+ end
+ end
+
+ describe Balance2 do
+ before do
+ @class = Balance2
+ @ugen = MockUgen.new :audio, 1, 2
+ @ugen2 = MockUgen.new(:audio, 2, 4)
+ @params = @ugen, @ugen2, 0.5, 1.0
+ @channels = 2
+ end
+ it_should_behave_like 'Panner with audio rate'
+ it_should_behave_like 'Panner with control rate'
+
+ it "should have keyword args" do
+ @class.ar( @ugen, @ugen2 , :level => 2.0 ).first.source.inputs.should == [@ugen, @ugen2 , 0.0, 2.0]
+ end
+ end
+
+ describe Rotate2 do
+ before do
+ @class = Rotate2
+ @ugen = MockUgen.new :audio, 1, 2
+ @ugen2 = MockUgen.new :audio, 2, 4
+ @params = @ugen, @ugen2, 0.5
+ @channels = 2
+ end
+ it_should_behave_like 'Panner with audio rate'
+ it_should_behave_like 'Panner with control rate'
+ # it "should have keyword args" do
+ # @class.ar( @ugen, @ugen2 , :level => 2.0 ).first.source.inputs.should == [@ugen, @ugen2 , 0.0, 2.0]
+ # end
+ end
+
+ describe PanB do
+ before do
+ @class = PanB
+ @ugen = MockUgen.new :audio, 1, 2
+ @params = @ugen, 0.5, 0.5, 1.0
+ @channels = 4
+ end
+ it_should_behave_like 'Panner with audio rate'
+ it_should_behave_like 'Panner with control rate'
+ # it "should have keyword args" do
+ # @class.ar( @ugen, @ugen2 , :level => 2.0 ).first.source.inputs.should == [@ugen, @ugen2 , 0.0, 2.0]
+ # end
+ end
+
+ describe PanB2 do
+ before do
+ @class = PanB2
+ @ugen = MockUgen.new :audio, 1, 2
+ @params = @ugen, 0.5, 1.0
+ @channels = 3
+ end
+ it_should_behave_like 'Panner with audio rate'
+ it_should_behave_like 'Panner with control rate'
+
+ # it "should have keyword args" do
+ # @class.ar( @ugen, @ugen2 , :level => 2.0 ).first.source.inputs.should == [@ugen, @ugen2 , 0.0, 2.0]
+ # end
+ end
+
+ describe BiPanB2 do
+ before do
+ @class = BiPanB2
+ @ugen2 = MockUgen.new(:audio, 2, 4)
+ @ugen = MockUgen.new :audio, 1, 2
+ @params = @ugen, @ugen2, 0.5, 0.5
+ @channels = 3
+ end
+ it_should_behave_like 'Panner with audio rate'
+ it_should_behave_like 'Panner with control rate'
+ # it "should have keyword args" do
+ # @class.ar( @ugen, @ugen2 , :level => 2.0 ).first.source.inputs.should == [@ugen, @ugen2 , 0.0, 2.0]
+ # end
+ end
+
+ describe DecodeB2, 'five channels' do
+ before do
+ @class = DecodeB2
+ @params = 5, 0.5, 0.5, 0.5, 0.5
+ @inputs = 0.5, 0.5, 0.5, 0.5
+ @channels = 5
+ end
+ it_should_behave_like 'Panner with audio rate'
+ it_should_behave_like 'Panner with control rate'
+ end
+
+ describe DecodeB2, 'seven channels' do
+ before do
+ @class = DecodeB2
+ @params = 7, 0.5, 0.5, 0.5, 0.5
+ @inputs = 0.5, 0.5, 0.5, 0.5
+ @channels = 7
+ end
+ it_should_behave_like 'Panner with audio rate'
+ it_should_behave_like 'Panner with control rate'
+ end
+
+ describe PanAz, 'five channels' do
+ before do
+ @class = PanAz
+ @ugen = MockUgen.new(:audio, 1, 2)
+ @params = 5, @ugen, 0.5, 0.5, 0.5, 0.5
+ @inputs = @ugen, 0.5, 0.5, 0.5, 0.5
+ @channels = 5
+ end
+ it_should_behave_like 'Panner with audio rate'
+ it_should_behave_like 'Panner with control rate'
+ end
+end
View
8 spec/synthdef_spec.rb
@@ -11,6 +11,10 @@
include Scruby
include Ugens
+class MockUgen < Ugen
+ class << self; public :new; end
+end
+
describe SynthDef, 'instantiation' do
@@ -159,12 +163,12 @@
end
it "should collect constants for simple children array" do
- children = [Ugen.new(:audio, 100), Ugen.new(:audio, 200), Ugen.new(:audio, 100, 300)]
+ children = [MockUgen.new(:audio, 100), MockUgen.new(:audio, 200), MockUgen.new(:audio, 100, 300)]
@sdef.send_msg( :collect_constants, children).should == [100.0, 200.0, 300.0]
end
it "should collect constants for children arrays" do
- children = [ Ugen.new(:audio, 100), [ Ugen.new(:audio, 400), [ Ugen.new(:audio, 200), Ugen.new(:audio, 100, 300) ] ] ]
+ children = [ MockUgen.new(:audio, 100), [ MockUgen.new(:audio, 400), [ MockUgen.new(:audio, 200), MockUgen.new(:audio, 100, 300) ] ] ]
@sdef.send_msg( :collect_constants, children).should == [100.0, 400.0, 200.0, 300.0]
end
View
10 spec/ugen_operations_spec.rb
@@ -12,11 +12,15 @@
include Scruby
include Ugens
+class MockUgen < Ugen
+ class << self; public :new; end
+end
+
describe UgenOperations do
before do
- @ugen = Ugen.new :audio
- @ugen2 = Ugen.new :audio
+ @ugen = MockUgen.new :audio
+ @ugen2 = MockUgen.new :audio
end
describe 'binary operations' do
@@ -71,7 +75,7 @@
describe DelegatorArray do
before do
- @ugen = Ugen.new :audio
+ @ugen = MockUgen.new :audio
end
it "do binary operation" do
View
102 spec/ugen_spec.rb
@@ -17,6 +17,10 @@
include Scruby
include Ugens
+class MockUgen < Ugen
+ class << self; public :new; end
+end
+
class SinOsc < Ugen
class << self
def ar freq = 440.0, phase = 0.0 #not interested in muladd by now
@@ -59,7 +63,7 @@ def as_ugen_input; 0; end
end
it "should use buffnum as input when a buffer is passed" do
- Ugen.new( :audio, Buffer.new ).inputs.should == [0]
+ MockUgen.new( :audio, Buffer.new ).inputs.should == [0]
end
describe 'attributes' do
@@ -99,16 +103,16 @@ def as_ugen_input; 0; end
describe 'ugen graph in synth def' do
before do
Ugen.synthdef = nil
- @ugen = Ugen.new( :audio, 1, 2 )
- @ugen2 = Ugen.new( :audio, 1, 2 )
+ @ugen = MockUgen.new( :audio, 1, 2 )
+ @ugen2 = MockUgen.new( :audio, 1, 2 )
end
it "should not have synthdef" do
- Ugen.new( :audio, 1, 2 ).send( :synthdef ).should be_nil
+ MockUgen.new( :audio, 1, 2 ).send( :synthdef ).should be_nil
end
it "should have 0 as index if not belonging to ugen" do
- Ugen.new( :audio, 1, 2 ).index.should be_zero
+ MockUgen.new( :audio, 1, 2 ).index.should be_zero
end
it "should have synthdef" do
@@ -122,14 +126,14 @@ def as_ugen_input; 0; end
it "should add to synth def on instantiation" do
Ugen.synthdef = @sdef
- ugen = Ugen.new( :audio, 1, 2)
+ ugen = MockUgen.new( :audio, 1, 2)
ugen.send( :synthdef ).should == @sdef
@sdef.children.should == [ugen]
end
it "should add to synthdef and return synthdef.children size" do
Ugen.synthdef = @sdef
- ugen, ugen2 = Ugen.new(:audio, 1, 2), Ugen.new(:audio, 1, 2)
+ ugen, ugen2 = MockUgen.new(:audio, 1, 2), MockUgen.new(:audio, 1, 2)
@sdef.children.should eql( [ugen, ugen2] )
ugen.index.should == 0
ugen2.index.should == 1
@@ -138,60 +142,60 @@ def as_ugen_input; 0; end
it "should not add to synthdef" do
Ugen.synthdef = nil
@sdef.children.should_not_receive( :<< )
- Ugen.new( :audio, 1, 2 ).send( :add_to_synthdef ).should eql( nil )
+ MockUgen.new( :audio, 1, 2 ).send( :add_to_synthdef ).should eql( nil )
end
it "should collect constants" do
- Ugen.new( :audio, 100, @ugen, 200 ).send( :collect_constants ).flatten.sort.should == [1, 2, 100, 200]
+ MockUgen.new( :audio, 100, @ugen, 200 ).send( :collect_constants ).flatten.sort.should == [1, 2, 100, 200]
end
it "should collect constants on arrayed inputs" do
- Ugen.new( :audio, 100, [@ugen, [200, @ugen2, 100] ] ).send( :collect_constants ).flatten.uniq.sort.should == [1, 2, 100, 200]
+ MockUgen.new( :audio, 100, [@ugen, [200, @ugen2, 100] ] ).send( :collect_constants ).flatten.uniq.sort.should == [1, 2, 100, 200]
end
end
describe 'initialization and inputs' do
before do
- @ugen = Ugen.new(:audio, 1, 2, 3)
+ @ugen = MockUgen.new(:audio, 1, 2, 3)
end
it "should not accept non valid inputs" do
- lambda{ @ugen = Ugen.new(:audio, "hola") }.should raise_error( ArgumentError )
+ lambda{ @ugen = MockUgen.new(:audio, "hola") }.should raise_error( ArgumentError )
end
it "should require at least one argument" do
- lambda { Ugen.new }.should raise_error( ArgumentError )
+ lambda { MockUgen.new }.should raise_error( ArgumentError )
end
it "should be a defined rate as the first argument" do
- lambda { Ugen.new( :not_a_rate, 1 ) }.should raise_error( ArgumentError )
+ lambda { MockUgen.new( :not_a_rate, 1 ) }.should raise_error( ArgumentError )
end
it "should use the highest rate when passing an array" do
- Ugen.new([:audio, :control], 1).rate.should == :audio
+ MockUgen.new([:audio, :control], 1).rate.should == :audio
end
it "should be a defined rate as array" do
- lambda { Ugen.new( [:not_a_rate, :audio], 1 ) }.should raise_error( ArgumentError )
+ lambda { MockUgen.new( [:not_a_rate, :audio], 1 ) }.should raise_error( ArgumentError )
end
it "should accept an empty array for inputs and inputs should be an empty array" do
- Ugen.new( :audio, [] ).inputs.should eql([])
+ MockUgen.new( :audio, [] ).inputs.should eql([])
end
it "should instantiate" do
- Ugen.new( :audio, 1, 2 ).should be_instance_of( Ugen )
+ MockUgen.new( :audio, 1, 2 ).should be_instance_of( MockUgen )
end
it "should accept any number of args" do
- Ugen.new( :audio, 1, 2 )
- Ugen.new( :audio, 1, 2, 3, 4 )
+ MockUgen.new( :audio, 1, 2 )
+ MockUgen.new( :audio, 1, 2, 3, 4 )
end
it "should description" do
- Ugen.should_receive( :instantiate ).with( :audio, 1, 2 )
- Ugen.new( :audio, 1, 2 )
+ MockUgen.should_receive( :instantiate ).with( :audio, 1, 2 )
+ MockUgen.new( :audio, 1, 2 )
end
it "should set inputs" do
@@ -203,8 +207,8 @@ def as_ugen_input; 0; end
end
it "should have empty inputs" do
- Ugen.new( :audio ).inputs.should == []
- Ugen.new( :audio, [] ).inputs.should == []
+ MockUgen.new( :audio ).inputs.should == []
+ MockUgen.new( :audio, [] ).inputs.should == []
end
end
@@ -218,63 +222,63 @@ def as_ugen_input; 0; end
end
it "should not care if an array was passed" do
- Ugen.new( :audio, [1, 2, 3] ).should be_instance_of(Ugen)
+ MockUgen.new( :audio, [1, 2, 3] ).should be_instance_of(MockUgen)
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(DelegatorArray)
+ MockUgen.new( :audio, 1, [2, 3] ).should be_instance_of(DelegatorArray)
end
it do
- Ugen.new( :audio, 1, [2,3], [4,5] ).should have( 2 ).items
+ MockUgen.new( :audio, 1, [2,3], [4,5] ).should have( 2 ).items
end
it do
- Ugen.new( :audio, 1, [2,3, 3], [4,5] ).should have( 3 ).items
+ MockUgen.new( :audio, 1, [2,3, 3], [4,5] ).should have( 3 ).items
end
it "should return an array of ugens" do
- ugens = Ugen.new( :audio, 100, [210, 220, 230, 240] )
+ ugens = MockUgen.new( :audio, 100, [210, 220, 230, 240] )
ugens.each do |u|
- u.should be_instance_of(Ugen)
+ u.should be_instance_of(MockUgen)
end
end
it "should return ugen" do
- ugen = Ugen.new( :audio, [1], [2] )
- ugen.should be_instance_of( Ugen )
+ ugen = MockUgen.new( :audio, [1], [2] )
+ ugen.should be_instance_of( MockUgen )
ugen.inputs.should == [1, 2]
end
it "should return ugen" do
- ugen = Ugen.new( :audio, [1, 2] )
- ugen.should be_instance_of( Ugen )
+ ugen = MockUgen.new( :audio, [1, 2] )
+ ugen.should be_instance_of( MockUgen )
ugen.inputs.should == [1, 2]
end
it "should make multichannel array (DelegatorArray)" do
- multichannel = Ugen.new( :audio, 100, [210, 220] )
+ multichannel = MockUgen.new( :audio, 100, [210, 220] )
multichannel.should be_a(DelegatorArray)
- multichannel.should == d(Ugen.new(:audio, 100, 210), Ugen.new(:audio, 100, 220))
+ multichannel.should == d(MockUgen.new(:audio, 100, 210), MockUgen.new(:audio, 100, 220))
end
it "should accept DelegatorArray as inputs" do
- multichannel = Ugen.new( :audio, 100, d(210, 220) )
+ multichannel = MockUgen.new( :audio, 100, d(210, 220) )
multichannel.should be_a(DelegatorArray)
- multichannel.should == d(Ugen.new(:audio, 100, 210), Ugen.new(:audio, 100, 220))
+ multichannel.should == d(MockUgen.new(:audio, 100, 210), MockUgen.new(:audio, 100, 220))
end
it "should instantiate with correct arguments" do
- Ugen.should_receive(:instantiate).with( :audio, *@i_1 )
- Ugen.should_receive(:instantiate).with( :audio, *@i_2 )
- Ugen.should_receive(:instantiate).with( :audio, *@i_3 )
- Ugen.should_receive(:instantiate).with( :audio, *@i_4 )
- ugens = Ugen.new( :audio, 100, [210, 220, 230, 240] )
+ MockUgen.should_receive(:instantiate).with( :audio, *@i_1 )
+ MockUgen.should_receive(:instantiate).with( :audio, *@i_2 )
+ MockUgen.should_receive(:instantiate).with( :audio, *@i_3 )
+ MockUgen.should_receive(:instantiate).with( :audio, *@i_4 )
+ ugens = MockUgen.new( :audio, 100, [210, 220, 230, 240] )
ugens.should have(4).ugens
end
it "should return an delegator array of ugens with correct inputs" do
- ugens = Ugen.new( :audio, 100, [210, 220, 230, 240] )
+ ugens = MockUgen.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 )
end
@@ -282,9 +286,9 @@ def as_ugen_input; 0; end
it "should match the structure of the inputs array(s)" do
array = [ 200, [210, [220, 230] ] ]
- ugens = Ugen.new( :audio, 100, array )
+ ugens = MockUgen.new( :audio, 100, array )
last = lambda do |i|
- if i.instance_of?(Ugen)
+ if i.instance_of?(MockUgen)
i.inputs.first.should == 100
i.inputs.last
else
@@ -295,12 +299,12 @@ def as_ugen_input; 0; end
end
it "should return muladd" do
- @ugen = Ugen.new(:audio, 100, 100)
+ @ugen = MockUgen.new(:audio, 100, 100)
@ugen.muladd(0.5, 0.5).should be_a(MulAdd)
end
it "should return an arrayed muladd" do
- @ugen = Ugen.new(:audio, [100,100], 100)
+ @ugen = MockUgen.new(:audio, [100,100], 100)
@ugen.muladd(0.5, 0.5).should be_a(DelegatorArray)
end
end
@@ -357,7 +361,7 @@ def as_ugen_input; 0; end
end
it "should equal to a similar" do
- Ugen.new(:audio, 1, 2).should == Ugen.new(:audio, 1, 2)
+ MockUgen.new(:audio, 1, 2).should == MockUgen.new(:audio, 1, 2)
end
end
end
View
40 spec/ugens_spec.rb
@@ -46,26 +46,26 @@ class Klass
lambda { Gendy1.ar }.should raise_error(ArgumentError)
end
- it "should print params" do
- PanAz.params.should == {
- :audio => [
- [:input, nil],
- [:pos, 0],
- [:level, 1],
- [:width, 2],
- [:orientation, 0.5],
- [:mul, 1],
- [:add, 0] ],
- :control => [
- [:input, nil],
- [:pos, 0],
- [:level, 1],
- [:width, 2],
- [:orientation, 0.5],
- [:mul, 1],
- [:add, 0] ]}
- end
-
+ # it "should print params" do
+ # PanAz.params.should == {
+ # :audio => [
+ # [:input, nil],
+ # [:pos, 0],
+ # [:level, 1],
+ # [:width, 2],
+ # [:orientation, 0.5],
+ # [:mul, 1],
+ # [:add, 0] ],
+ # :control => [
+ # [:input, nil],
+ # [:pos, 0],
+ # [:level, 1],
+ # [:width, 2],
+ # [:orientation, 0.5],
+ # [:mul, 1],
+ # [:add, 0] ]}
+ # end
+
# it "should work with arrays"
end
Please sign in to comment.
Something went wrong with that request. Please try again.