Module: MTK::Lang::Pitches

Defined in:
lib/mtk/lang/pitches.rb

Overview

Note:

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)

Note:

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.

See en.wikipedia.org/wiki/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

Class Method Details

.[](name) ⇒ Object

Note:

Unlike Core::Pitch.from_s this method will accept either ‘_’ (underscore) or ‘-’ (minus) and treat it like ‘-’ (minus)

Note:

Unlike Core::Pitch.from_s this method only accepts the accidental ‘b’

Lookup the value of an pitch constant by name.

Examples:

lookup value of ‘C3’

MTK::Core::Pitches['C3']

See Also:



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