Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

… SetTempo.
  • Loading branch information...
commit 61bcf339c2896b13763e1d0b00f1d07f4a096042 1 parent ba072f8
Jeremy Voorhis authored
View
4 lib/music.rb
@@ -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
7 lib/music/score.rb
@@ -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
4 lib/music/smf_writer.rb
@@ -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
2  spec/attribute_spec.rb
@@ -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
6 spec/score_spec.rb
@@ -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
2  spec/temporal_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.