class NoteFactory

an interface to create RBMusicTheory::Notes using lilypond notation

Public Class Methods

[](notesym)
Alias for: create
create(notesym) click to toggle source

notesym is a String - absolute pitch in the lilypond format. (currently alterations are not supported, as they are not necessary for our dealing with Gregorian chant.) returns a coresponding RBMusicTheory::Note

# File lib/lygre/gabcpitchreader.rb, line 48
def create(notesym)
  unless notesym =~ /^[a-g]('+|,+)?$/i
    raise ArgumentError.new('#{notesym} is not a valid lilypond absolute pitch')
  end

  note = notesym[0]
  octaves = notesym[1..-1]

  sign = 0
  octave = 0
  if octaves then
    sign = (octaves[0] == ',' ? -1 : 1)
    octave += (octaves.size * sign)
  end
  return MusicTheory::Note.new note.to_sym, octave
end
Also aliased as: create_note, []
create_note(notesym)
Alias for: create
lily_abs_pitch(note) click to toggle source

returns a lilypond absolute pitch for the given RbMusicTheory::Note

this method doesn't fit well in a factory, but create translates lilypond pitch to Note and lily_abs_pitch does the reverse translation, so maybe just the class should be renamed

# File lib/lygre/gabcpitchreader.rb, line 73
def lily_abs_pitch(note)
  octave_signs = (note.octave >= 0 ? "'" : ",") * note.octave.abs
  note.pitch.to_s + octave_signs
end