Section Chords
Chord class and other chords utility functions, like extracting chords from the chord line of a staff.
- See
- Chord for raw music theory
Class
Class | Summary |
---|---|
Chord | Chord building, accept more notations than builtin HA chords. |
Summary
Return type | Function and summary |
---|---|
table | GetChordsFromStaff(Score score, Staff staff, boolean held) Get the chords of a Staff from the chord line and return detailed informations. |
int | TheoryStemsDirection(string case, table notes) Get the stem direction a group of beamed notes, or a chord, would have in normal conditions. |
Functions
GetChordsFromStaff(Score score, Staff staff, boolean held)
Get the chords of a Staff from the chord line and return detailed informations.
This is useful to build bass and chords accompaniments, perform analysis, or whatever you want.
The returned structure is a table, indexed from 1 to number of chords. Each element is a table which contains properties:
- Chord: a Chord object, able to parse more complex notations than HA. From this object, you can obtain the list of notes, chord octave, bass octave (2 octaves lower), inversion...
- BarNumber: the bar number where the chord is writed
- TimeBegin: time (in tick, from the beginning of the score), where the chord starts to play
- TimeEnd: time (in ticks, from the beginning of the score), where the chord ends, just before next chord or an empty cell/bar.
- ArppegioDelay: by default,
staff.ChordArpeggioDelay
. May change if [Annn] command has been encountered in chord line.
Parameter | Type | Default | Description |
---|---|---|---|
score | Score | score | |
staff | Staff | staff | |
held | boolean | nil | Hold chord until next is encountered? If nil , use the chord line setup of the staff. HA needs underscore (_) to hold a chord, but this is unsightly for printing, and works randomly. |
- Return
- table: table
- See
- Chord for more details about Chord object.
- Example
local chords = GetChordsFromStaff(FrontScore(), FrontScore().FirstStaff) for i=1,getn(chords) do print("Chord #" .. i .. ": "..chords[i].Chord:toASCIIName()) print("Bar #" .. chords[i].BarNumber) print(tdebug(chords[i].Chord:notes())) end
TheoryStemsDirection(string case, table notes)
Get the stem direction a group of beamed notes, or a chord, would have in normal conditions.
Stem direction is determinated by the note that is far than the middle line. In case of equal distance between the far top and far bottom, chord has stems up, beamed notes have stems down.
Parameter | Type | Default | Description |
---|---|---|---|
case | string | "chord" or "beam" | |
notes | table | table of Symbol, only notes are considered (Symbol.IsNote == true ) |
- Return
- int: STEM_UP or STEM_DOWN, nil if no symbol args are notes.