class Mystic::Chord

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.cr

Constant 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

Instance Method Summary

Constructor Detail

def self.new(root : Mystic::Note, intervals : Array(Interval), notes : Array(Note) | Nil = nil) #

[View source]
def self.new(root : Mystic::Note, notes : Array(Note)) #

[View source]
def self.new(root : Mystic::Note, quality : String, notes : Array(Note) | Nil = nil) #

[View source]
def self.new(notes : Array(Note)) #

[View source]
def self.new(s : String) #

[View source]

Instance Method Detail

def +(interval : Interval) : Chord #

[View source]
def ==(other : self) : Bool #
Description copied from class Reference

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


[View source]
def bass : Note #

Returns the lowest note


[View source]
def get(member : Int32) : Note | Nil #

Return the given member

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


[View source]
def 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")

[View source]
def intervals : Array(Interval) #

[View source]
def inversion : Int32 #

Returns the inversion number, or 0 if in root position


[View source]
def invert(num : Int32, keep_root = true) : Chord #

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


[View source]
def 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


[View source]
def name : String #

[View source]
def note_names : Array(String) #

[View source]
def notes : Array(Note) #

[View source]
def pitch_class_set : PitchClassSet #

Returns the PitchClassSet of the notes


[View source]
def quality : String #

Returns the chord quality


[View source]
def root : Note #

[View source]
def root_position : Chord #

Returns the root position of the chord


[View source]