music-transcription 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/music-transcription/note.rb +7 -5
- data/lib/music-transcription/validatable.rb +9 -4
- data/lib/music-transcription/version.rb +1 -1
- data/spec/meter_spec.rb +2 -2
- data/spec/note_spec.rb +8 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bbc3d1440e2ac88166f035060fda110df18aeb5
|
4
|
+
data.tar.gz: 53b0c934d092ca5a176a481b1a00a532e4201ea7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec1b59468978c4561be944b5c4f61f892399e34a72f5bc790037f3c67f297e64ae7d625a1a69a7cb967239fc20e432d5d2aebe1d9358d792d56cc573747b05a4
|
7
|
+
data.tar.gz: 5bd9cd9b7dd02043d28c94ca569ecef5ae1e0ae5dd1990a4dff20ce6aaf0207fb94811805bfc37c5abf0eede7afbce6fc8963c731abf4327da3347af46b7b3c7
|
@@ -20,7 +20,9 @@ class Note
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def ensure_positive_duration
|
23
|
-
|
23
|
+
unless @duration > 0
|
24
|
+
raise ValueNotPositiveError, "duration #{@duration} is not positive"
|
25
|
+
end
|
24
26
|
end
|
25
27
|
|
26
28
|
def == other
|
@@ -33,6 +35,10 @@ class Note
|
|
33
35
|
def clone
|
34
36
|
Marshal.load(Marshal.dump(self))
|
35
37
|
end
|
38
|
+
|
39
|
+
def clear_links
|
40
|
+
@links = {}
|
41
|
+
end
|
36
42
|
|
37
43
|
def transpose diff
|
38
44
|
self.clone.transpose! diff
|
@@ -62,10 +68,6 @@ class Note
|
|
62
68
|
return self
|
63
69
|
end
|
64
70
|
|
65
|
-
def valid?
|
66
|
-
@duration > 0
|
67
|
-
end
|
68
|
-
|
69
71
|
class Sixteenth < Note
|
70
72
|
def initialize pitches = [], links: {}, accent: Accents::NONE
|
71
73
|
super(Rational(1,16),pitches,links:links,accent:accent)
|
@@ -5,6 +5,7 @@ module Validatable
|
|
5
5
|
|
6
6
|
def validate
|
7
7
|
@errors = []
|
8
|
+
|
8
9
|
@check_methods.each do |check_method|
|
9
10
|
begin
|
10
11
|
send(check_method)
|
@@ -12,14 +13,18 @@ module Validatable
|
|
12
13
|
@errors.push e
|
13
14
|
end
|
14
15
|
end
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
16
|
+
|
17
|
+
validatables.each do |v|
|
18
|
+
@errors += v.validate
|
19
19
|
end
|
20
|
+
|
20
21
|
return @errors
|
21
22
|
end
|
22
23
|
|
24
|
+
def validatables
|
25
|
+
[]
|
26
|
+
end
|
27
|
+
|
23
28
|
def valid?
|
24
29
|
self.validate
|
25
30
|
@errors.empty?
|
data/spec/meter_spec.rb
CHANGED
@@ -58,7 +58,7 @@ describe Meter do
|
|
58
58
|
}.each do |context_str,args|
|
59
59
|
context context_str do
|
60
60
|
it 'should return true' do
|
61
|
-
|
61
|
+
Meter.new(*args).should be_valid
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
@@ -71,7 +71,7 @@ describe Meter do
|
|
71
71
|
}.each do |context_str,args|
|
72
72
|
context context_str do
|
73
73
|
it 'should return false' do
|
74
|
-
|
74
|
+
Meter.new(*args).should be_invalid
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
data/spec/note_spec.rb
CHANGED
@@ -36,6 +36,14 @@ describe Note do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
describe '#clear_links' do
|
40
|
+
it 'should remove all links' do
|
41
|
+
n = Note.new(2,[C2,E2],links: {C2 => Link::Slur.new(D2)})
|
42
|
+
n.clear_links
|
43
|
+
n.links.should be_empty
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
39
47
|
describe '#transpose!' do
|
40
48
|
context 'given pitch diff' do
|
41
49
|
before(:all) do
|
@@ -113,8 +121,6 @@ describe Note do
|
|
113
121
|
context 'note with 0 duration' do
|
114
122
|
it 'should return false' do
|
115
123
|
Note.new(0,[C2]).should be_invalid
|
116
|
-
require 'pry'
|
117
|
-
binding.pry
|
118
124
|
end
|
119
125
|
end
|
120
126
|
|