music-transcription 0.11.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/examples/{make_hip.rb → hip.rb} +8 -2
  4. data/examples/hip_packed.yml +22 -0
  5. data/examples/{make_missed_connection.rb → missed_connection.rb} +8 -2
  6. data/examples/missed_connection.yml +2 -2
  7. data/examples/missed_connection_packed.yml +14 -0
  8. data/examples/{make_song1.rb → song1.rb} +7 -1
  9. data/examples/song1_packed.yml +19 -0
  10. data/examples/{make_song2.rb → song2.rb} +6 -1
  11. data/examples/song2_packed.yml +21 -0
  12. data/lib/music-transcription.rb +11 -3
  13. data/lib/music-transcription/model/link.rb +24 -6
  14. data/lib/music-transcription/model/meter.rb +10 -0
  15. data/lib/music-transcription/model/meters.rb +1 -1
  16. data/lib/music-transcription/model/note.rb +32 -0
  17. data/lib/music-transcription/model/pitch.rb +19 -0
  18. data/lib/music-transcription/packing/change_packing.rb +27 -0
  19. data/lib/music-transcription/packing/part_packing.rb +33 -0
  20. data/lib/music-transcription/packing/program_packing.rb +18 -0
  21. data/lib/music-transcription/packing/score_packing.rb +59 -0
  22. data/lib/music-transcription/parsing/convenience_methods.rb +10 -0
  23. data/lib/music-transcription/parsing/meter_parsing.rb +117 -9
  24. data/lib/music-transcription/parsing/meter_parsing.treetop +12 -0
  25. data/lib/music-transcription/parsing/note_node.rb +42 -0
  26. data/lib/music-transcription/parsing/note_parsing.rb +57 -180
  27. data/lib/music-transcription/parsing/note_parsing.treetop +2 -19
  28. data/lib/music-transcription/parsing/numbers/nonnegative_float_parsing.rb +178 -0
  29. data/lib/music-transcription/parsing/numbers/nonnegative_float_parsing.treetop +19 -0
  30. data/lib/music-transcription/parsing/{nonnegative_integer_parsing.rb → numbers/nonnegative_integer_parsing.rb} +9 -0
  31. data/lib/music-transcription/parsing/{nonnegative_integer_parsing.treetop → numbers/nonnegative_integer_parsing.treetop} +7 -1
  32. data/lib/music-transcription/parsing/numbers/nonnegative_rational_parsing.rb +88 -0
  33. data/lib/music-transcription/parsing/numbers/nonnegative_rational_parsing.treetop +22 -0
  34. data/lib/music-transcription/parsing/{positive_integer_parsing.rb → numbers/positive_integer_parsing.rb} +0 -0
  35. data/lib/music-transcription/parsing/{positive_integer_parsing.treetop → numbers/positive_integer_parsing.treetop} +0 -0
  36. data/lib/music-transcription/parsing/segment_parsing.rb +143 -0
  37. data/lib/music-transcription/parsing/segment_parsing.treetop +25 -0
  38. data/lib/music-transcription/version.rb +1 -1
  39. data/spec/model/link_spec.rb +44 -60
  40. data/spec/model/meter_spec.rb +18 -0
  41. data/spec/model/note_spec.rb +39 -0
  42. data/spec/model/pitch_spec.rb +32 -0
  43. data/spec/packing/change_packing_spec.rb +91 -0
  44. data/spec/packing/part_packing_spec.rb +66 -0
  45. data/spec/packing/program_packing_spec.rb +33 -0
  46. data/spec/packing/score_packing_spec.rb +122 -0
  47. data/spec/parsing/meter_parsing_spec.rb +2 -2
  48. data/spec/parsing/note_node_spec.rb +87 -0
  49. data/spec/parsing/note_parsing_spec.rb +3 -0
  50. data/spec/parsing/numbers/nonnegative_float_spec.rb +11 -0
  51. data/spec/parsing/{nonnegative_integer_spec.rb → numbers/nonnegative_integer_spec.rb} +1 -1
  52. data/spec/parsing/numbers/nonnegative_rational_spec.rb +11 -0
  53. data/spec/parsing/{positive_integer_spec.rb → numbers/positive_integer_spec.rb} +1 -1
  54. data/spec/parsing/segment_parsing_spec.rb +27 -0
  55. metadata +45 -17
  56. data/lib/music-transcription/parsing/note_nodes.rb +0 -64
  57. data/spec/parsing/note_nodes_spec.rb +0 -84
@@ -0,0 +1,122 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Score do
4
+ before :all do
5
+ @score = Score.new(FOUR_FOUR,120) do |s|
6
+ s.program = Program.new([0...2, 0...2,2...4,0...2])
7
+ s.parts["lead"] = Part.new(Dynamics::MF) do |p|
8
+ riff = "/6Bb3 /4 /12Db4= /6Db4= /36Db4 /36Eb4 /36Db4 /6Ab3 /12Db4 \
9
+ /6Bb3 /4 /12Db4= /4Db4= /8=Db4 /8C4".to_notes
10
+ p.notes = riff + riff.map {|n| n.transpose(2) }
11
+ end
12
+
13
+ s.parts["bass"] = Part.new(Dynamics::MP) do |p|
14
+ riff = "/6Bb2 /4 /3Ab2 /6F2 /12Ab2 \
15
+ /6Bb2 /4 /3Ab2 /4Ab2".to_notes
16
+ p.notes = riff + riff.map {|n| n.transpose(2) }
17
+ end
18
+ end
19
+
20
+ @h = @score.pack
21
+ end
22
+
23
+ describe '#pack' do
24
+ it 'should return a hash' do
25
+ @h.should be_a Hash
26
+ end
27
+
28
+ it 'should return a hash with keys: "parts", "start_meter", ...' do
29
+ @h.keys.should include("parts")
30
+ @h.keys.should include("start_meter")
31
+ @h.keys.should include("meter_changes")
32
+ @h.keys.should include("start_tempo")
33
+ @h.keys.should include("tempo_changes")
34
+ @h.keys.should include("program")
35
+ end
36
+
37
+ it 'should pack start meter as a string' do
38
+ @h['start_meter'].should be_a String
39
+ end
40
+
41
+ it 'should pack meter changes as whatver type Change#pack returns' do
42
+ @h['meter_changes'].each do |offset,packed_v|
43
+ change_v = @score.meter_changes[offset]
44
+ t = change_v.pack.class
45
+ packed_v.should be_a t
46
+ end
47
+ end
48
+
49
+ it 'should pack meter change values as strings' do
50
+ @h['meter_changes'].each do |offset,packed_v|
51
+ packed_v[0].should be_a String
52
+ end
53
+ end
54
+
55
+ it 'should pack start tempo as plain numeric value' do
56
+ @h['start_tempo'].should be_a Numeric
57
+ end
58
+
59
+ it 'should pack tempo changes as whatver type Change#pack returns' do
60
+ @h['tempo_changes'].each do |offset,packed_v|
61
+ change_v = @score.tempo_changes[offset]
62
+ t = change_v.pack.class
63
+ packed_v.should be_a t
64
+ end
65
+ end
66
+
67
+ it 'should pack program as whatever type Program#pack returns' do
68
+ t = @score.program.pack.class
69
+ @h['program'].should be_a t
70
+ end
71
+
72
+ it 'should pack program segments as strings' do
73
+ @h['program'].each {|x| x.should be_a String }
74
+ end
75
+
76
+ it 'should pack parts as hash' do
77
+ @h['parts'].should be_a Hash
78
+ end
79
+
80
+ it 'should pack parts as whatever Part#pack returns' do
81
+ @score.parts.each do |name,part|
82
+ packing = part.pack
83
+ @h['parts'][name].should eq packing
84
+ end
85
+ end
86
+ end
87
+
88
+ describe '.unpack' do
89
+ before :all do
90
+ @score2 = Score.unpack @h
91
+ end
92
+
93
+ it 'should return a Score' do
94
+ @score2.should be_a Score
95
+ end
96
+
97
+ it 'should successfuly unpack the parts' do
98
+ @score2.parts.should eq @score.parts
99
+ end
100
+
101
+ it 'should successfuly unpack the start meter' do
102
+ @score2.start_meter.should eq @score.start_meter
103
+ end
104
+
105
+ it 'should successfuly unpack the start tempo' do
106
+ @score2.start_tempo.should eq @score.start_tempo
107
+ end
108
+
109
+ it 'should successfuly unpack the meter changes' do
110
+ @score2.meter_changes.should eq @score.meter_changes
111
+ end
112
+
113
+ it 'should successfuly unpack the tempo changes' do
114
+ @score2.tempo_changes.should eq @score.tempo_changes
115
+ end
116
+
117
+ it 'should successfuly unpack the program' do
118
+ @score2.program.should eq @score.program
119
+ end
120
+ end
121
+ end
122
+
@@ -5,9 +5,9 @@ describe Parsing::MeterParser do
5
5
 
6
6
  {
7
7
  '4/4' => FOUR_FOUR,
8
- '6/8' => SIX_EIGHT,
8
+ '2*3/8' => SIX_EIGHT,
9
9
  '12/3' => Meter.new(12,"1/3".to_r),
10
- '9/8' => Meter.new(9,"1/8".to_r),
10
+ '3*3/8' => Meter.new(3,"3/8".to_r),
11
11
  '3/4' => THREE_FOUR
12
12
  }.each do |str,met|
13
13
  res = parser.parse(str)
@@ -0,0 +1,87 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ NOTE_PARSER = Parsing::NoteParser.new
4
+
5
+ describe Parsing::NoteNode do
6
+ context 'rest note' do
7
+ {
8
+ '/2' => Note.new(Rational(1,2)),
9
+ '4/2' => Note.new(Rational(4,2)),
10
+ '28' => Note.new(Rational(28,1)),
11
+ '56/33' => Note.new(Rational(56,33)),
12
+ }.each do |str,tgt|
13
+ res = NOTE_PARSER.parse(str)
14
+ context str do
15
+ it 'should parse as NoteNode' do
16
+ res.should be_a Parsing::NoteNode
17
+ end
18
+
19
+ describe '#to_note' do
20
+ n = res.to_note
21
+ it 'should produce a Note' do
22
+ n.should be_a Note
23
+ end
24
+
25
+ it 'should produce value matching input str' do
26
+ n.should eq tgt
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ context 'monophonic note' do
34
+ {
35
+ '/2=C2=C2' => Note.new(Rational(1,2),[C2],articulation:SLUR, links:{C2=>Link::Slur.new(C2)}),
36
+ '4/2.D#6' => Note.new(Rational(4,2),[Eb6],articulation:STACCATO),
37
+ '28%Eb7!' => Note.new(Rational(28,1),[Eb7],articulation:PORTATO, accented: true),
38
+ "56/33'B1" => Note.new(Rational(56,33),[B1],articulation:STACCATISSIMO),
39
+ }.each do |str,tgt|
40
+ res = NOTE_PARSER.parse(str)
41
+
42
+ context str do
43
+ it 'should parse as MonophonicNoteNode' do
44
+ res.should be_a Parsing::NoteNode
45
+ end
46
+
47
+ describe '#to_note' do
48
+ n = res.to_note
49
+ it 'should produce a Note' do
50
+ n.should be_a Note
51
+ end
52
+
53
+ it 'should produce value matching input str' do
54
+ n.should eq tgt
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ context 'polyphonic note' do
62
+ {
63
+ '/2C2,D2,E2-F2' => Note.new(Rational(1,2),[C2,D2,E2],links:{E2=>Link::Legato.new(F2)}),
64
+ '4/2.D#6,G4' => Note.new(Rational(4,2),[Eb6,G4], articulation:STACCATO),
65
+ '28_Eb7,D7,G7' => Note.new(Rational(28,1),[Eb7,D7,G7],articulation:TENUTO),
66
+ '56/33B1,B2,B3,B4,B5!' => Note.new(Rational(56,33),[B1,B2,B3,B4,B5], accented: true),
67
+ }.each do |str,tgt|
68
+ res = NOTE_PARSER.parse(str)
69
+ context str do
70
+ it 'should parse as PolyphonicNoteNode' do
71
+ res.should be_a Parsing::NoteNode
72
+ end
73
+
74
+ describe '#to_note' do
75
+ n = res.to_note
76
+ it 'should produce a Note' do
77
+ n.should be_a Note
78
+ end
79
+
80
+ it 'should produce value matching input str' do
81
+ n.should eq tgt
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -7,6 +7,9 @@ describe Parsing::NoteParser do
7
7
 
8
8
  valid_cases = {
9
9
  'duration only' => ['1/4','/2','1','55/33'],
10
+ 'duration + accent' => ['1/4!','/2!'],
11
+ 'duration + articulation' => ['1/4.','/2%','2/3='],
12
+ 'duration + articulation + accent' => ['1/4.!','/2%!','2/3=!'],
10
13
  'single pitch' => ['/4C2','5/3Db3','/33E#8'],
11
14
  'multiple pitches' => ['/4C2,C3,c5','5/3Db3,Bb2,E5','/33E#8,F1,B9'],
12
15
  'with articulation' => ['/4.C2',"5/3'Db3,Bb2,E5",'/33=F3','5-B2','/2_D3,F4'],
@@ -0,0 +1,11 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Parsing::NonnegativeFloatParser do
4
+ parser = Parsing::NonnegativeFloatParser .new
5
+
6
+ ["1.0","0.50","05.003e-10","1.555e+2","3.443214"].each do |str|
7
+ it "should parse '#{str}'" do
8
+ parser.parse(str).should_not be nil
9
+ end
10
+ end
11
+ end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
 
3
3
  describe Parsing::NonnegativeIntegerParser do
4
4
  parser = Parsing::NonnegativeIntegerParser.new
@@ -0,0 +1,11 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Parsing::NonnegativeRationalParser do
4
+ parser = Parsing::NonnegativeRationalParser.new
5
+
6
+ ["1/2","0/50","05/003","502530/1","0/1"].each do |str|
7
+ it "should parse '#{str}'" do
8
+ parser.parse(str).should_not be nil
9
+ end
10
+ end
11
+ end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
 
3
3
  describe Parsing::PositiveIntegerParser do
4
4
  parser = Parsing::PositiveIntegerParser.new
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Parsing::SegmentParser do
4
+ parser = Parsing::SegmentParser.new
5
+
6
+ cases = {
7
+ "ints" => ["0...4",0...4],
8
+ "plain floats" => ["0.0..4.0",0.0...4.0],
9
+ "sci floats" => ["1.3e-10...5",1.3e-10...5],
10
+ "int/float" => ["45..46.5",45...46.5],
11
+ "float/int" => ["4.5...5",4.5...5],
12
+ "rationals" => ["2/3..3/2",Rational(2,3)...Rational(3,2)],
13
+ "float/rational" => ["3.5..10/6",3.5...Rational(10,6)]
14
+ }.each do |descr,str_tgt|
15
+ context descr do
16
+ str,tgt = str_tgt
17
+ res = parser.parse(str)
18
+ it 'should parse' do
19
+ res.should_not be nil
20
+ end
21
+
22
+ it 'should return node that converts to exclusive range via #to_range' do
23
+ res.to_range.should eq tgt
24
+ end
25
+ end
26
+ end
27
+ 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.11.0
4
+ version: 0.13.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-13 00:00:00.000000000 Z
11
+ date: 2014-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -156,14 +156,18 @@ files:
156
156
  - README.rdoc
157
157
  - Rakefile
158
158
  - bin/transcribe
159
+ - examples/hip.rb
159
160
  - examples/hip.yml
160
- - examples/make_hip.rb
161
- - examples/make_missed_connection.rb
162
- - examples/make_song1.rb
163
- - examples/make_song2.rb
161
+ - examples/hip_packed.yml
162
+ - examples/missed_connection.rb
164
163
  - examples/missed_connection.yml
164
+ - examples/missed_connection_packed.yml
165
+ - examples/song1.rb
165
166
  - examples/song1.yml
167
+ - examples/song1_packed.yml
168
+ - examples/song2.rb
166
169
  - examples/song2.yml
170
+ - examples/song2_packed.yml
167
171
  - lib/music-transcription.rb
168
172
  - lib/music-transcription/errors.rb
169
173
  - lib/music-transcription/model/articulations.rb
@@ -179,6 +183,10 @@ files:
179
183
  - lib/music-transcription/model/program.rb
180
184
  - lib/music-transcription/model/score.rb
181
185
  - lib/music-transcription/model/tempo.rb
186
+ - lib/music-transcription/packing/change_packing.rb
187
+ - lib/music-transcription/packing/part_packing.rb
188
+ - lib/music-transcription/packing/program_packing.rb
189
+ - lib/music-transcription/packing/score_packing.rb
182
190
  - lib/music-transcription/parsing/articulation_parsing.rb
183
191
  - lib/music-transcription/parsing/articulation_parsing.treetop
184
192
  - lib/music-transcription/parsing/convenience_methods.rb
@@ -190,16 +198,22 @@ files:
190
198
  - lib/music-transcription/parsing/link_parsing.treetop
191
199
  - lib/music-transcription/parsing/meter_parsing.rb
192
200
  - lib/music-transcription/parsing/meter_parsing.treetop
193
- - lib/music-transcription/parsing/nonnegative_integer_parsing.rb
194
- - lib/music-transcription/parsing/nonnegative_integer_parsing.treetop
195
- - lib/music-transcription/parsing/note_nodes.rb
201
+ - lib/music-transcription/parsing/note_node.rb
196
202
  - lib/music-transcription/parsing/note_parsing.rb
197
203
  - lib/music-transcription/parsing/note_parsing.treetop
204
+ - lib/music-transcription/parsing/numbers/nonnegative_float_parsing.rb
205
+ - lib/music-transcription/parsing/numbers/nonnegative_float_parsing.treetop
206
+ - lib/music-transcription/parsing/numbers/nonnegative_integer_parsing.rb
207
+ - lib/music-transcription/parsing/numbers/nonnegative_integer_parsing.treetop
208
+ - lib/music-transcription/parsing/numbers/nonnegative_rational_parsing.rb
209
+ - lib/music-transcription/parsing/numbers/nonnegative_rational_parsing.treetop
210
+ - lib/music-transcription/parsing/numbers/positive_integer_parsing.rb
211
+ - lib/music-transcription/parsing/numbers/positive_integer_parsing.treetop
198
212
  - lib/music-transcription/parsing/pitch_node.rb
199
213
  - lib/music-transcription/parsing/pitch_parsing.rb
200
214
  - lib/music-transcription/parsing/pitch_parsing.treetop
201
- - lib/music-transcription/parsing/positive_integer_parsing.rb
202
- - lib/music-transcription/parsing/positive_integer_parsing.treetop
215
+ - lib/music-transcription/parsing/segment_parsing.rb
216
+ - lib/music-transcription/parsing/segment_parsing.treetop
203
217
  - lib/music-transcription/validatable.rb
204
218
  - lib/music-transcription/version.rb
205
219
  - music-transcription.gemspec
@@ -213,6 +227,10 @@ files:
213
227
  - spec/model/score_spec.rb
214
228
  - spec/model/tempo_spec.rb
215
229
  - spec/music-transcription_spec.rb
230
+ - spec/packing/change_packing_spec.rb
231
+ - spec/packing/part_packing_spec.rb
232
+ - spec/packing/program_packing_spec.rb
233
+ - spec/packing/score_packing_spec.rb
216
234
  - spec/parsing/articulation_parsing_spec.rb
217
235
  - spec/parsing/convenience_methods_spec.rb
218
236
  - spec/parsing/duration_nodes_spec.rb
@@ -220,12 +238,15 @@ files:
220
238
  - spec/parsing/link_nodes_spec.rb
221
239
  - spec/parsing/link_parsing_spec.rb
222
240
  - spec/parsing/meter_parsing_spec.rb
223
- - spec/parsing/nonnegative_integer_spec.rb
224
- - spec/parsing/note_nodes_spec.rb
241
+ - spec/parsing/note_node_spec.rb
225
242
  - spec/parsing/note_parsing_spec.rb
243
+ - spec/parsing/numbers/nonnegative_float_spec.rb
244
+ - spec/parsing/numbers/nonnegative_integer_spec.rb
245
+ - spec/parsing/numbers/nonnegative_rational_spec.rb
246
+ - spec/parsing/numbers/positive_integer_spec.rb
226
247
  - spec/parsing/pitch_node_spec.rb
227
248
  - spec/parsing/pitch_parsing_spec.rb
228
- - spec/parsing/positive_integer_spec.rb
249
+ - spec/parsing/segment_parsing_spec.rb
229
250
  - spec/spec_helper.rb
230
251
  homepage: https://github.com/jamestunnell/music-transcription
231
252
  licenses:
@@ -263,6 +284,10 @@ test_files:
263
284
  - spec/model/score_spec.rb
264
285
  - spec/model/tempo_spec.rb
265
286
  - spec/music-transcription_spec.rb
287
+ - spec/packing/change_packing_spec.rb
288
+ - spec/packing/part_packing_spec.rb
289
+ - spec/packing/program_packing_spec.rb
290
+ - spec/packing/score_packing_spec.rb
266
291
  - spec/parsing/articulation_parsing_spec.rb
267
292
  - spec/parsing/convenience_methods_spec.rb
268
293
  - spec/parsing/duration_nodes_spec.rb
@@ -270,11 +295,14 @@ test_files:
270
295
  - spec/parsing/link_nodes_spec.rb
271
296
  - spec/parsing/link_parsing_spec.rb
272
297
  - spec/parsing/meter_parsing_spec.rb
273
- - spec/parsing/nonnegative_integer_spec.rb
274
- - spec/parsing/note_nodes_spec.rb
298
+ - spec/parsing/note_node_spec.rb
275
299
  - spec/parsing/note_parsing_spec.rb
300
+ - spec/parsing/numbers/nonnegative_float_spec.rb
301
+ - spec/parsing/numbers/nonnegative_integer_spec.rb
302
+ - spec/parsing/numbers/nonnegative_rational_spec.rb
303
+ - spec/parsing/numbers/positive_integer_spec.rb
276
304
  - spec/parsing/pitch_node_spec.rb
277
305
  - spec/parsing/pitch_parsing_spec.rb
278
- - spec/parsing/positive_integer_spec.rb
306
+ - spec/parsing/segment_parsing_spec.rb
279
307
  - spec/spec_helper.rb
280
308
  has_rdoc:
@@ -1,64 +0,0 @@
1
- module Music
2
- module Transcription
3
- module Parsing
4
- class NoteNode < Treetop::Runtime::SyntaxNode
5
- def primitives env
6
- [ self.to_note ]
7
- end
8
- end
9
-
10
- class RestNoteNode < NoteNode
11
- def to_note
12
- Music::Transcription::Note.new(duration.to_r)
13
- end
14
- end
15
-
16
- class MonophonicNoteNode < NoteNode
17
- def to_note
18
- pitches = [ pl.pitch.to_pitch ]
19
-
20
- links = {}
21
- unless pl.the_link.empty?
22
- links[pitches[0]] = pl.the_link.to_link
23
- end
24
-
25
- artic = Music::Transcription::Articulations::NORMAL
26
- unless art.empty?
27
- artic = art.to_articulation
28
- end
29
-
30
- accent_flag = acc.empty? ? false : true
31
- Music::Transcription::Note.new(duration.to_r,
32
- pitches, links: links, articulation: artic, accented: accent_flag)
33
- end
34
- end
35
-
36
- class PolyphonicNoteNode < NoteNode
37
- def to_note
38
- pitches = [ pl.pitch.to_pitch ]
39
-
40
- links = {}
41
- unless pl.the_link.empty?
42
- links[pitches[0]] = pl.the_link.to_link
43
- end
44
-
45
- more_pitches.elements.each do |mp|
46
- pitches.push mp.pl.pitch.to_pitch
47
- unless mp.pl.the_link.empty?
48
- links[pitches[-1]] = mp.pl.the_link.to_link
49
- end
50
- end
51
-
52
- artic = Music::Transcription::Articulations::NORMAL
53
- unless art.empty?
54
- artic = art.to_articulation
55
- end
56
-
57
- accent_flag = acc.empty? ? false : true
58
- Music::Transcription::Note.new(duration.to_r,
59
- pitches, links: links, articulation: artic, accented: accent_flag)
60
- end
61
- end
62
- end
63
- end
64
- end