songleaf.diagrams¶
Chord diagrams for the sheet: piano keys or guitar shapes (songleaf#13).
The chords a song uses (song_chords(), in order of first use) are drawn as a strip
of small diagrams. Both kinds come from the chord’s pitch classes alone
(chord_tones()), so no fingering table is needed, and none has to be licensed:
piano: a two-octave keyboard with the chord’s notes marked, in close position from the bass;
guitar: a shape in standard tuning found by search (
guitar_shape()): the lowest sounding string plays the bass (the root, or the slash bass), every chord tone sounds, the fret span is at most four frets and four fingers (notes at the lowest fret share one barre finger, unless an open string lies under the barre), and fewer muted strings, lower positions, fewer fingers and no open string between fretted ones are preferred.
The layout reserves the strip’s height before it fits the font size, so the lyrics
shrink to make room (strip_height()); draw_strip() draws it.
>>> chord_tones("Cmaj7"), chord_tones("Am/G"), chord_tones("F#m7b5")
((0, 4, 7, 11), (7, 9, 0, 4), (6, 9, 0, 4))
>>> guitar_shape("C"), guitar_shape("E"), guitar_shape("G")
((None, 3, 2, 0, 1, 0), (0, 2, 2, 1, 0, 0), (3, 2, 0, 0, 0, 3))
Module Attributes
Standard guitar tuning, low to high, as pitch classes (E A D G B E). |
Functions
|
The chord's pitch classes, bass first (the root, or the bass of a slash chord). |
|
Draw the diagrams in rows, left to right, the strip's bottom at |
|
Frets per string, low to high ( |
|
The distinct chord symbols of |
|
The height a strip of |
Classes
|
Sizes of a diagram, in units of the lyric font size, and its colours. |
- class songleaf.diagrams.DiagramStyle(piano_width=4.2, piano_height=1.5, guitar_width=1.9, guitar_height=2.2, label_scale=0.6, gap=0.7, line_color='#555555', mark_color='#222222', black_key_color='#444444')[source]¶
Bases:
objectSizes of a diagram, in units of the lyric font size, and its colours.
- songleaf.diagrams.STANDARD_TUNING = (4, 9, 2, 7, 11, 4)¶
Standard guitar tuning, low to high, as pitch classes (E A D G B E).
- songleaf.diagrams.chord_tones(symbol)[source]¶
The chord’s pitch classes, bass first (the root, or the bass of a slash chord).
Triads by quality (
m,dim,aug/+,sus2,sus4,5), then sevenths (7,maj7,dim7,m7b5), sixths and added ninths.Nonefor whatsongleaf.harmony.parse_chord()does not read as a chord.
- songleaf.diagrams.draw_strip(canvas, symbols, kind, *, left, bottom, width, size, font, style=DiagramStyle(piano_width=4.2, piano_height=1.5, guitar_width=1.9, guitar_height=2.2, label_scale=0.6, gap=0.7, line_color='#555555', mark_color='#222222', black_key_color='#444444'))[source]¶
Draw the diagrams in rows, left to right, the strip’s bottom at
bottom.- Return type:
- songleaf.diagrams.guitar_shape(symbol, *, tuning=(4, 9, 2, 7, 11, 4), max_fret=12)[source]¶
Frets per string, low to high (
None= not played), or None if none is found.
- songleaf.diagrams.song_chords(song)[source]¶
The distinct chord symbols of
songthatchord_tones()reads, in order.
- songleaf.diagrams.strip_height(n, kind, size, width, *, style=DiagramStyle(piano_width=4.2, piano_height=1.5, guitar_width=1.9, guitar_height=2.2, label_scale=0.6, gap=0.7, line_color='#555555', mark_color='#222222', black_key_color='#444444'))[source]¶
The height a strip of
ndiagrams takes acrosswidth(0 for none).- Return type: