Module: Music::Transcription::Parsing::Note
- Includes:
- Articulation, Duration, Link, Pitch, Treetop::Runtime
- Included in:
- NoteParser
- Defined in:
- lib/music-transcription/parsing/note_parsing.rb
Defined Under Namespace
Modules: Note0, Note1, Note2, PitchLink0
Instance Method Summary collapse
Methods included from Duration
#_nt_den_only, #_nt_duration, #_nt_num_and_den, #_nt_num_only
Methods included from PositiveInteger
Methods included from NonnegativeInteger
Methods included from Link
#_nt_glissando, #_nt_legato_link, #_nt_link, #_nt_portamento, #_nt_slur_link, #_nt_tie
Methods included from Pitch
#_nt_cent, #_nt_letter_a, #_nt_letter_b, #_nt_letter_c, #_nt_letter_d, #_nt_letter_e, #_nt_letter_f, #_nt_letter_g, #_nt_octave, #_nt_pitch, #_nt_pitch_letter
Methods included from Articulation
#_nt_articulation, #_nt_legato, #_nt_portato, #_nt_slur, #_nt_staccatissimo, #_nt_staccato, #_nt_tenuto
Instance Method Details
#_nt_accent ⇒ Object
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/music-transcription/parsing/note_parsing.rb', line 198 def _nt_accent start_index = index if node_cache[:accent].has_key?(index) cached = node_cache[:accent][index] if cached node_cache[:accent][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end if (match_len = has_terminal?("!", false, index)) r0 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure("!") r0 = nil end node_cache[:accent][start_index] = r0 r0 end |
#_nt_note ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/music-transcription/parsing/note_parsing.rb', line 57 def _nt_note start_index = index if node_cache[:note].has_key?(index) cached = node_cache[:note][index] if cached node_cache[:note][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_duration s0 << r1 if r1 r3 = _nt_articulation if r3 r2 = r3 else r2 = instantiate_node(SyntaxNode,input, index...index) end s0 << r2 if r2 i5, s5 = index, [] r6 = _nt_pitch_link s5 << r6 if r6 s7, i7 = [], index loop do i8, s8 = index, [] if (match_len = has_terminal?(",", false, index)) r9 = true @index += match_len else terminal_parse_failure(",") r9 = nil end s8 << r9 if r9 r10 = _nt_pitch_link s8 << r10 end if s8.last r8 = instantiate_node(SyntaxNode,input, i8...index, s8) r8.extend(Note0) else @index = i8 r8 = nil end if r8 s7 << r8 else break end end r7 = instantiate_node(SyntaxNode,input, i7...index, s7) s5 << r7 end if s5.last r5 = instantiate_node(SyntaxNode,input, i5...index, s5) r5.extend(Note1) else @index = i5 r5 = nil end if r5 r4 = r5 else r4 = instantiate_node(SyntaxNode,input, index...index) end s0 << r4 if r4 r12 = _nt_accent if r12 r11 = r12 else r11 = instantiate_node(SyntaxNode,input, index...index) end s0 << r11 end end end if s0.last r0 = instantiate_node(NoteNode,input, i0...index, s0) r0.extend(Note2) else @index = i0 r0 = nil end node_cache[:note][start_index] = r0 r0 end |
#_nt_pitch_link ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/music-transcription/parsing/note_parsing.rb', line 162 def _nt_pitch_link start_index = index if node_cache[:pitch_link].has_key?(index) cached = node_cache[:pitch_link][index] if cached node_cache[:pitch_link][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_pitch s0 << r1 if r1 r3 = _nt_link if r3 r2 = r3 else r2 = instantiate_node(SyntaxNode,input, index...index) end s0 << r2 end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(PitchLink0) else @index = i0 r0 = nil end node_cache[:pitch_link][start_index] = r0 r0 end |
#root ⇒ Object
11 12 13 |
# File 'lib/music-transcription/parsing/note_parsing.rb', line 11 def root @root ||= :note end |