Class: Music::Transcription::Parsing::NoteNode

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Defined in:
lib/music-transcription/parsing/note_node.rb

Instance Method Summary collapse

Instance Method Details

#primitives(env) ⇒ Object



5
6
7
# File 'lib/music-transcription/parsing/note_node.rb', line 5

def primitives env
  [ self.to_note ]
end

#to_noteObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/music-transcription/parsing/note_node.rb', line 9

def to_note
  pitches = []
  links = {}
  
  unless pitch_links.empty?
    first = pitch_links.first
    more = pitch_links.more
    
    pitches.push first.pitch.to_pitch
    unless first.the_link.empty?
      links[pitches[-1]] = first.the_link.to_link
    end
    
    more.elements.each do |x|
      pitches.push x.pl.pitch.to_pitch
      unless x.pl.the_link.empty?
        links[pitches[-1]] = x.pl.the_link.to_link
      end
    end
  end
  
  artic = Music::Transcription::Articulations::NORMAL
  unless art.empty?
    artic = art.to_articulation
  end
  
  accent_flag = acc.empty? ? false : true
  Music::Transcription::Note.new(duration.to_r,
    pitches, links: links, articulation: artic, accented: accent_flag)
end