Class: Music::Transcription::Parsing::PitchNode

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

Instance Method Summary collapse

Instance Method Details

#to_pitchObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/music-transcription/parsing/pitch_node.rb', line 5

def to_pitch
  
  sem = pitch_letter.to_semitone
  unless mod.empty?
    sem += case mod.text_value
    when "#" then 1
    when "b" then -1
    end
  end
  oct = octave.to_i
  ncents = 0
  unless cents.empty?
    ncents = cents.to_i
  end
  
  Music::Transcription::Pitch.new(semitone: sem, octave: oct, cent: ncents)
end