music-transcription 0.5.11 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 693041857559185a3b35e513e64f5d0ec39b7d7f
4
- data.tar.gz: 815fcf70a4a859adcb043b7d34cfb093f492ca71
3
+ metadata.gz: 9e5ce482a31fa5f96be5e43f326fcee0dc743999
4
+ data.tar.gz: 55401ebda9f844af86fd799ce230f7cc7a98eea3
5
5
  SHA512:
6
- metadata.gz: 98e2b0d53a98619aa58e3e376ede9557e59b7b3d36d19791b749388ba64b54a416db2246eb9fb533fa40b890459743c6f764d2d40af28078be96e49047ebd2a7
7
- data.tar.gz: fbe7411e757ca16a46b86d6a97ab2fde24931a620c394e37f2d69a1818dad8a364523da242f40155a725077f9707b432128e92a7951622fd8a666fb12b267449
6
+ metadata.gz: 93e176daaf8376649eea0ff8124e84a0cd774ed5fcb8e9196b1f05b06a7bb22086bc74e54c833aedac7b09e46f22a245bbc2cfd693a13a5a66d31fe0b00b84a8
7
+ data.tar.gz: 30fba405514a07bb81e0df8c54e1a71307252ca6133b255c06ea1222299a4ee8427552d8c2d9dd0f2d9088cdb1d153e798b31df66427a10cbbd726b3edfa3051
@@ -2,25 +2,32 @@ module Music
2
2
  module Transcription
3
3
 
4
4
  class Change
5
- attr_accessor :value
5
+ attr_accessor :value, :duration
6
6
 
7
- def initialize value
7
+ def initialize value, duration
8
8
  @value = value
9
+ @duration = duration
10
+
11
+ unless duration >= 0
12
+ raise ArgumentError, "duration #{duration} must be >= 0"
13
+ end
9
14
  end
10
15
 
11
16
  def ==(other)
12
- self.class == other.class && self.value == other.value
17
+ self.class == other.class &&
18
+ self.value == other.value &&
19
+ self.duration == other.duration
13
20
  end
14
21
 
15
22
  class Immediate < Change
16
23
  def initialize value
17
- super(value)
24
+ super(value,0)
18
25
  end
19
26
  end
20
27
 
21
28
  class Gradual < Change
22
- def initialize value
23
- super(value)
29
+ def initialize value, transition_duration
30
+ super(value, transition_duration)
24
31
  end
25
32
  end
26
33
  end
@@ -2,6 +2,6 @@
2
2
  module Music
3
3
  module Transcription
4
4
  # music-transcription version
5
- VERSION = "0.5.11"
5
+ VERSION = "0.6.0"
6
6
  end
7
7
  end
@@ -0,0 +1,49 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Change::Immediate do
4
+ context '.new' do
5
+ it 'should set value to given' do
6
+ Change::Immediate.new(5).value.should eq 5
7
+ end
8
+
9
+ it 'should set duration to 0' do
10
+ Change::Immediate.new(5).duration.should eq 0
11
+ end
12
+ end
13
+
14
+ describe '==' do
15
+ it 'should return true if two immediate changes have the same value' do
16
+ Change::Immediate.new(5).should eq(Change::Immediate.new(5))
17
+ end
18
+
19
+ it 'should return false if two immediate changes do not have the same value' do
20
+ Change::Immediate.new(5).should_not eq(Change::Immediate.new(4))
21
+ end
22
+ end
23
+ end
24
+
25
+ describe Change::Gradual do
26
+ context '.new' do
27
+ it 'should set value to given value' do
28
+ Change::Gradual.new(5,2).value.should eq 5
29
+ end
30
+
31
+ it 'should set duration to given duration' do
32
+ Change::Gradual.new(5,2).duration.should eq 2
33
+ end
34
+ end
35
+
36
+ describe '==' do
37
+ it 'should return true if two gradual changes have the same value and duration' do
38
+ Change::Gradual.new(5,2).should eq(Change::Gradual.new(5,2))
39
+ end
40
+
41
+ it 'should return false if two gradual changes do not have the same value' do
42
+ Change::Gradual.new(5,2).should_not eq(Change::Gradual.new(4,2))
43
+ end
44
+
45
+ it 'should return false if two gradual changes do not have the same duration' do
46
+ Change::Gradual.new(5,2).should_not eq(Change::Gradual.new(5,1))
47
+ end
48
+ end
49
+ end
data/spec/part_spec.rb CHANGED
@@ -77,15 +77,15 @@ describe Part do
77
77
  notes: [Note::Whole.new],
78
78
  dynamic_profile: Profile.new(
79
79
  Dynamics::PPP,
80
- Rational(1,8) => Change::Gradual.new(Dynamics::PP),
81
- Rational(2,8) => Change::Immediate.new(Dynamics::P)
80
+ Rational(1,8) => Change::Gradual.new(Dynamics::PP,Rational(1,8)),
81
+ Rational(3,8) => Change::Immediate.new(Dynamics::P)
82
82
  )
83
83
  )
84
84
  p1.append! p2
85
85
  p1.dynamic_profile.value_changes.size.should eq 3
86
86
  p1.dynamic_profile.value_changes[Rational(1,1)].value.should eq Dynamics::PPP
87
87
  p1.dynamic_profile.value_changes[Rational(9,8)].value.should eq Dynamics::PP
88
- p1.dynamic_profile.value_changes[Rational(10,8)].value.should eq Dynamics::P
88
+ p1.dynamic_profile.value_changes[Rational(11,8)].value.should eq Dynamics::P
89
89
  end
90
90
  end
91
91
  end
data/spec/profile_spec.rb CHANGED
@@ -118,7 +118,7 @@ describe Profile do
118
118
  describe '#append!' do
119
119
  before :each do
120
120
  @p1 = Profile.new(0.0, 5.0 => Change::Immediate.new(0.1), 7.5 => Change::Immediate.new(0.2))
121
- @p2 = Profile.new(0.2, 1.0 => Change::Immediate.new(0.0), 2.0 => Change::Gradual.new(100.0))
121
+ @p2 = Profile.new(0.2, 1.0 => Change::Immediate.new(0.0), 2.0 => Change::Gradual.new(100.0,1.0))
122
122
  @p3 = Profile.new(0.1, 1.0 => Change::Immediate.new(0.0))
123
123
  end
124
124
 
data/spec/score_spec.rb CHANGED
@@ -14,7 +14,7 @@ describe Score do
14
14
  end
15
15
 
16
16
  it "should assign tempo profile given during construction" do
17
- profile = Profile.new(Tempo.new(200), { 0.5 => Change::Gradual.new(120) })
17
+ profile = Profile.new(Tempo.new(200), 0.5 => Change::Gradual.new(Tempo.new(120),0.5) )
18
18
  score = Score.new tempo_profile: profile
19
19
  score.tempo_profile.should eq(profile)
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: music-transcription
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.11
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Tunnell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-16 00:00:00.000000000 Z
11
+ date: 2014-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -163,6 +163,7 @@ files:
163
163
  - samples/arrangements/slur_test.yml
164
164
  - samples/arrangements/song1.yml
165
165
  - samples/arrangements/song2.yml
166
+ - spec/change_spec.rb
166
167
  - spec/link_spec.rb
167
168
  - spec/music-transcription_spec.rb
168
169
  - spec/note_spec.rb
@@ -199,6 +200,7 @@ specification_version: 4
199
200
  summary: Classes for representing music notational features like pitch, note, loudness,
200
201
  tempo, etc.
201
202
  test_files:
203
+ - spec/change_spec.rb
202
204
  - spec/link_spec.rb
203
205
  - spec/music-transcription_spec.rb
204
206
  - spec/note_spec.rb