lib/head_music/scale.rb in head_music-0.19.2 vs lib/head_music/scale.rb in head_music-0.20.0
- old
+ new
@@ -7,11 +7,12 @@
def self.get(root_pitch, scale_type = nil)
root_pitch, scale_type = root_pitch.split(/\s+/) if root_pitch.is_a?(String) && scale_type =~ SCALE_REGEX
root_pitch = HeadMusic::Pitch.get(root_pitch)
scale_type = HeadMusic::ScaleType.get(scale_type || :major)
@scales ||= {}
- name = [root_pitch, scale_type].join(' ')
- hash_key = HeadMusic::Utilities::HashKey.for(name)
+ hash_key = HeadMusic::Utilities::HashKey.for(
+ [root_pitch, scale_type].join(' ').gsub(/#|♯/, 'sharp').gsub(/(\w)[b♭]/, '\\1flat')
+ )
@scales[hash_key] ||= new(root_pitch, scale_type)
end
delegate :letter_name_cycle, to: :root_pitch