lib/head_music/pitch.rb in head_music-0.26.3 vs lib/head_music/pitch.rb in head_music-0.27.0
- old
+ new
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-# A pitch is a named frequency represented by a spelling and an octive.
+# A pitch is a named frequency represented by a spelling and a register.
class HeadMusic::Pitch
include Comparable
attr_reader :spelling, :register
@@ -106,10 +106,14 @@
def to_i
midi_note_number
end
+ def helmholtz_notation
+ helmholtz_letter_name + helmholtz_marks
+ end
+
def natural
HeadMusic::Pitch.get(to_s.gsub(HeadMusic::Sign.matcher, ''))
end
def +(other)
@@ -208,7 +212,17 @@
end
def target_letter_name(num_steps)
@target_letter_name ||= {}
@target_letter_name[num_steps] ||= letter_name.steps_up(num_steps)
+ end
+
+ def helmholtz_letter_name
+ return spelling.to_s.downcase if HeadMusic::Register.get(register).helmholtz_case == :lower
+
+ spelling.to_s
+ end
+
+ def helmholtz_marks
+ HeadMusic::Register.get(register).helmholtz_marks
end
end