class

Mystic::Chord

Inherits Reference < Object

Represents a chord

A chord has a root note, intervals (indicating the intervals above the root in root position), and an array of notes

Some ways to create a Chord:

# Create with root note and quality
Chord.new(Note.new("C4"), "major")

# Create a chord with notes. The lowest will be assumed to be the root
# (C major)
Chord.new([Note.new("C4"), Note.new("E4"), Note.new("G4")])

# Create with root note and notes
# (C major, 1st inversion)
Chord.new(Note.new("C4"), [Note.new("E4"), Note.new("G4"), Note.new("C5")])

# Create chord with custom intervals
Chord.new(Note.new("C4"), [Interval.new("M2"), Interval.new("P5")])

# Shorthand with chord symbols
Chord.new("Cmb9#11")

Constants

ALIASES = { dominant: "dominant seventh", diminished: "fully diminished", "augmented dominant seventh": "augmented seventh", }
INTERVAL_QUALITIES = QUALITY_INTERVALS.to_h.invert
QUALITY_INTERVALS = { major: ["M3", "P5"], minor: ["m3", "P5"], diminished: ["m3", "d5"], augmented: ["M3", "A5"], "major seventh": ["M3", "P5", "M7"], "dominant seventh": ["M3", "P5", "m7"], "minor seventh": ["m3", "P5", "m7"], "minor major seventh": ["m3", "P5", "M7"], "half diminished seventh": ["m3", "d5", "m7"], "fully diminished seventh": ["m3", "d5", "d7"], "augmented seventh": ["M3", "A5", "m7"], "augmented major seventh": ["M3", "A5", "M7"], mystic: ["A4", "m7", "M10", "M13", "M16"], }

Constructors

new(root : Mystic::Note, intervals : Array(Interval), notes : Array(Note) | Nil = nil)
Source
new(root : Mystic::Note, notes : Array(Note))
Source
new(root : Mystic::Note, quality : String, notes : Array(Note) | Nil = nil)
Source
new(notes : Array(Note))
Source
new(s : String)
Source

Instance methods

+(interval : Interval) : Chord
Source
==(other : self) : Bool

Returns true if this reference is the same as other. Invokes same?.

Source
bass

Returns the lowest note

Source
get(member : Int32) : Note | Nil

Return the given member

For example, chord.get(3) will return the 3rd of the chord

Source
get(interval_from_root : Interval) : Note | Nil

Return the member of the chord given a specific interval_from_root.

This is a more specific version of Chord#get(member). This is useful if a chord has multiple notes with the same member number.

For example:

# Split 3rd chord (has 2 "3rds")
chord = Chord.new([Note.new("C4"), Note.new("Eb4"), Note.new("E4"), Note.new("G4")])
chord.get(Interval.new("M3")) # => Note.new("E4")
Source
intervals
Source
inversion

Returns the inversion number, or 0 if in root position

Source
invert(num : Int32, keep_root = true) : Chord

Returns the result of inverting the chord num times (upwards)

Source
invert(keep_root = true) : Chord

Returns the result of inverting the chord once (upwards). If keep_root is true, will maintain the same root note if inverted back to root position. This will result in all the notes shifting down some number of octave(s). Otherwise, the resulting chord will have a higher root note if inverted back to root position

Source
name
Source
note_names
Source
notes
Source
pitch_class_set

Returns the PitchClassSet of the notes

Source
quality

Returns the chord quality

Source
root
Source
root_position

Returns the root position of the chord

Source