Sha256: 13ab08354453c7dade04959f06ecad20de44118842e8e1cd7adf1c01f2cd47ba

Contents?: true

Size: 1022 Bytes

Versions: 9

Compression:

Stored size: 1022 Bytes

Contents

module Music
module Transcription
module Parsing
  class NoteNode < Treetop::Runtime::SyntaxNode
    def primitives env
      [ self.to_note ]
    end
    
    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
  end
end
end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
music-transcription-0.21.0 lib/music-transcription/parsing/note_node.rb
music-transcription-0.20.0 lib/music-transcription/parsing/note_node.rb
music-transcription-0.19.0 lib/music-transcription/parsing/note_node.rb
music-transcription-0.17.1 lib/music-transcription/parsing/note_node.rb
music-transcription-0.17.0 lib/music-transcription/parsing/note_node.rb
music-transcription-0.16.0 lib/music-transcription/parsing/note_node.rb
music-transcription-0.15.0 lib/music-transcription/parsing/note_node.rb
music-transcription-0.14.0 lib/music-transcription/parsing/note_node.rb
music-transcription-0.13.0 lib/music-transcription/parsing/note_node.rb