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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/examples/hip.yml +86 -148
  3. data/examples/make_hip.rb +16 -53
  4. data/examples/make_missed_connection.rb +10 -55
  5. data/examples/make_song1.rb +17 -61
  6. data/examples/make_song2.rb +17 -47
  7. data/examples/missed_connection.yml +120 -196
  8. data/examples/song1.yml +168 -158
  9. data/examples/song2.yml +46 -180
  10. data/lib/music-transcription.rb +14 -13
  11. data/lib/music-transcription/{articulations.rb → model/articulations.rb} +0 -0
  12. data/lib/music-transcription/{change.rb → model/change.rb} +0 -0
  13. data/lib/music-transcription/{dynamics.rb → model/dynamics.rb} +0 -0
  14. data/lib/music-transcription/{link.rb → model/link.rb} +8 -0
  15. data/lib/music-transcription/{meter.rb → model/meter.rb} +0 -0
  16. data/lib/music-transcription/{meters.rb → model/meters.rb} +0 -0
  17. data/lib/music-transcription/{note.rb → model/note.rb} +1 -1
  18. data/lib/music-transcription/{part.rb → model/part.rb} +1 -1
  19. data/lib/music-transcription/{pitch.rb → model/pitch.rb} +0 -0
  20. data/lib/music-transcription/{pitches.rb → model/pitches.rb} +0 -0
  21. data/lib/music-transcription/{program.rb → model/program.rb} +0 -0
  22. data/lib/music-transcription/{score.rb → model/score.rb} +1 -1
  23. data/lib/music-transcription/{tempo.rb → model/tempo.rb} +0 -0
  24. data/lib/music-transcription/parsing/convenience_methods.rb +10 -0
  25. data/lib/music-transcription/parsing/meter_parsing.rb +84 -0
  26. data/lib/music-transcription/parsing/meter_parsing.treetop +19 -0
  27. data/lib/music-transcription/version.rb +1 -1
  28. data/spec/{change_spec.rb → model/change_spec.rb} +1 -1
  29. data/spec/{link_spec.rb → model/link_spec.rb} +1 -1
  30. data/spec/{meter_spec.rb → model/meter_spec.rb} +1 -1
  31. data/spec/{note_spec.rb → model/note_spec.rb} +8 -1
  32. data/spec/{part_spec.rb → model/part_spec.rb} +1 -1
  33. data/spec/{pitch_spec.rb → model/pitch_spec.rb} +1 -1
  34. data/spec/{program_spec.rb → model/program_spec.rb} +1 -1
  35. data/spec/{score_spec.rb → model/score_spec.rb} +1 -1
  36. data/spec/{tempo_spec.rb → model/tempo_spec.rb} +1 -1
  37. data/spec/parsing/convenience_methods_spec.rb +13 -2
  38. data/spec/parsing/meter_parsing_spec.rb +23 -0
  39. metadata +37 -33
data/examples/song1.yml CHANGED
@@ -7,9 +7,6 @@ start_meter: !ruby/object:Music::Transcription::Meter
7
7
  measure_duration: !ruby/object:Rational
8
8
  denominator: 1
9
9
  numerator: 1
10
- check_methods:
11
- - :check_beats_per_measure
12
- - :check_beat_duration
13
10
  start_tempo: 120
14
11
  meter_changes: {}
15
12
  tempo_changes: {}
@@ -17,278 +14,287 @@ parts:
17
14
  1: !ruby/object:Music::Transcription::Part
18
15
  notes:
19
16
  - !ruby/object:Music::Transcription::Note
20
- duration: &4 !ruby/object:Rational
17
+ duration: !ruby/object:Rational
21
18
  denominator: 8
22
19
  numerator: 3
23
20
  pitches:
24
- - &3 !ruby/object:Music::Transcription::Pitch
21
+ - !ruby/object:Music::Transcription::Pitch
25
22
  octave: 2
26
23
  semitone: 0
27
24
  articulation: :normal
28
25
  accented: false
29
26
  links: {}
30
- check_methods:
31
- - :ensure_positive_duration
32
27
  - !ruby/object:Music::Transcription::Note
33
- duration: &2 !ruby/object:Rational
28
+ duration: !ruby/object:Rational
34
29
  denominator: 4
35
30
  numerator: 1
36
31
  pitches:
37
- - &1 !ruby/object:Music::Transcription::Pitch
32
+ - !ruby/object:Music::Transcription::Pitch
38
33
  octave: 2
39
34
  semitone: 3
40
35
  articulation: :normal
41
36
  accented: false
42
37
  links: {}
43
- check_methods:
44
- - :ensure_positive_duration
45
38
  - !ruby/object:Music::Transcription::Note
46
39
  duration: !ruby/object:Rational
47
40
  denominator: 16
48
41
  numerator: 5
49
42
  pitches:
50
- - &5 !ruby/object:Music::Transcription::Pitch
43
+ - !ruby/object:Music::Transcription::Pitch
51
44
  octave: 2
52
45
  semitone: 5
53
46
  articulation: :normal
54
47
  accented: false
55
48
  links: {}
56
- check_methods:
57
- - :ensure_positive_duration
58
49
  - !ruby/object:Music::Transcription::Note
59
50
  duration: !ruby/object:Rational
60
51
  denominator: 16
61
52
  numerator: 1
62
53
  pitches:
63
- - *1
54
+ - !ruby/object:Music::Transcription::Pitch
55
+ octave: 2
56
+ semitone: 3
64
57
  articulation: :normal
65
58
  accented: false
66
59
  links: {}
67
- check_methods:
68
- - :ensure_positive_duration
69
60
  - !ruby/object:Music::Transcription::Note
70
- duration: &6 !ruby/object:Rational
61
+ duration: !ruby/object:Rational
71
62
  denominator: 8
72
63
  numerator: 1
73
64
  pitches: []
74
65
  articulation: :normal
75
66
  accented: false
76
67
  links: {}
77
- check_methods:
78
- - :ensure_positive_duration
79
68
  - !ruby/object:Music::Transcription::Note
80
- duration: *2
69
+ duration: !ruby/object:Rational
70
+ denominator: 4
71
+ numerator: 1
81
72
  pitches:
82
- - *3
73
+ - !ruby/object:Music::Transcription::Pitch
74
+ octave: 2
75
+ semitone: 0
83
76
  articulation: :normal
84
77
  accented: false
85
78
  links: {}
86
- check_methods:
87
- - :ensure_positive_duration
88
79
  - !ruby/object:Music::Transcription::Note
89
- duration: *2
80
+ duration: !ruby/object:Rational
81
+ denominator: 4
82
+ numerator: 1
90
83
  pitches:
91
- - *1
84
+ - !ruby/object:Music::Transcription::Pitch
85
+ octave: 2
86
+ semitone: 3
92
87
  articulation: :normal
93
88
  accented: false
94
89
  links: {}
95
- check_methods:
96
- - :ensure_positive_duration
97
90
  - !ruby/object:Music::Transcription::Note
98
- duration: *4
91
+ duration: !ruby/object:Rational
92
+ denominator: 8
93
+ numerator: 3
99
94
  pitches: []
100
95
  articulation: :normal
101
96
  accented: false
102
97
  links: {}
103
- check_methods:
104
- - :ensure_positive_duration
105
98
  - !ruby/object:Music::Transcription::Note
106
- duration: *4
99
+ duration: !ruby/object:Rational
100
+ denominator: 8
101
+ numerator: 3
107
102
  pitches:
108
- - *3
103
+ - !ruby/object:Music::Transcription::Pitch
104
+ octave: 2
105
+ semitone: 0
109
106
  articulation: :normal
110
107
  accented: false
111
108
  links: {}
112
- check_methods:
113
- - :ensure_positive_duration
114
109
  - !ruby/object:Music::Transcription::Note
115
- duration: *2
110
+ duration: !ruby/object:Rational
111
+ denominator: 4
112
+ numerator: 1
116
113
  pitches:
117
- - *1
114
+ - !ruby/object:Music::Transcription::Pitch
115
+ octave: 2
116
+ semitone: 3
118
117
  articulation: :normal
119
118
  accented: false
120
119
  links: {}
121
- check_methods:
122
- - :ensure_positive_duration
123
120
  - !ruby/object:Music::Transcription::Note
124
121
  duration: !ruby/object:Rational
125
122
  denominator: 16
126
123
  numerator: 5
127
124
  pitches:
128
- - *5
125
+ - !ruby/object:Music::Transcription::Pitch
126
+ octave: 2
127
+ semitone: 5
129
128
  articulation: :normal
130
129
  accented: false
131
130
  links: {}
132
- check_methods:
133
- - :ensure_positive_duration
134
131
  - !ruby/object:Music::Transcription::Note
135
132
  duration: !ruby/object:Rational
136
133
  denominator: 16
137
134
  numerator: 1
138
135
  pitches:
139
- - *1
136
+ - !ruby/object:Music::Transcription::Pitch
137
+ octave: 2
138
+ semitone: 3
140
139
  articulation: :normal
141
140
  accented: false
142
141
  links: {}
143
- check_methods:
144
- - :ensure_positive_duration
145
142
  - !ruby/object:Music::Transcription::Note
146
- duration: *6
143
+ duration: !ruby/object:Rational
144
+ denominator: 8
145
+ numerator: 1
147
146
  pitches: []
148
147
  articulation: :normal
149
148
  accented: false
150
149
  links: {}
151
- check_methods:
152
- - :ensure_positive_duration
153
150
  - !ruby/object:Music::Transcription::Note
154
- duration: *2
151
+ duration: !ruby/object:Rational
152
+ denominator: 4
153
+ numerator: 1
155
154
  pitches:
156
- - *3
155
+ - !ruby/object:Music::Transcription::Pitch
156
+ octave: 2
157
+ semitone: 0
157
158
  articulation: :normal
158
159
  accented: false
159
160
  links: {}
160
- check_methods:
161
- - :ensure_positive_duration
162
161
  - !ruby/object:Music::Transcription::Note
163
- duration: *2
162
+ duration: !ruby/object:Rational
163
+ denominator: 4
164
+ numerator: 1
164
165
  pitches:
165
- - *1
166
+ - !ruby/object:Music::Transcription::Pitch
167
+ octave: 2
168
+ semitone: 3
166
169
  articulation: :normal
167
170
  accented: false
168
171
  links: {}
169
- check_methods:
170
- - :ensure_positive_duration
171
172
  start_dynamic: 0.625
172
173
  dynamic_changes: {}
173
- check_methods:
174
- - :ensure_start_dynamic
175
- - :ensure_dynamic_change_values_range
176
174
  2: !ruby/object:Music::Transcription::Part
177
175
  notes:
178
176
  - !ruby/object:Music::Transcription::Note
179
- duration: *6
177
+ duration: !ruby/object:Rational
178
+ denominator: 8
179
+ numerator: 1
180
180
  pitches: []
181
181
  articulation: :normal
182
182
  accented: false
183
183
  links: {}
184
- check_methods:
185
- - :ensure_positive_duration
186
184
  - !ruby/object:Music::Transcription::Note
187
- duration: *6
185
+ duration: !ruby/object:Rational
186
+ denominator: 8
187
+ numerator: 1
188
188
  pitches:
189
- - &7 !ruby/object:Music::Transcription::Pitch
189
+ - !ruby/object:Music::Transcription::Pitch
190
190
  octave: 3
191
191
  semitone: 10
192
192
  articulation: :normal
193
193
  accented: false
194
194
  links: {}
195
- check_methods:
196
- - :ensure_positive_duration
197
195
  - !ruby/object:Music::Transcription::Note
198
- duration: *6
196
+ duration: !ruby/object:Rational
197
+ denominator: 8
198
+ numerator: 1
199
199
  pitches:
200
- - *7
200
+ - !ruby/object:Music::Transcription::Pitch
201
+ octave: 3
202
+ semitone: 10
201
203
  articulation: :normal
202
204
  accented: false
203
205
  links: {}
204
- check_methods:
205
- - :ensure_positive_duration
206
206
  - !ruby/object:Music::Transcription::Note
207
- duration: *6
207
+ duration: !ruby/object:Rational
208
+ denominator: 8
209
+ numerator: 1
208
210
  pitches:
209
- - *7
211
+ - !ruby/object:Music::Transcription::Pitch
212
+ octave: 3
213
+ semitone: 10
210
214
  articulation: :normal
211
215
  accented: false
212
216
  links: {}
213
- check_methods:
214
- - :ensure_positive_duration
215
217
  - !ruby/object:Music::Transcription::Note
216
- duration: *6
218
+ duration: !ruby/object:Rational
219
+ denominator: 8
220
+ numerator: 1
217
221
  pitches:
218
- - *7
222
+ - !ruby/object:Music::Transcription::Pitch
223
+ octave: 3
224
+ semitone: 10
219
225
  articulation: :normal
220
226
  accented: false
221
227
  links: {}
222
- check_methods:
223
- - :ensure_positive_duration
224
228
  - !ruby/object:Music::Transcription::Note
225
- duration: *2
229
+ duration: !ruby/object:Rational
230
+ denominator: 4
231
+ numerator: 1
226
232
  pitches:
227
- - &10 !ruby/object:Music::Transcription::Pitch
233
+ - !ruby/object:Music::Transcription::Pitch
228
234
  octave: 4
229
235
  semitone: 0
230
236
  articulation: :normal
231
237
  accented: false
232
238
  links: {}
233
- check_methods:
234
- - :ensure_positive_duration
235
239
  - !ruby/object:Music::Transcription::Note
236
- duration: *2
240
+ duration: !ruby/object:Rational
241
+ denominator: 4
242
+ numerator: 1
237
243
  pitches:
238
- - &11 !ruby/object:Music::Transcription::Pitch
244
+ - !ruby/object:Music::Transcription::Pitch
239
245
  octave: 3
240
246
  semitone: 9
241
247
  articulation: :normal
242
248
  accented: false
243
249
  links: {}
244
- check_methods:
245
- - :ensure_positive_duration
246
250
  - !ruby/object:Music::Transcription::Note
247
- duration: *6
251
+ duration: !ruby/object:Rational
252
+ denominator: 8
253
+ numerator: 1
248
254
  pitches:
249
- - &8 !ruby/object:Music::Transcription::Pitch
255
+ - !ruby/object:Music::Transcription::Pitch
250
256
  octave: 3
251
257
  semitone: 7
252
258
  articulation: :normal
253
259
  accented: false
254
260
  links: {}
255
- check_methods:
256
- - :ensure_positive_duration
257
261
  - !ruby/object:Music::Transcription::Note
258
- duration: *6
262
+ duration: !ruby/object:Rational
263
+ denominator: 8
264
+ numerator: 1
259
265
  pitches:
260
- - &9 !ruby/object:Music::Transcription::Pitch
266
+ - !ruby/object:Music::Transcription::Pitch
261
267
  octave: 3
262
268
  semitone: 5
263
269
  articulation: :normal
264
270
  accented: false
265
271
  links: {}
266
- check_methods:
267
- - :ensure_positive_duration
268
272
  - !ruby/object:Music::Transcription::Note
269
273
  duration: !ruby/object:Rational
270
274
  denominator: 16
271
275
  numerator: 5
272
276
  pitches:
273
- - *8
277
+ - !ruby/object:Music::Transcription::Pitch
278
+ octave: 3
279
+ semitone: 7
274
280
  articulation: :slur
275
281
  accented: false
276
282
  links: {}
277
- check_methods:
278
- - :ensure_positive_duration
279
283
  - !ruby/object:Music::Transcription::Note
280
284
  duration: !ruby/object:Rational
281
285
  denominator: 16
282
286
  numerator: 1
283
287
  pitches:
284
- - *9
288
+ - !ruby/object:Music::Transcription::Pitch
289
+ octave: 3
290
+ semitone: 5
285
291
  articulation: :slur
286
292
  accented: false
287
293
  links: {}
288
- check_methods:
289
- - :ensure_positive_duration
290
294
  - !ruby/object:Music::Transcription::Note
291
- duration: *6
295
+ duration: !ruby/object:Rational
296
+ denominator: 8
297
+ numerator: 1
292
298
  pitches:
293
299
  - !ruby/object:Music::Transcription::Pitch
294
300
  octave: 3
@@ -296,100 +302,114 @@ parts:
296
302
  articulation: :normal
297
303
  accented: false
298
304
  links: {}
299
- check_methods:
300
- - :ensure_positive_duration
301
305
  - !ruby/object:Music::Transcription::Note
302
- duration: *6
306
+ duration: !ruby/object:Rational
307
+ denominator: 8
308
+ numerator: 1
303
309
  pitches: []
304
310
  articulation: :normal
305
311
  accented: false
306
312
  links: {}
307
- check_methods:
308
- - :ensure_positive_duration
309
313
  - !ruby/object:Music::Transcription::Note
310
- duration: *6
314
+ duration: !ruby/object:Rational
315
+ denominator: 8
316
+ numerator: 1
311
317
  pitches: []
312
318
  articulation: :normal
313
319
  accented: false
314
320
  links: {}
315
- check_methods:
316
- - :ensure_positive_duration
317
321
  - !ruby/object:Music::Transcription::Note
318
- duration: *6
322
+ duration: !ruby/object:Rational
323
+ denominator: 8
324
+ numerator: 1
319
325
  pitches:
320
- - *7
326
+ - !ruby/object:Music::Transcription::Pitch
327
+ octave: 3
328
+ semitone: 10
321
329
  articulation: :normal
322
330
  accented: false
323
331
  links: {}
324
- check_methods:
325
- - :ensure_positive_duration
326
332
  - !ruby/object:Music::Transcription::Note
327
- duration: *6
333
+ duration: !ruby/object:Rational
334
+ denominator: 8
335
+ numerator: 1
328
336
  pitches:
329
- - *7
337
+ - !ruby/object:Music::Transcription::Pitch
338
+ octave: 3
339
+ semitone: 10
330
340
  articulation: :normal
331
341
  accented: false
332
342
  links: {}
333
- check_methods:
334
- - :ensure_positive_duration
335
343
  - !ruby/object:Music::Transcription::Note
336
- duration: *6
344
+ duration: !ruby/object:Rational
345
+ denominator: 8
346
+ numerator: 1
337
347
  pitches:
338
- - *7
348
+ - !ruby/object:Music::Transcription::Pitch
349
+ octave: 3
350
+ semitone: 10
339
351
  articulation: :normal
340
352
  accented: false
341
353
  links: {}
342
- check_methods:
343
- - :ensure_positive_duration
344
354
  - !ruby/object:Music::Transcription::Note
345
- duration: *6
355
+ duration: !ruby/object:Rational
356
+ denominator: 8
357
+ numerator: 1
346
358
  pitches:
347
- - *7
359
+ - !ruby/object:Music::Transcription::Pitch
360
+ octave: 3
361
+ semitone: 10
348
362
  articulation: :normal
349
363
  accented: false
350
364
  links: {}
351
- check_methods:
352
- - :ensure_positive_duration
353
365
  - !ruby/object:Music::Transcription::Note
354
- duration: *2
366
+ duration: !ruby/object:Rational
367
+ denominator: 4
368
+ numerator: 1
355
369
  pitches:
356
- - *10
370
+ - !ruby/object:Music::Transcription::Pitch
371
+ octave: 4
372
+ semitone: 0
357
373
  articulation: :normal
358
374
  accented: false
359
375
  links: {}
360
- check_methods:
361
- - :ensure_positive_duration
362
376
  - !ruby/object:Music::Transcription::Note
363
- duration: *6
377
+ duration: !ruby/object:Rational
378
+ denominator: 8
379
+ numerator: 1
364
380
  pitches:
365
- - *11
381
+ - !ruby/object:Music::Transcription::Pitch
382
+ octave: 3
383
+ semitone: 9
366
384
  articulation: :normal
367
385
  accented: false
368
386
  links: {}
369
- check_methods:
370
- - :ensure_positive_duration
371
387
  - !ruby/object:Music::Transcription::Note
372
- duration: *6
388
+ duration: !ruby/object:Rational
389
+ denominator: 8
390
+ numerator: 1
373
391
  pitches:
374
- - &12 !ruby/object:Music::Transcription::Pitch
392
+ - !ruby/object:Music::Transcription::Pitch
375
393
  octave: 4
376
394
  semitone: 4
377
395
  articulation: :normal
378
396
  accented: false
379
397
  links: {}
380
- check_methods:
381
- - :ensure_positive_duration
382
398
  - !ruby/object:Music::Transcription::Note
383
- duration: *6
399
+ duration: !ruby/object:Rational
400
+ denominator: 8
401
+ numerator: 1
384
402
  pitches:
385
- - *12
403
+ - !ruby/object:Music::Transcription::Pitch
404
+ octave: 4
405
+ semitone: 4
386
406
  articulation: :slur
387
407
  accented: false
388
408
  links: {}
389
- check_methods:
390
- - :ensure_positive_duration
391
409
  - !ruby/object:Music::Transcription::Note
392
- duration: *6
410
+ duration: !ruby/object:Rational
411
+ denominator: 8
412
+ numerator: 1
393
413
  pitches:
394
414
  - !ruby/object:Music::Transcription::Pitch
395
415
  octave: 4
@@ -397,22 +417,19 @@ parts:
397
417
  articulation: :slur
398
418
  accented: false
399
419
  links: {}
400
- check_methods:
401
- - :ensure_positive_duration
402
420
  - !ruby/object:Music::Transcription::Note
403
- duration: *6
421
+ duration: !ruby/object:Rational
422
+ denominator: 8
423
+ numerator: 1
404
424
  pitches:
405
- - *10
425
+ - !ruby/object:Music::Transcription::Pitch
426
+ octave: 4
427
+ semitone: 0
406
428
  articulation: :normal
407
429
  accented: false
408
430
  links: {}
409
- check_methods:
410
- - :ensure_positive_duration
411
431
  start_dynamic: 0.625
412
432
  dynamic_changes: {}
413
- check_methods:
414
- - :ensure_start_dynamic
415
- - :ensure_dynamic_change_values_range
416
433
  program: !ruby/object:Music::Transcription::Program
417
434
  segments:
418
435
  - !ruby/range
@@ -423,10 +440,3 @@ program: !ruby/object:Music::Transcription::Program
423
440
  begin: 0
424
441
  end: 4.0
425
442
  excl: true
426
- check_methods:
427
- - :ensure_increasing_segments
428
- - :ensure_nonnegative_segments
429
- check_methods:
430
- - :check_start_tempo
431
- - :check_tempo_changes
432
- - :check_meter_changes