class GabcPitchReader
responsible for converting the 'visual pitch' information contained in gabc to absolute musical pitch
Constants
- CLEFS
- CLEF_POSITIONS
Attributes
base[R]
clef[R]
clef_position[R]
Public Class Methods
new(clef=:c, clef_position=4)
click to toggle source
# File lib/lygre/gabcpitchreader.rb, line 9 def initialize(clef=:c, clef_position=4) unless CLEFS.include? clef raise ArgumentError.new "#{clef} is not a valid clef" end unless CLEF_POSITIONS.include? clef_position raise ArgumentError.new "#{clef_position} is not a valid clef position" end @clef = clef @clef_position = clef_position init_base end
Public Instance Methods
pitch(visual_note)
click to toggle source
gets a gabc visual pitch, returns a RbMusicTheory::Note
# File lib/lygre/gabcpitchreader.rb, line 26 def pitch(visual_note) hnote = visual_note.to_s.ord - 'a'.ord # steps from a - the lowest writable gabc note return @base.diatonic_steps(hnote) end
Private Instance Methods
init_base()
click to toggle source
# File lib/lygre/gabcpitchreader.rb, line 33 def init_base steps = -1 * (3 + # a is 3 steps under the first line 2 * (@clef_position - 1)) # one step for each line and space @base = NoteFactory.create_note(CLEFS[@clef]).diatonic_steps(steps) end