class Mystic::Chord
- Mystic::Chord
- Reference
- Object
Overview
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")
Defined in:
mystic/chord.crConstant Summary
-
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)
- .new(root : Mystic::Note, notes : Array(Note))
- .new(root : Mystic::Note, quality : String, notes : Array(Note) | Nil = nil)
- .new(notes : Array(Note))
- .new(s : String)
Instance Method Summary
- #+(interval : Interval) : Chord
-
#==(other : self) : Bool
Returns
true
if this reference is the same as other. -
#bass : Note
Returns the lowest note
-
#get(member : Int32) : Note | Nil
Return the given member
-
#get(interval_from_root : Interval) : Note | Nil
Return the member of the chord given a specific interval_from_root.
- #intervals : Array(Interval)
-
#inversion : Int32
Returns the inversion number, or 0 if in root position
-
#invert(num : Int32, keep_root = true) : Chord
Returns the result of inverting the chord num times (upwards)
-
#invert(keep_root = true) : Chord
Returns the result of inverting the chord once (upwards).
- #name : String
- #note_names : Array(String)
- #notes : Array(Note)
-
#pitch_class_set : PitchClassSet
Returns the
PitchClassSet
of the notes -
#quality : String
Returns the chord quality
- #root : Note
-
#root_position : Chord
Returns the root position of the chord
Constructor Detail
Instance Method Detail
Returns true
if this reference is the same as other. Invokes same?
.
Return the given member
For example, chord.get(3) will return the 3rd of the chord
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")
Returns the result of inverting the chord num times (upwards)
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