Method: Fet::Note#degree

Defined in:
lib/fet/note.rb

#degree(root_name) ⇒ Object

NOTE: Note.new(“E”).change_natural_note(“D”) -> Note.new(“Dx”) def change_natural_note(new_natural_note)

semitone_offset = accidental_to_semitone_offset
return Note.new("#{natural_note}#{self.class.accidental_from_semitone_offset(semitone_offset)}") if new_natural_note == natural_note

end



89
90
91
92
93
94
95
96
97
98
# File 'lib/fet/note.rb', line 89

def degree(root_name)
  notes_array = Fet::MusicTheory.notes_of_mode(root_name, "major")
  index = notes_array.index { |note| Note.new(note).natural_note == natural_note }

  degree = index + 1
  degree_note = Note.new(notes_array[index])

  accidental_difference = accidental_to_semitone_offset - degree_note.accidental_to_semitone_offset
  return "#{self.class.accidental_from_semitone_offset(accidental_difference)}#{degree}"
end