Class Chord
Chord building, accept more notations than builtin HA chords.
Accepts also strings that look pretty with My Chord font but means nothing (", ', ! for °, Ø, Δ)...
Section
Section | Summary |
---|---|
Chords | Chord class and other chords utility functions, like extracting chords from the chord line of a staff. |
Summary
Field | Type | Summary |
---|---|---|
BassOctave | int | Octave of the bass |
ChordOctave | int | Octave of the fundamental of the chord, before inversion |
Inversion | int | Chord inversion: fundamental state, 1 to 4 up, 1 to 4 one octave down. |
IsAugmented | bool | Is this chord augmented? |
IsDiminished | bool | Is this chord diminished? |
IsMajor | bool | Is this chord major? |
IsMinor | bool | Is this chord minor? |
Return type | Function and summary |
---|---|
Chord | new(string chordName, Chord previousChord) Build a chord from its name |
table | bassNote() Get the bass note Anglo-Saxon name, pitch and accidental. |
table | notes(int numberOfNotes) Get the chord's notes in notes anglo-saxon names, pitch and preferred accidental. |
int | numberOfNotes() Get the number of notes in the chord. |
string | toASCIIName() Get the ASCII name of the Chord. |
string | toNumbers() Get the chord in numbers, for example 1 3 5 for major, 1 3b 5 for minor. |
Fields
int Chord:ChordOctave
Octave of the fundamental of the chord, before inversion
int Chord:BassOctave
Octave of the bass
int Chord:Inversion
Chord inversion: fundamental state, 1 to 4 up, 1 to 4 one octave down.
One of these constants from MSDefine:
- INVERSION_FUNDAMENTAL
- INVERSION_1ST
- INVERSION_2ND
- INVERSION_3RD
- INVERSION_4TH
- INVERSION_1ST_BOTTOM
- INVERSION_2ND_BOTTOM
- INVERSION_3RD_BOTTOM
- INVERSION_4TH_BOTTOM
bool Chord:IsMajor
Is this chord major?
bool Chord:IsMinor
Is this chord minor?
bool Chord:IsDiminished
Is this chord diminished?
bool Chord:IsAugmented
Is this chord augmented?
Methods
Chord:new(string chordName, Chord previousChord)
Build a chord from its name
Parameter | Type | Default | Description |
---|---|---|---|
chordName | string | Chord name, for example F#m, FaØ, Réb/Sib, C#dim7, Lamadd9 | |
previousChord | Chord | nil | If this chord is only a bass movement (for example /Bb, use the previous chord to complete it |
- Return
- Chord: A chord object.
Chord:toASCIIName()
Get the ASCII name of the Chord.
Sharp and flats are # and b, natural is =, Δ is Maj7, and Ø is m7b5.
- Return
- string:
Chord:toNumbers()
Get the chord in numbers, for example 1 3 5 for major, 1 3b 5 for minor.
- Return
- string:
Chord:notes(int numberOfNotes)
Get the chord's notes in notes anglo-saxon names, pitch and preferred accidental.
The structure returned is a indexed table. Each element is a table with following properties:
- RealName: Real name of note, may be incompatible with HA in extrema.
- CompatibleName: sanitized name compatible with HA,
Symbol.AngloSaxonName
- Pitch: Pitch between 0 and 127
- Accidental: constant from MSDefine (NATURAL, SHARP, FLAT...) for
Symbol.Accidental
local c = Chord:new("C#Maj7")
local notes = c:notes()
print(getn(notes)) --> 4
print(notes[1].RealName) --> "C#4"
print(notes[1].CompatibleName) --> "C#4"
print(notes[1].Pitch) --> 61
print(notes[1]) --> Accidental=SHARP
print(notes[2].RealName) --> "E4"
print( notes[2].Pitch) --> 64
print(notes[2].Accidental) --> NATURAL
-- ...
Bass note is not returned.Parameter | Type | Default | Description |
---|---|---|---|
numberOfNotes | int | nil | Minimum number of notes for the chord. 4 notes for C returns C E G + C. If the chord contains more notes, it won't be limited to this parameter: 4 notes for C9 returns C E G Bb D. If nil, no minimum of number of notes. |
- Return
- table:
- See
- Chord:bassNote
Chord:bassNote()
Get the bass note Anglo-Saxon name, pitch and accidental.
The structure returned is a table similar to one element (one note) returned by Chord:notes()
.
This table properties are:
- RealName: Real name of note, may be incompatible with HA in extrema.
- CompatibleName: sanitized name compatible with HA,
Symbol.AngloSaxonName
- Pitch: Pitch between 0 and 127
- Accidental: constant from MSDefine (NATURAL, SHARP, FLAT...) for
Symbol.Accidental
local c = Chord:new("D/C") local bass = c:bassNote() print(bass.RealName) --> "C2" print(bass.CompatibleName) --> "C2" print(bass.Pitch) --> 36 print(bass.Accidental) --> NATURAL
- Return
- table: