music-transcription 0.6.1 → 0.6.2
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 +9 -1
- data/lib/music-transcription/version.rb +1 -1
- data/spec/note_spec.rb +28 -5
- 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: 798476169e353327ed492007a49a4fa4cb7a5876
|
4
|
+
data.tar.gz: e1b210b46df6d19be8376981d273386d259112b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 703b333835f7a602d7fddd76f8cb3a4de29e2ffc5e917a5f6041056f8c5bf26d1159095cdd9d9860be184f1ee9dddc52d7819e1aa07a4d2c5c1a570024434a4d
|
7
|
+
data.tar.gz: 48f2c1e631998cc99cfa01bf960dc405b0280717a9357fcf40cefc6d8c8550a7c94c9527d35d92f301d62a457f2053ec2b99ad394c0d85950932d4c8cf4454ec
|
@@ -76,7 +76,7 @@ class Note
|
|
76
76
|
self.clone.transpose! diff, transpose_links
|
77
77
|
end
|
78
78
|
|
79
|
-
def transpose! diff, transpose_link_targets
|
79
|
+
def transpose! diff, transpose_link_targets = true
|
80
80
|
unless diff.is_a?(Pitch)
|
81
81
|
diff = Pitch.make_from_semitone(diff)
|
82
82
|
end
|
@@ -93,6 +93,14 @@ class Note
|
|
93
93
|
return self
|
94
94
|
end
|
95
95
|
|
96
|
+
def stretch ratio
|
97
|
+
self.clone.stretch! ratio
|
98
|
+
end
|
99
|
+
|
100
|
+
def stretch! ratio
|
101
|
+
@duration *= ratio
|
102
|
+
end
|
103
|
+
|
96
104
|
def to_s
|
97
105
|
output = @duration.to_s
|
98
106
|
if @pitches.any?
|
data/spec/note_spec.rb
CHANGED
@@ -62,13 +62,36 @@ describe Note do
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
65
|
+
|
66
|
+
context 'transpose_link_targets set true' do
|
67
|
+
it 'should also transpose link targets' do
|
68
|
+
note = Note::Quarter.new([C2,F2], links:{C2=>Link::Slur.new(D2)})
|
69
|
+
note.transpose!(2,true)
|
70
|
+
note.links[D2].target_pitch.should eq(E2)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'transpose_link_targets not set' do
|
75
|
+
it 'should default to true' do
|
76
|
+
note = Note::Quarter.new([C2,F2], links: {C2=>Link::Slur.new(D2)})
|
77
|
+
note.transpose!(2)
|
78
|
+
note.links[D2].target_pitch.should eq E2
|
79
|
+
end
|
80
|
+
end
|
65
81
|
end
|
66
82
|
|
67
|
-
|
68
|
-
it 'should
|
69
|
-
note = Note::Quarter.new
|
70
|
-
note.
|
71
|
-
note.
|
83
|
+
describe '#stretch!' do
|
84
|
+
it 'should multiply note duration by ratio' do
|
85
|
+
note = Note::Quarter.new
|
86
|
+
note.stretch!(2)
|
87
|
+
note.duration.should eq(Rational(1,2))
|
88
|
+
|
89
|
+
note = Note::Quarter.new
|
90
|
+
note.stretch!(Rational(1,2))
|
91
|
+
note.duration.should eq(Rational(1,8))
|
92
|
+
note = Note::Quarter.new
|
93
|
+
note.stretch!(2)
|
94
|
+
note.duration.should eq(Rational(1,2))
|
72
95
|
end
|
73
96
|
end
|
74
97
|
end
|