Module: MTK::Lang::Pitches
- Defined in:
- lib/mtk/lang/pitches.rb
Overview
Because the character ‘#’ cannot be used in the name of a constant, the “black key” pitches are all named as flats with ‘b’ (for example, Gb3 or Cb4)
Because the character ‘-’ (minus) cannot be used in the name of a constant, the low pitches use ‘_’ (underscore) in place of ‘-’ (minus) (for example C_1).
Defines a constants for each Core::Pitch in the standard MIDI range using scientific pitch notation.
Constant Summary collapse
- PITCHES =
The values of all constants defined in this module
[]
- PITCH_NAMES =
The names of all constants defined in this module
[]
Class Method Summary collapse
-
.[](name) ⇒ Object
Lookup the value of an pitch constant by name.
Class Method Details
.[](name) ⇒ Object
Unlike Core::Pitch.from_s this method will accept either ‘_’ (underscore) or ‘-’ (minus) and treat it like ‘-’ (minus)
Unlike Core::Pitch.from_s this method only accepts the accidental ‘b’
Lookup the value of an pitch constant by name.
42 43 44 45 46 47 48 |
# File 'lib/mtk/lang/pitches.rb', line 42 def self.[](name) begin const_get name.sub('-','_') rescue nil end end |