Permalink
Browse files

Changed attribute layout of Controller. Converting bpm to qn/usec for…

… SetTempo.
  • Loading branch information...
Jeremy Voorhis
Jeremy Voorhis committed Nov 18, 2008
1 parent ba072f8 commit 61bcf339c2896b13763e1d0b00f1d07f4a096042
Showing with 12 additions and 13 deletions.
  1. +2 −2 lib/music.rb
  2. +3 −4 lib/music/score.rb
  3. +2 −2 lib/music/smf_writer.rb
  4. +1 −1 spec/attribute_spec.rb
  5. +3 −3 spec/score_spec.rb
  6. +1 −1 spec/temporal_spec.rb
View
@@ -149,7 +149,7 @@ def env(&fn) Env.new(&fn) end
=end
- def ctl(name, value, attrs = {})
- Controller.new(name, value, attrs)
+ def ctl(name, attrs = {})
+ Controller.new(name, attrs)
end
end
View
@@ -325,8 +325,8 @@ class Controller < ScoreObject
include Instant
attr_reader :attributes
- def initialize(name, data, attrs = {})
- @attributes = attrs.merge(:name => name, :data => Array(data))
+ def initialize(name, as = {})
+ @attributes = as.merge(:name => name)
end
def ==(other)
@@ -339,8 +339,7 @@ def ==(other)
def update(key, val)
a = attributes.merge(key => val)
- n, v = attributes.values_at(:name, :value)
- self.class.new(n, v, a)
+ self.class.new(name, a)
end
def eval(interpreter, context)
View
@@ -64,9 +64,9 @@ def write_controller(track, ctl, time)
track << case ctl.name.to_s
when 'tempo'
- SetTempo.new(offset, ctl.data[0])
+ SetTempo.new(offset, bpm_to_qn_per_usec(ctl.tempo))
when /^cc(0?[1-9]|1[0-6])$/
- ControlChange.new(offset, channel, $1, ctl.data[0])
+ ControlChange.new(offset, channel, $1, ctl.value)
end
end
end
View
@@ -52,7 +52,7 @@
describe Controller do
before(:all) do
- @object = Controller.new(60, 1)
+ @object = Controller.new(:cc1, :value => 64)
end
it_should_behave_like "all attributes implementations"
end
View
@@ -226,13 +226,13 @@
describe Controller do
before(:all) do
- @object = Controller.new(:tempo, 120)
+ @object = Controller.new(:tempo, :tempo => 120)
end
it_should_behave_like "all scores"
-
+
it "should carry associated data" do
- @object.data.should == [120]
+ @object.tempo.should == 120
end
end
View
@@ -107,7 +107,7 @@
describe Controller do
before(:all) do
@dur = 0
- @object = ctl(:tempo, 120)
+ @object = ctl(:tempo, :tempo => 120)
end
it_should_behave_like "all temporal objects"
end

0 comments on commit 61bcf33

Please sign in to comment.