music-transcription 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/hip.yml +86 -148
- data/examples/make_hip.rb +16 -53
- data/examples/make_missed_connection.rb +10 -55
- data/examples/make_song1.rb +17 -61
- data/examples/make_song2.rb +17 -47
- data/examples/missed_connection.yml +120 -196
- data/examples/song1.yml +168 -158
- data/examples/song2.yml +46 -180
- data/lib/music-transcription.rb +14 -13
- data/lib/music-transcription/{articulations.rb → model/articulations.rb} +0 -0
- data/lib/music-transcription/{change.rb → model/change.rb} +0 -0
- data/lib/music-transcription/{dynamics.rb → model/dynamics.rb} +0 -0
- data/lib/music-transcription/{link.rb → model/link.rb} +8 -0
- data/lib/music-transcription/{meter.rb → model/meter.rb} +0 -0
- data/lib/music-transcription/{meters.rb → model/meters.rb} +0 -0
- data/lib/music-transcription/{note.rb → model/note.rb} +1 -1
- data/lib/music-transcription/{part.rb → model/part.rb} +1 -1
- data/lib/music-transcription/{pitch.rb → model/pitch.rb} +0 -0
- data/lib/music-transcription/{pitches.rb → model/pitches.rb} +0 -0
- data/lib/music-transcription/{program.rb → model/program.rb} +0 -0
- data/lib/music-transcription/{score.rb → model/score.rb} +1 -1
- data/lib/music-transcription/{tempo.rb → model/tempo.rb} +0 -0
- data/lib/music-transcription/parsing/convenience_methods.rb +10 -0
- data/lib/music-transcription/parsing/meter_parsing.rb +84 -0
- data/lib/music-transcription/parsing/meter_parsing.treetop +19 -0
- data/lib/music-transcription/version.rb +1 -1
- data/spec/{change_spec.rb → model/change_spec.rb} +1 -1
- data/spec/{link_spec.rb → model/link_spec.rb} +1 -1
- data/spec/{meter_spec.rb → model/meter_spec.rb} +1 -1
- data/spec/{note_spec.rb → model/note_spec.rb} +8 -1
- data/spec/{part_spec.rb → model/part_spec.rb} +1 -1
- data/spec/{pitch_spec.rb → model/pitch_spec.rb} +1 -1
- data/spec/{program_spec.rb → model/program_spec.rb} +1 -1
- data/spec/{score_spec.rb → model/score_spec.rb} +1 -1
- data/spec/{tempo_spec.rb → model/tempo_spec.rb} +1 -1
- data/spec/parsing/convenience_methods_spec.rb +13 -2
- data/spec/parsing/meter_parsing_spec.rb +23 -0
- metadata +37 -33
@@ -0,0 +1,84 @@
|
|
1
|
+
# Autogenerated from a Treetop grammar. Edits may be lost.
|
2
|
+
|
3
|
+
|
4
|
+
module Music
|
5
|
+
module Transcription
|
6
|
+
module Parsing
|
7
|
+
|
8
|
+
module Meter
|
9
|
+
include Treetop::Runtime
|
10
|
+
|
11
|
+
def root
|
12
|
+
@root ||= :meter
|
13
|
+
end
|
14
|
+
|
15
|
+
include PositiveInteger
|
16
|
+
|
17
|
+
module Meter0
|
18
|
+
def bpm
|
19
|
+
elements[0]
|
20
|
+
end
|
21
|
+
|
22
|
+
def bd
|
23
|
+
elements[2]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module Meter1
|
28
|
+
def to_meter
|
29
|
+
Music::Transcription::Meter.new(bpm.to_i, Rational(1,bd.to_i))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def _nt_meter
|
34
|
+
start_index = index
|
35
|
+
if node_cache[:meter].has_key?(index)
|
36
|
+
cached = node_cache[:meter][index]
|
37
|
+
if cached
|
38
|
+
node_cache[:meter][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
39
|
+
@index = cached.interval.end
|
40
|
+
end
|
41
|
+
return cached
|
42
|
+
end
|
43
|
+
|
44
|
+
i0, s0 = index, []
|
45
|
+
r1 = _nt_positive_integer
|
46
|
+
s0 << r1
|
47
|
+
if r1
|
48
|
+
if (match_len = has_terminal?("/", false, index))
|
49
|
+
r2 = true
|
50
|
+
@index += match_len
|
51
|
+
else
|
52
|
+
terminal_parse_failure("/")
|
53
|
+
r2 = nil
|
54
|
+
end
|
55
|
+
s0 << r2
|
56
|
+
if r2
|
57
|
+
r3 = _nt_positive_integer
|
58
|
+
s0 << r3
|
59
|
+
end
|
60
|
+
end
|
61
|
+
if s0.last
|
62
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
63
|
+
r0.extend(Meter0)
|
64
|
+
r0.extend(Meter1)
|
65
|
+
else
|
66
|
+
@index = i0
|
67
|
+
r0 = nil
|
68
|
+
end
|
69
|
+
|
70
|
+
node_cache[:meter][start_index] = r0
|
71
|
+
|
72
|
+
r0
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
class MeterParser < Treetop::Runtime::CompiledParser
|
78
|
+
include Meter
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Music
|
2
|
+
module Transcription
|
3
|
+
module Parsing
|
4
|
+
|
5
|
+
grammar Meter
|
6
|
+
include PositiveInteger
|
7
|
+
|
8
|
+
rule meter
|
9
|
+
bpm:positive_integer "/" bd:positive_integer {
|
10
|
+
def to_meter
|
11
|
+
Music::Transcription::Meter.new(bpm.to_i, Rational(1,bd.to_i))
|
12
|
+
end
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
describe Note do
|
4
4
|
before :all do
|
@@ -89,6 +89,13 @@ describe Note do
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
+
context 'with links that have no target pitch' do
|
93
|
+
it 'should not raise error' do
|
94
|
+
n = Note::half([E2],links: {E2 => Link::Tie.new})
|
95
|
+
expect { n.transpose!(1) }.to_not raise_error
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
92
99
|
it 'should return self' do
|
93
100
|
n = Note::quarter
|
94
101
|
n.transpose!(0).should eq n
|
@@ -41,6 +41,15 @@ notes_stuff = ['should parse as whitespace-separated notes',
|
|
41
41
|
"/2Db2\t/2C2 \n /2C2" => [Note::half([Db2]), Note::half([C2]), Note::half([C2])]
|
42
42
|
}]
|
43
43
|
|
44
|
+
meter_stuff = ['should parse as meter',
|
45
|
+
{
|
46
|
+
'2/2' => Meter.new(2,"1/2".to_r),
|
47
|
+
"4/4" => Meter.new(4,"1/4".to_r),
|
48
|
+
"6/8" => Meter.new(6,"1/8".to_r),
|
49
|
+
"12/3" => Meter.new(12,"1/3".to_r),
|
50
|
+
"133/55" => Meter.new(133,"1/55".to_r),
|
51
|
+
}]
|
52
|
+
|
44
53
|
{
|
45
54
|
:duration => dur_stuff,
|
46
55
|
:dur => dur_stuff,
|
@@ -49,7 +58,8 @@ notes_stuff = ['should parse as whitespace-separated notes',
|
|
49
58
|
:pitch => pitch_stuff,
|
50
59
|
:pitches => pitches_stuff,
|
51
60
|
:note => note_stuff,
|
52
|
-
:notes => notes_stuff
|
61
|
+
:notes => notes_stuff,
|
62
|
+
:meter => meter_stuff
|
53
63
|
}.each do |mod_fun,descr_cases|
|
54
64
|
describe("Parsing::" + mod_fun.to_s) do
|
55
65
|
descr, cases = descr_cases
|
@@ -75,7 +85,8 @@ end
|
|
75
85
|
:to_n => note_stuff,
|
76
86
|
:to_note => note_stuff,
|
77
87
|
:to_ns => notes_stuff,
|
78
|
-
:to_notes => notes_stuff
|
88
|
+
:to_notes => notes_stuff,
|
89
|
+
:to_meter => meter_stuff,
|
79
90
|
}.each do |inst_meth,descr_cases|
|
80
91
|
describe("String#" + inst_meth.to_s) do
|
81
92
|
descr, cases = descr_cases
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Parsing::MeterParser do
|
4
|
+
parser = Parsing::MeterParser.new
|
5
|
+
|
6
|
+
{
|
7
|
+
'4/4' => FOUR_FOUR,
|
8
|
+
'6/8' => SIX_EIGHT,
|
9
|
+
'12/3' => Meter.new(12,"1/3".to_r),
|
10
|
+
'9/8' => Meter.new(9,"1/8".to_r),
|
11
|
+
'3/4' => THREE_FOUR
|
12
|
+
}.each do |str,met|
|
13
|
+
res = parser.parse(str)
|
14
|
+
|
15
|
+
it "should parse #{str}" do
|
16
|
+
res.should_not be nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should produce node that properly converts to meter' do
|
20
|
+
res.to_meter.should eq met
|
21
|
+
end
|
22
|
+
end
|
23
|
+
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.
|
4
|
+
version: 0.11.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-10-
|
11
|
+
date: 2014-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -165,14 +165,20 @@ files:
|
|
165
165
|
- examples/song1.yml
|
166
166
|
- examples/song2.yml
|
167
167
|
- lib/music-transcription.rb
|
168
|
-
- lib/music-transcription/articulations.rb
|
169
|
-
- lib/music-transcription/change.rb
|
170
|
-
- lib/music-transcription/dynamics.rb
|
171
168
|
- lib/music-transcription/errors.rb
|
172
|
-
- lib/music-transcription/
|
173
|
-
- lib/music-transcription/
|
174
|
-
- lib/music-transcription/
|
175
|
-
- lib/music-transcription/
|
169
|
+
- lib/music-transcription/model/articulations.rb
|
170
|
+
- lib/music-transcription/model/change.rb
|
171
|
+
- lib/music-transcription/model/dynamics.rb
|
172
|
+
- lib/music-transcription/model/link.rb
|
173
|
+
- lib/music-transcription/model/meter.rb
|
174
|
+
- lib/music-transcription/model/meters.rb
|
175
|
+
- lib/music-transcription/model/note.rb
|
176
|
+
- lib/music-transcription/model/part.rb
|
177
|
+
- lib/music-transcription/model/pitch.rb
|
178
|
+
- lib/music-transcription/model/pitches.rb
|
179
|
+
- lib/music-transcription/model/program.rb
|
180
|
+
- lib/music-transcription/model/score.rb
|
181
|
+
- lib/music-transcription/model/tempo.rb
|
176
182
|
- lib/music-transcription/parsing/articulation_parsing.rb
|
177
183
|
- lib/music-transcription/parsing/articulation_parsing.treetop
|
178
184
|
- lib/music-transcription/parsing/convenience_methods.rb
|
@@ -182,6 +188,8 @@ files:
|
|
182
188
|
- lib/music-transcription/parsing/link_nodes.rb
|
183
189
|
- lib/music-transcription/parsing/link_parsing.rb
|
184
190
|
- lib/music-transcription/parsing/link_parsing.treetop
|
191
|
+
- lib/music-transcription/parsing/meter_parsing.rb
|
192
|
+
- lib/music-transcription/parsing/meter_parsing.treetop
|
185
193
|
- lib/music-transcription/parsing/nonnegative_integer_parsing.rb
|
186
194
|
- lib/music-transcription/parsing/nonnegative_integer_parsing.treetop
|
187
195
|
- lib/music-transcription/parsing/note_nodes.rb
|
@@ -192,38 +200,33 @@ files:
|
|
192
200
|
- lib/music-transcription/parsing/pitch_parsing.treetop
|
193
201
|
- lib/music-transcription/parsing/positive_integer_parsing.rb
|
194
202
|
- lib/music-transcription/parsing/positive_integer_parsing.treetop
|
195
|
-
- lib/music-transcription/part.rb
|
196
|
-
- lib/music-transcription/pitch.rb
|
197
|
-
- lib/music-transcription/pitches.rb
|
198
|
-
- lib/music-transcription/program.rb
|
199
|
-
- lib/music-transcription/score.rb
|
200
|
-
- lib/music-transcription/tempo.rb
|
201
203
|
- lib/music-transcription/validatable.rb
|
202
204
|
- lib/music-transcription/version.rb
|
203
205
|
- music-transcription.gemspec
|
204
|
-
- spec/change_spec.rb
|
205
|
-
- spec/link_spec.rb
|
206
|
-
- spec/meter_spec.rb
|
206
|
+
- spec/model/change_spec.rb
|
207
|
+
- spec/model/link_spec.rb
|
208
|
+
- spec/model/meter_spec.rb
|
209
|
+
- spec/model/note_spec.rb
|
210
|
+
- spec/model/part_spec.rb
|
211
|
+
- spec/model/pitch_spec.rb
|
212
|
+
- spec/model/program_spec.rb
|
213
|
+
- spec/model/score_spec.rb
|
214
|
+
- spec/model/tempo_spec.rb
|
207
215
|
- spec/music-transcription_spec.rb
|
208
|
-
- spec/note_spec.rb
|
209
216
|
- spec/parsing/articulation_parsing_spec.rb
|
210
217
|
- spec/parsing/convenience_methods_spec.rb
|
211
218
|
- spec/parsing/duration_nodes_spec.rb
|
212
219
|
- spec/parsing/duration_parsing_spec.rb
|
213
220
|
- spec/parsing/link_nodes_spec.rb
|
214
221
|
- spec/parsing/link_parsing_spec.rb
|
222
|
+
- spec/parsing/meter_parsing_spec.rb
|
215
223
|
- spec/parsing/nonnegative_integer_spec.rb
|
216
224
|
- spec/parsing/note_nodes_spec.rb
|
217
225
|
- spec/parsing/note_parsing_spec.rb
|
218
226
|
- spec/parsing/pitch_node_spec.rb
|
219
227
|
- spec/parsing/pitch_parsing_spec.rb
|
220
228
|
- spec/parsing/positive_integer_spec.rb
|
221
|
-
- spec/part_spec.rb
|
222
|
-
- spec/pitch_spec.rb
|
223
|
-
- spec/program_spec.rb
|
224
|
-
- spec/score_spec.rb
|
225
229
|
- spec/spec_helper.rb
|
226
|
-
- spec/tempo_spec.rb
|
227
230
|
homepage: https://github.com/jamestunnell/music-transcription
|
228
231
|
licenses:
|
229
232
|
- MIT
|
@@ -250,27 +253,28 @@ specification_version: 4
|
|
250
253
|
summary: Classes for representing music notational features like pitch, note, loudness,
|
251
254
|
tempo, etc.
|
252
255
|
test_files:
|
253
|
-
- spec/change_spec.rb
|
254
|
-
- spec/link_spec.rb
|
255
|
-
- spec/meter_spec.rb
|
256
|
+
- spec/model/change_spec.rb
|
257
|
+
- spec/model/link_spec.rb
|
258
|
+
- spec/model/meter_spec.rb
|
259
|
+
- spec/model/note_spec.rb
|
260
|
+
- spec/model/part_spec.rb
|
261
|
+
- spec/model/pitch_spec.rb
|
262
|
+
- spec/model/program_spec.rb
|
263
|
+
- spec/model/score_spec.rb
|
264
|
+
- spec/model/tempo_spec.rb
|
256
265
|
- spec/music-transcription_spec.rb
|
257
|
-
- spec/note_spec.rb
|
258
266
|
- spec/parsing/articulation_parsing_spec.rb
|
259
267
|
- spec/parsing/convenience_methods_spec.rb
|
260
268
|
- spec/parsing/duration_nodes_spec.rb
|
261
269
|
- spec/parsing/duration_parsing_spec.rb
|
262
270
|
- spec/parsing/link_nodes_spec.rb
|
263
271
|
- spec/parsing/link_parsing_spec.rb
|
272
|
+
- spec/parsing/meter_parsing_spec.rb
|
264
273
|
- spec/parsing/nonnegative_integer_spec.rb
|
265
274
|
- spec/parsing/note_nodes_spec.rb
|
266
275
|
- spec/parsing/note_parsing_spec.rb
|
267
276
|
- spec/parsing/pitch_node_spec.rb
|
268
277
|
- spec/parsing/pitch_parsing_spec.rb
|
269
278
|
- spec/parsing/positive_integer_spec.rb
|
270
|
-
- spec/part_spec.rb
|
271
|
-
- spec/pitch_spec.rb
|
272
|
-
- spec/program_spec.rb
|
273
|
-
- spec/score_spec.rb
|
274
279
|
- spec/spec_helper.rb
|
275
|
-
- spec/tempo_spec.rb
|
276
280
|
has_rdoc:
|