musicality 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +27 -1
- data/README.md +153 -10
- data/bin/collidify +102 -0
- data/bin/lilify +57 -29
- data/bin/midify +64 -24
- data/bin/musicality +39 -0
- data/examples/composition/auto_counterpoint.rb +4 -5
- data/examples/composition/part_generator.rb +8 -2
- data/examples/composition/scale_exercise.rb +1 -1
- data/examples/notation/notes.rb +27 -0
- data/examples/notation/parts.rb +51 -0
- data/examples/notation/scores.rb +38 -0
- data/examples/notation/twinkle.rb +34 -0
- data/examples/notation/twinkle.score +33 -0
- data/lib/musicality.rb +46 -11
- data/lib/musicality/composition/dsl/score_dsl.rb +2 -2
- data/lib/musicality/composition/dsl/score_methods.rb +10 -7
- data/lib/musicality/notation/conversion/change_conversion.rb +1 -1
- data/lib/musicality/notation/conversion/note_time_converter.rb +6 -23
- data/lib/musicality/notation/conversion/score_conversion.rb +15 -15
- data/lib/musicality/notation/conversion/score_converter.rb +50 -67
- data/lib/musicality/notation/model/articulations.rb +3 -2
- data/lib/musicality/notation/model/change.rb +15 -6
- data/lib/musicality/notation/model/dynamics.rb +11 -8
- data/lib/musicality/notation/model/instrument.rb +61 -0
- data/lib/musicality/notation/model/instruments.rb +111 -0
- data/lib/musicality/notation/model/key.rb +137 -0
- data/lib/musicality/notation/model/keys.rb +37 -0
- data/lib/musicality/notation/model/link.rb +6 -19
- data/lib/musicality/notation/model/mark.rb +43 -0
- data/lib/musicality/notation/model/marks.rb +11 -0
- data/lib/musicality/notation/model/meter.rb +4 -0
- data/lib/musicality/notation/model/note.rb +42 -28
- data/lib/musicality/notation/model/part.rb +18 -5
- data/lib/musicality/notation/model/pitch.rb +13 -4
- data/lib/musicality/notation/model/score.rb +104 -66
- data/lib/musicality/notation/model/symbols.rb +16 -11
- data/lib/musicality/notation/parsing/articulation_parsing.rb +38 -38
- data/lib/musicality/notation/parsing/articulation_parsing.treetop +14 -14
- data/lib/musicality/notation/parsing/link_parsing.rb +6 -6
- data/lib/musicality/notation/parsing/link_parsing.treetop +3 -3
- data/lib/musicality/notation/parsing/mark_parsing.rb +138 -0
- data/lib/musicality/notation/parsing/mark_parsing.treetop +31 -0
- data/lib/musicality/notation/parsing/note_node.rb +19 -12
- data/lib/musicality/notation/parsing/note_parsing.rb +218 -87
- data/lib/musicality/notation/parsing/note_parsing.treetop +9 -5
- data/lib/musicality/notation/parsing/numbers/nonnegative_integer_parsing.rb +7 -2
- data/lib/musicality/notation/parsing/numbers/nonnegative_integer_parsing.treetop +1 -1
- data/lib/musicality/notation/parsing/numbers/positive_integer_parsing.rb +6 -4
- data/lib/musicality/notation/parsing/numbers/positive_integer_parsing.treetop +1 -1
- data/lib/musicality/notation/util/function.rb +41 -18
- data/lib/musicality/packable.rb +156 -0
- data/lib/musicality/performance/conversion/glissando_converter.rb +2 -2
- data/lib/musicality/performance/conversion/note_sequence_extractor.rb +223 -70
- data/lib/musicality/performance/conversion/portamento_converter.rb +5 -2
- data/lib/musicality/performance/conversion/score_collator.rb +70 -64
- data/lib/musicality/performance/midi/midi_events.rb +3 -3
- data/lib/musicality/performance/midi/midi_settings.rb +127 -0
- data/lib/musicality/performance/midi/midi_util.rb +8 -2
- data/lib/musicality/performance/midi/part_sequencer.rb +19 -18
- data/lib/musicality/performance/midi/score_sequencer.rb +13 -9
- data/lib/musicality/performance/midi/score_sequencing.rb +5 -5
- data/lib/musicality/performance/model/attack.rb +8 -0
- data/lib/musicality/performance/model/duration_functions.rb +23 -0
- data/lib/musicality/performance/model/note_sequence.rb +52 -95
- data/lib/musicality/performance/model/separation.rb +10 -0
- data/lib/musicality/performance/supercollider/add_actions.rb +13 -0
- data/lib/musicality/performance/supercollider/bundle.rb +18 -0
- data/lib/musicality/performance/supercollider/conductor.rb +125 -0
- data/lib/musicality/performance/supercollider/group.rb +71 -0
- data/lib/musicality/performance/supercollider/message.rb +26 -0
- data/lib/musicality/performance/supercollider/node.rb +122 -0
- data/lib/musicality/performance/supercollider/performer.rb +123 -0
- data/lib/musicality/performance/supercollider/score_conducting.rb +17 -0
- data/lib/musicality/performance/supercollider/server.rb +8 -0
- data/lib/musicality/performance/supercollider/synth.rb +43 -0
- data/lib/musicality/performance/supercollider/synthdef.rb +57 -0
- data/lib/musicality/performance/supercollider/synthdef_settings.rb +23 -0
- data/lib/musicality/performance/supercollider/synthdefs.rb +1654 -0
- data/lib/musicality/{composition/model/pitch_class.rb → pitch_class.rb} +1 -1
- data/lib/musicality/{composition/model/pitch_classes.rb → pitch_classes.rb} +9 -9
- data/lib/musicality/printing/lilypond/clef.rb +12 -0
- data/lib/musicality/printing/lilypond/key_engraving.rb +9 -0
- data/lib/musicality/printing/lilypond/lilypond_settings.rb +105 -0
- data/lib/musicality/printing/lilypond/meter_engraving.rb +1 -1
- data/lib/musicality/printing/lilypond/note_engraving.rb +112 -30
- data/lib/musicality/printing/lilypond/part_engraver.rb +114 -3
- data/lib/musicality/printing/lilypond/pitch_class_engraving.rb +22 -0
- data/lib/musicality/printing/lilypond/pitch_engraving.rb +2 -15
- data/lib/musicality/printing/lilypond/score_engraver.rb +44 -73
- data/lib/musicality/printing/lilypond/score_engraving.rb +3 -3
- data/lib/musicality/project/create_tasks.rb +31 -0
- data/lib/musicality/project/file_cleaner.rb +19 -0
- data/lib/musicality/project/file_raker.rb +107 -0
- data/lib/musicality/project/load_config.rb +43 -0
- data/lib/musicality/project/project.rb +64 -0
- data/lib/musicality/version.rb +1 -1
- data/musicality.gemspec +3 -0
- data/spec/composition/util/random_sampler_spec.rb +1 -1
- data/spec/notation/conversion/measure_note_map_spec.rb +1 -1
- data/spec/notation/conversion/note_time_converter_spec.rb +5 -85
- data/spec/notation/conversion/score_conversion_spec.rb +6 -41
- data/spec/notation/conversion/score_converter_spec.rb +19 -137
- data/spec/notation/model/change_spec.rb +55 -0
- data/spec/notation/model/key_spec.rb +171 -0
- data/spec/notation/model/link_spec.rb +34 -5
- data/spec/notation/model/meter_spec.rb +15 -0
- data/spec/notation/model/note_spec.rb +33 -27
- data/spec/notation/model/part_spec.rb +53 -4
- data/spec/notation/model/pitch_spec.rb +15 -0
- data/spec/notation/model/score_spec.rb +64 -72
- data/spec/notation/parsing/link_nodes_spec.rb +3 -3
- data/spec/notation/parsing/link_parsing_spec.rb +6 -6
- data/spec/notation/parsing/note_node_spec.rb +34 -9
- data/spec/notation/parsing/note_parsing_spec.rb +11 -9
- data/spec/notation/parsing/numbers/nonnegative_integer_spec.rb +4 -0
- data/spec/notation/parsing/pitch_node_spec.rb +0 -1
- data/spec/notation/util/value_computer_spec.rb +2 -2
- data/spec/performance/conversion/glissando_converter_spec.rb +9 -9
- data/spec/performance/conversion/note_sequence_extractor_spec.rb +48 -53
- data/spec/performance/conversion/portamento_converter_spec.rb +11 -9
- data/spec/performance/conversion/score_collator_spec.rb +59 -63
- data/spec/performance/midi/midi_util_spec.rb +22 -8
- data/spec/performance/midi/part_sequencer_spec.rb +2 -2
- data/spec/performance/midi/score_sequencer_spec.rb +12 -10
- data/spec/performance/midi/score_sequencing_spec.rb +2 -2
- data/spec/performance/model/note_sequence_spec.rb +41 -134
- data/spec/printing/note_engraving_spec.rb +204 -0
- data/spec/printing/score_engraver_spec.rb +40 -0
- data/spec/spec_helper.rb +1 -0
- metadata +69 -23
- data/examples/notation/hip.rb +0 -32
- data/examples/notation/missed_connection.rb +0 -26
- data/examples/notation/song1.rb +0 -33
- data/examples/notation/song2.rb +0 -32
- data/lib/musicality/notation/model/links.rb +0 -11
- data/lib/musicality/notation/packing/change_packing.rb +0 -56
- data/lib/musicality/notation/packing/part_packing.rb +0 -31
- data/lib/musicality/notation/packing/score_packing.rb +0 -123
- data/lib/musicality/performance/model/note_attacks.rb +0 -19
- data/lib/musicality/performance/util/note_linker.rb +0 -28
- data/spec/notation/packing/change_packing_spec.rb +0 -304
- data/spec/notation/packing/part_packing_spec.rb +0 -66
- data/spec/notation/packing/score_packing_spec.rb +0 -255
- data/spec/performance/util/note_linker_spec.rb +0 -68
@@ -3,35 +3,35 @@ module Parsing
|
|
3
3
|
|
4
4
|
grammar Articulation
|
5
5
|
rule articulation
|
6
|
-
|
6
|
+
tenuto / accent / marcato / portato / staccato / staccatissimo
|
7
7
|
end
|
8
|
-
|
9
|
-
rule
|
10
|
-
"
|
8
|
+
|
9
|
+
rule tenuto
|
10
|
+
"-" {
|
11
11
|
def to_articulation
|
12
|
-
Musicality::Articulations::
|
12
|
+
Musicality::Articulations::TENUTO
|
13
13
|
end
|
14
14
|
}
|
15
15
|
end
|
16
16
|
|
17
|
-
rule
|
18
|
-
"
|
17
|
+
rule accent
|
18
|
+
">" {
|
19
19
|
def to_articulation
|
20
|
-
Musicality::Articulations::
|
20
|
+
Musicality::Articulations::ACCENT
|
21
21
|
end
|
22
22
|
}
|
23
23
|
end
|
24
|
-
|
25
|
-
rule
|
26
|
-
"
|
24
|
+
|
25
|
+
rule marcato
|
26
|
+
"^" {
|
27
27
|
def to_articulation
|
28
|
-
Musicality::Articulations::
|
28
|
+
Musicality::Articulations::MARCATO
|
29
29
|
end
|
30
30
|
}
|
31
31
|
end
|
32
32
|
|
33
33
|
rule portato
|
34
|
-
"
|
34
|
+
"_" {
|
35
35
|
def to_articulation
|
36
36
|
Musicality::Articulations::PORTATO
|
37
37
|
end
|
@@ -47,7 +47,7 @@ grammar Articulation
|
|
47
47
|
end
|
48
48
|
|
49
49
|
rule staccatissimo
|
50
|
-
"
|
50
|
+
"!" {
|
51
51
|
def to_articulation
|
52
52
|
Musicality::Articulations::STACCATISSIMO
|
53
53
|
end
|
@@ -62,11 +62,11 @@ module Link
|
|
62
62
|
return cached
|
63
63
|
end
|
64
64
|
|
65
|
-
if (match_len = has_terminal?("
|
65
|
+
if (match_len = has_terminal?("~", false, index))
|
66
66
|
r0 = instantiate_node(TieNode,input, index...(index + match_len))
|
67
67
|
@index += match_len
|
68
68
|
else
|
69
|
-
terminal_parse_failure("
|
69
|
+
terminal_parse_failure('"~"')
|
70
70
|
r0 = nil
|
71
71
|
end
|
72
72
|
|
@@ -93,11 +93,11 @@ module Link
|
|
93
93
|
end
|
94
94
|
|
95
95
|
i0, s0 = index, []
|
96
|
-
if (match_len = has_terminal?("
|
96
|
+
if (match_len = has_terminal?(";", false, index))
|
97
97
|
r1 = true
|
98
98
|
@index += match_len
|
99
99
|
else
|
100
|
-
terminal_parse_failure("
|
100
|
+
terminal_parse_failure('";"')
|
101
101
|
r1 = nil
|
102
102
|
end
|
103
103
|
s0 << r1
|
@@ -136,11 +136,11 @@ module Link
|
|
136
136
|
end
|
137
137
|
|
138
138
|
i0, s0 = index, []
|
139
|
-
if (match_len = has_terminal?("
|
139
|
+
if (match_len = has_terminal?(":", false, index))
|
140
140
|
r1 = true
|
141
141
|
@index += match_len
|
142
142
|
else
|
143
|
-
terminal_parse_failure("
|
143
|
+
terminal_parse_failure('":"')
|
144
144
|
r1 = nil
|
145
145
|
end
|
146
146
|
s0 << r1
|
@@ -9,15 +9,15 @@ grammar Link
|
|
9
9
|
end
|
10
10
|
|
11
11
|
rule tie
|
12
|
-
"
|
12
|
+
"~" <TieNode>
|
13
13
|
end
|
14
14
|
|
15
15
|
rule glissando
|
16
|
-
"
|
16
|
+
";" pitch <GlissandoNode>
|
17
17
|
end
|
18
18
|
|
19
19
|
rule portamento
|
20
|
-
"
|
20
|
+
":" pitch <PortamentoNode>
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -0,0 +1,138 @@
|
|
1
|
+
# Autogenerated from a Treetop grammar. Edits may be lost.
|
2
|
+
|
3
|
+
|
4
|
+
module Musicality
|
5
|
+
module Parsing
|
6
|
+
|
7
|
+
module Mark
|
8
|
+
include Treetop::Runtime
|
9
|
+
|
10
|
+
def root
|
11
|
+
@root ||= :begin_slur
|
12
|
+
end
|
13
|
+
|
14
|
+
module BeginSlur0
|
15
|
+
def to_mark; return Musicality::Mark::Slur::Begin.new; end
|
16
|
+
end
|
17
|
+
|
18
|
+
def _nt_begin_slur
|
19
|
+
start_index = index
|
20
|
+
if node_cache[:begin_slur].has_key?(index)
|
21
|
+
cached = node_cache[:begin_slur][index]
|
22
|
+
if cached
|
23
|
+
node_cache[:begin_slur][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
24
|
+
@index = cached.interval.end
|
25
|
+
end
|
26
|
+
return cached
|
27
|
+
end
|
28
|
+
|
29
|
+
if (match_len = has_terminal?("(", false, index))
|
30
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
31
|
+
r0.extend(BeginSlur0)
|
32
|
+
@index += match_len
|
33
|
+
else
|
34
|
+
terminal_parse_failure('"("')
|
35
|
+
r0 = nil
|
36
|
+
end
|
37
|
+
|
38
|
+
node_cache[:begin_slur][start_index] = r0
|
39
|
+
|
40
|
+
r0
|
41
|
+
end
|
42
|
+
|
43
|
+
module EndSlur0
|
44
|
+
def to_mark; return Musicality::Mark::Slur::End.new; end
|
45
|
+
end
|
46
|
+
|
47
|
+
def _nt_end_slur
|
48
|
+
start_index = index
|
49
|
+
if node_cache[:end_slur].has_key?(index)
|
50
|
+
cached = node_cache[:end_slur][index]
|
51
|
+
if cached
|
52
|
+
node_cache[:end_slur][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
53
|
+
@index = cached.interval.end
|
54
|
+
end
|
55
|
+
return cached
|
56
|
+
end
|
57
|
+
|
58
|
+
if (match_len = has_terminal?(")", false, index))
|
59
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
60
|
+
r0.extend(EndSlur0)
|
61
|
+
@index += match_len
|
62
|
+
else
|
63
|
+
terminal_parse_failure('")"')
|
64
|
+
r0 = nil
|
65
|
+
end
|
66
|
+
|
67
|
+
node_cache[:end_slur][start_index] = r0
|
68
|
+
|
69
|
+
r0
|
70
|
+
end
|
71
|
+
|
72
|
+
module BeginTriplet0
|
73
|
+
def to_mark; return Musicality::Mark::Triplet::Begin.new; end
|
74
|
+
end
|
75
|
+
|
76
|
+
def _nt_begin_triplet
|
77
|
+
start_index = index
|
78
|
+
if node_cache[:begin_triplet].has_key?(index)
|
79
|
+
cached = node_cache[:begin_triplet][index]
|
80
|
+
if cached
|
81
|
+
node_cache[:begin_triplet][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
82
|
+
@index = cached.interval.end
|
83
|
+
end
|
84
|
+
return cached
|
85
|
+
end
|
86
|
+
|
87
|
+
if (match_len = has_terminal?("[", false, index))
|
88
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
89
|
+
r0.extend(BeginTriplet0)
|
90
|
+
@index += match_len
|
91
|
+
else
|
92
|
+
terminal_parse_failure('"["')
|
93
|
+
r0 = nil
|
94
|
+
end
|
95
|
+
|
96
|
+
node_cache[:begin_triplet][start_index] = r0
|
97
|
+
|
98
|
+
r0
|
99
|
+
end
|
100
|
+
|
101
|
+
module EndTriplet0
|
102
|
+
def to_mark; return Musicality::Mark::Triplet::End.new; end
|
103
|
+
end
|
104
|
+
|
105
|
+
def _nt_end_triplet
|
106
|
+
start_index = index
|
107
|
+
if node_cache[:end_triplet].has_key?(index)
|
108
|
+
cached = node_cache[:end_triplet][index]
|
109
|
+
if cached
|
110
|
+
node_cache[:end_triplet][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
111
|
+
@index = cached.interval.end
|
112
|
+
end
|
113
|
+
return cached
|
114
|
+
end
|
115
|
+
|
116
|
+
if (match_len = has_terminal?("]", false, index))
|
117
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
118
|
+
r0.extend(EndTriplet0)
|
119
|
+
@index += match_len
|
120
|
+
else
|
121
|
+
terminal_parse_failure('"]"')
|
122
|
+
r0 = nil
|
123
|
+
end
|
124
|
+
|
125
|
+
node_cache[:end_triplet][start_index] = r0
|
126
|
+
|
127
|
+
r0
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
class MarkParser < Treetop::Runtime::CompiledParser
|
133
|
+
include Mark
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Musicality
|
2
|
+
module Parsing
|
3
|
+
|
4
|
+
grammar Mark
|
5
|
+
rule begin_slur
|
6
|
+
"(" {
|
7
|
+
def to_mark; return Musicality::Mark::Slur::Begin.new; end
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
rule end_slur
|
12
|
+
")" {
|
13
|
+
def to_mark; return Musicality::Mark::Slur::End.new; end
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
rule begin_triplet
|
18
|
+
"[" {
|
19
|
+
def to_mark; return Musicality::Mark::Triplet::Begin.new; end
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
rule end_triplet
|
24
|
+
"]" {
|
25
|
+
def to_mark; return Musicality::Mark::Triplet::End.new; end
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
module Musicality
|
2
2
|
module Parsing
|
3
3
|
class NoteNode < Treetop::Runtime::SyntaxNode
|
4
|
-
def primitives env
|
5
|
-
[ self.to_note ]
|
6
|
-
end
|
7
|
-
|
8
4
|
def to_note
|
5
|
+
dur = duration.to_r
|
6
|
+
|
9
7
|
if more.empty?
|
10
|
-
return Musicality::Note.new(
|
8
|
+
return Musicality::Note.new(dur)
|
11
9
|
end
|
12
10
|
|
13
11
|
pitches = []
|
@@ -27,15 +25,24 @@ module Parsing
|
|
27
25
|
links[pitches[-1]] = x.pl.the_link.to_link
|
28
26
|
end
|
29
27
|
end
|
30
|
-
|
31
|
-
|
32
|
-
unless
|
33
|
-
|
28
|
+
|
29
|
+
marks = []
|
30
|
+
unless begin_marks.empty?
|
31
|
+
marks.push begin_marks.first.to_mark
|
32
|
+
unless begin_marks.second.empty?
|
33
|
+
marks.push begin_marks.second.to_mark
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
unless end_marks.empty?
|
38
|
+
marks.push end_marks.first.to_mark
|
39
|
+
unless end_marks.second.empty?
|
40
|
+
marks.push end_marks.second.to_mark
|
41
|
+
end
|
34
42
|
end
|
35
43
|
|
36
|
-
|
37
|
-
|
38
|
-
links: links, articulation: artic, accented: accent_flag)
|
44
|
+
Musicality::Note.new(dur, pitches, links: links, marks: marks,
|
45
|
+
articulation: more.art.empty? ? Articulations::NORMAL : more.art.to_articulation)
|
39
46
|
end
|
40
47
|
end
|
41
48
|
end
|
@@ -19,13 +19,35 @@ module Note
|
|
19
19
|
|
20
20
|
include Duration
|
21
21
|
|
22
|
+
include Mark
|
23
|
+
|
22
24
|
module Note0
|
23
|
-
def
|
25
|
+
def first
|
26
|
+
elements[0]
|
27
|
+
end
|
28
|
+
|
29
|
+
def second
|
24
30
|
elements[1]
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
28
34
|
module Note1
|
35
|
+
def first
|
36
|
+
elements[0]
|
37
|
+
end
|
38
|
+
|
39
|
+
def second
|
40
|
+
elements[1]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
module Note2
|
45
|
+
def pl
|
46
|
+
elements[1]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
module Note3
|
29
51
|
def first_pl
|
30
52
|
elements[0]
|
31
53
|
end
|
@@ -37,22 +59,46 @@ module Note
|
|
37
59
|
def art
|
38
60
|
elements[2]
|
39
61
|
end
|
62
|
+
end
|
40
63
|
|
41
|
-
|
42
|
-
|
64
|
+
module Note4
|
65
|
+
def first
|
66
|
+
elements[0]
|
67
|
+
end
|
68
|
+
|
69
|
+
def second
|
70
|
+
elements[1]
|
43
71
|
end
|
44
72
|
end
|
45
73
|
|
46
|
-
module
|
47
|
-
def
|
74
|
+
module Note5
|
75
|
+
def first
|
48
76
|
elements[0]
|
49
77
|
end
|
50
78
|
|
51
|
-
def
|
79
|
+
def second
|
52
80
|
elements[1]
|
53
81
|
end
|
54
82
|
end
|
55
83
|
|
84
|
+
module Note6
|
85
|
+
def begin_marks
|
86
|
+
elements[0]
|
87
|
+
end
|
88
|
+
|
89
|
+
def duration
|
90
|
+
elements[1]
|
91
|
+
end
|
92
|
+
|
93
|
+
def more
|
94
|
+
elements[2]
|
95
|
+
end
|
96
|
+
|
97
|
+
def end_marks
|
98
|
+
elements[3]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
56
102
|
def _nt_note
|
57
103
|
start_index = index
|
58
104
|
if node_cache[:note].has_key?(index)
|
@@ -65,79 +111,188 @@ module Note
|
|
65
111
|
end
|
66
112
|
|
67
113
|
i0, s0 = index, []
|
68
|
-
|
114
|
+
i2 = index
|
115
|
+
i3, s3 = index, []
|
116
|
+
r4 = _nt_begin_triplet
|
117
|
+
s3 << r4
|
118
|
+
if r4
|
119
|
+
r6 = _nt_begin_slur
|
120
|
+
if r6
|
121
|
+
r5 = r6
|
122
|
+
else
|
123
|
+
r5 = instantiate_node(SyntaxNode,input, index...index)
|
124
|
+
end
|
125
|
+
s3 << r5
|
126
|
+
end
|
127
|
+
if s3.last
|
128
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
129
|
+
r3.extend(Note0)
|
130
|
+
else
|
131
|
+
@index = i3
|
132
|
+
r3 = nil
|
133
|
+
end
|
134
|
+
if r3
|
135
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
136
|
+
r2 = r3
|
137
|
+
else
|
138
|
+
i7, s7 = index, []
|
139
|
+
r8 = _nt_begin_slur
|
140
|
+
s7 << r8
|
141
|
+
if r8
|
142
|
+
r10 = _nt_begin_triplet
|
143
|
+
if r10
|
144
|
+
r9 = r10
|
145
|
+
else
|
146
|
+
r9 = instantiate_node(SyntaxNode,input, index...index)
|
147
|
+
end
|
148
|
+
s7 << r9
|
149
|
+
end
|
150
|
+
if s7.last
|
151
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
152
|
+
r7.extend(Note1)
|
153
|
+
else
|
154
|
+
@index = i7
|
155
|
+
r7 = nil
|
156
|
+
end
|
157
|
+
if r7
|
158
|
+
r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
|
159
|
+
r2 = r7
|
160
|
+
else
|
161
|
+
@index = i2
|
162
|
+
r2 = nil
|
163
|
+
end
|
164
|
+
end
|
165
|
+
if r2
|
166
|
+
r1 = r2
|
167
|
+
else
|
168
|
+
r1 = instantiate_node(SyntaxNode,input, index...index)
|
169
|
+
end
|
69
170
|
s0 << r1
|
70
171
|
if r1
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
172
|
+
r11 = _nt_duration
|
173
|
+
s0 << r11
|
174
|
+
if r11
|
175
|
+
i13, s13 = index, []
|
176
|
+
r14 = _nt_pitch_link
|
177
|
+
s13 << r14
|
178
|
+
if r14
|
179
|
+
s15, i15 = [], index
|
180
|
+
loop do
|
181
|
+
i16, s16 = index, []
|
182
|
+
if (match_len = has_terminal?(",", false, index))
|
183
|
+
r17 = true
|
184
|
+
@index += match_len
|
185
|
+
else
|
186
|
+
terminal_parse_failure('","')
|
187
|
+
r17 = nil
|
188
|
+
end
|
189
|
+
s16 << r17
|
190
|
+
if r17
|
191
|
+
r18 = _nt_pitch_link
|
192
|
+
s16 << r18
|
193
|
+
end
|
194
|
+
if s16.last
|
195
|
+
r16 = instantiate_node(SyntaxNode,input, i16...index, s16)
|
196
|
+
r16.extend(Note2)
|
197
|
+
else
|
198
|
+
@index = i16
|
199
|
+
r16 = nil
|
200
|
+
end
|
201
|
+
if r16
|
202
|
+
s15 << r16
|
203
|
+
else
|
204
|
+
break
|
205
|
+
end
|
84
206
|
end
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
207
|
+
r15 = instantiate_node(SyntaxNode,input, i15...index, s15)
|
208
|
+
s13 << r15
|
209
|
+
if r15
|
210
|
+
r20 = _nt_articulation
|
211
|
+
if r20
|
212
|
+
r19 = r20
|
213
|
+
else
|
214
|
+
r19 = instantiate_node(SyntaxNode,input, index...index)
|
215
|
+
end
|
216
|
+
s13 << r19
|
89
217
|
end
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
218
|
+
end
|
219
|
+
if s13.last
|
220
|
+
r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
|
221
|
+
r13.extend(Note3)
|
222
|
+
else
|
223
|
+
@index = i13
|
224
|
+
r13 = nil
|
225
|
+
end
|
226
|
+
if r13
|
227
|
+
r12 = r13
|
228
|
+
else
|
229
|
+
r12 = instantiate_node(SyntaxNode,input, index...index)
|
230
|
+
end
|
231
|
+
s0 << r12
|
232
|
+
if r12
|
233
|
+
i22 = index
|
234
|
+
i23, s23 = index, []
|
235
|
+
r24 = _nt_end_triplet
|
236
|
+
s23 << r24
|
237
|
+
if r24
|
238
|
+
r26 = _nt_end_slur
|
239
|
+
if r26
|
240
|
+
r25 = r26
|
241
|
+
else
|
242
|
+
r25 = instantiate_node(SyntaxNode,input, index...index)
|
243
|
+
end
|
244
|
+
s23 << r25
|
96
245
|
end
|
97
|
-
if
|
98
|
-
|
246
|
+
if s23.last
|
247
|
+
r23 = instantiate_node(SyntaxNode,input, i23...index, s23)
|
248
|
+
r23.extend(Note4)
|
99
249
|
else
|
100
|
-
|
250
|
+
@index = i23
|
251
|
+
r23 = nil
|
101
252
|
end
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
if r5
|
106
|
-
r10 = _nt_articulation
|
107
|
-
if r10
|
108
|
-
r9 = r10
|
253
|
+
if r23
|
254
|
+
r23 = SyntaxNode.new(input, (index-1)...index) if r23 == true
|
255
|
+
r22 = r23
|
109
256
|
else
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
257
|
+
i27, s27 = index, []
|
258
|
+
r28 = _nt_end_slur
|
259
|
+
s27 << r28
|
260
|
+
if r28
|
261
|
+
r30 = _nt_end_triplet
|
262
|
+
if r30
|
263
|
+
r29 = r30
|
264
|
+
else
|
265
|
+
r29 = instantiate_node(SyntaxNode,input, index...index)
|
266
|
+
end
|
267
|
+
s27 << r29
|
268
|
+
end
|
269
|
+
if s27.last
|
270
|
+
r27 = instantiate_node(SyntaxNode,input, i27...index, s27)
|
271
|
+
r27.extend(Note5)
|
272
|
+
else
|
273
|
+
@index = i27
|
274
|
+
r27 = nil
|
275
|
+
end
|
276
|
+
if r27
|
277
|
+
r27 = SyntaxNode.new(input, (index-1)...index) if r27 == true
|
278
|
+
r22 = r27
|
117
279
|
else
|
118
|
-
|
280
|
+
@index = i22
|
281
|
+
r22 = nil
|
119
282
|
end
|
120
|
-
s3 << r11
|
121
283
|
end
|
284
|
+
if r22
|
285
|
+
r21 = r22
|
286
|
+
else
|
287
|
+
r21 = instantiate_node(SyntaxNode,input, index...index)
|
288
|
+
end
|
289
|
+
s0 << r21
|
122
290
|
end
|
123
291
|
end
|
124
|
-
if s3.last
|
125
|
-
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
126
|
-
r3.extend(Note1)
|
127
|
-
else
|
128
|
-
@index = i3
|
129
|
-
r3 = nil
|
130
|
-
end
|
131
|
-
if r3
|
132
|
-
r2 = r3
|
133
|
-
else
|
134
|
-
r2 = instantiate_node(SyntaxNode,input, index...index)
|
135
|
-
end
|
136
|
-
s0 << r2
|
137
292
|
end
|
138
293
|
if s0.last
|
139
294
|
r0 = instantiate_node(NoteNode,input, i0...index, s0)
|
140
|
-
r0.extend(
|
295
|
+
r0.extend(Note6)
|
141
296
|
else
|
142
297
|
@index = i0
|
143
298
|
r0 = nil
|
@@ -194,30 +349,6 @@ module Note
|
|
194
349
|
r0
|
195
350
|
end
|
196
351
|
|
197
|
-
def _nt_accent
|
198
|
-
start_index = index
|
199
|
-
if node_cache[:accent].has_key?(index)
|
200
|
-
cached = node_cache[:accent][index]
|
201
|
-
if cached
|
202
|
-
node_cache[:accent][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
203
|
-
@index = cached.interval.end
|
204
|
-
end
|
205
|
-
return cached
|
206
|
-
end
|
207
|
-
|
208
|
-
if (match_len = has_terminal?("!", false, index))
|
209
|
-
r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
210
|
-
@index += match_len
|
211
|
-
else
|
212
|
-
terminal_parse_failure("!")
|
213
|
-
r0 = nil
|
214
|
-
end
|
215
|
-
|
216
|
-
node_cache[:accent][start_index] = r0
|
217
|
-
|
218
|
-
r0
|
219
|
-
end
|
220
|
-
|
221
352
|
end
|
222
353
|
|
223
354
|
class NoteParser < Treetop::Runtime::CompiledParser
|