Mystic::Note
Represents a note, consisting of a note name (letter and accidental) and octave
To create a Note:
# Middle C
Note.new("C4")
# Middle C. Octave defaults to 4 if not provided
Note.new("C")
# Middle C
# In the case of accidentals, will default to using sharps.
Note.from_midi(60)
# The A above middle C
# This is used internally and may be less useful for most end users.
# See `Coords` for more information on Coordinate representation of pitches
Note.from_coords(Coords.new(-1, 3))
Constants
ALL_PITCHES = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]
BASE_OCTAVE = 4
Coordinates assume starting from C4
LETTER_PITCH_CLASSES = {
C: 0,
D: 2,
E: 4,
F: 5,
G: 7,
A: 9,
B: 11,
}
NAME_PATTERN = "(?<letter>[abcdefgABCDEFG])(?<accidental>[b♭𝄫]+|[#♯x𝄪]*)"
Regex pattern for a note name
PITCH_COORDS = {
C: Coords.new(0, 0),
D: Coords.new(-1, 2),
E: Coords.new(-2, 4),
F: Coords.new(1, -1),
G: Coords.new(0, 1),
A: Coords.new(-1, 3),
B: Coords.new(-2, 5),
}
PITCHES = ["C", "D", "E", "F", "G", "A", "B"]
Constructors
Class methods
Instance methods
+(interval : Interval) : Note
Source-(interval : Interval) : Note
Source-(other : self) : Interval
Source<=>(other : self) : Int32
Note: this compares notes as ordered on a staff rather than by pitch.
For example, a Cx4 < Db4 even though Cx4 sounds higher.
accidental
Sourceaccidental_offset
Sourceletter
Sourcename
Sourceoctave
Source