This section introduces the use of chords in tabr. All of the functionality surrounding individual notes in phrases generalizes to chords. Chords symbols can also be displayed above sheet music staves and chord diagrams can be included at the top of sheet music scores using a chord chart. These topics are covered in the subsequent section on tracks and scores. This section here focuses on using chords in phrase where their notation will become part of the content engraved in the sheet music staves.

Chord syntax

Like individual pitches, chords and other combinations of simultaneous pitches can be specified in multiple equivalent ways. The only difference is that there are no spaces between the notes. The following are equivalent ways to specify the same open C major chord.

phrase("cegc'e' c3e3g3c4e4 cegc4e4", 4)
#> <Musical phrase>
#> <c e g c' e'>4 <c e g c' e'>4 <c e g c' e'>4

When the notes of a chord are tied over to the next, it is convenient to use tie to avoid having to write the ~ explicitly for each note in the chord.

#> <Noteworthy string>
#>   Format: space-delimited time
#>   Values: <c3~e3~g3~c4~e4~>

Similar to notes, explicit string numbers passed to the string argument also require simply removing the spaces between individual notes. Recall the abbreviated syntax style 5s and the expansion operator. Be careful with simple recycling, however. It does not work here for string number. Recycling will only work when it is a single note (single string entry) that can be passed as an single integer, like how the 4 below is passed as a recycled quarter beat. You cannot passed "5s" for example.

chords <- "cegc'e' c3e3g3c4e4 cegc4e4"
phrase(chords, 4, "54321 54321 54321")
#> <Musical phrase>
#> <c\5 e\4 g\3 c'\2 e'\1>4 <c\5 e\4 g\3 c'\2 e'\1>4 <c\5 e\4 g\3 c'\2 e'\1>4
phrase(chords, 4, "5s*3")
#> <Musical phrase>
#> <c\5 e\4 g\3 c'\2 e'\1>4 <c\5 e\4 g\3 c'\2 e'\1>4 <c\5 e\4 g\3 c'\2 e'\1>4

Chord syntax for fretboard diagrams

Chord diagrams refer to the fretboard diagrams commonly displayed in sheet music written for guitar. These chord diagram specifications are passed to score, discussed in the next section that brings together the overall process of moving from phrases to tracks to a score. Here, the syntax used to specify chords for chord diagrams is introduced. Below are some chords that appear in a song.

Note that minor chord names, indicated by m, are one of the available chord modifiers. These modifiers come after the separator :. This is different from how key signatures can be expressed throughout most of tabr, with just a "dm" for example, but the modifiers that follow the colon have more general uses for chord diagrams. There will be more examples of this in a moment.

The chords also require position descriptions, because the same chord can be played many ways. This is the part that fully defines the chord diagram. As is standard, x means a string is not played and o refers to an open string. The numbers refer to the fret. The string is six characters representing strings six through one (low to high pitch) from left to right.

chord_names <- c("d:m", "f", "g:m", "a")
chord_positions <- c("xxo231", "133211", "355333", "xo222o")

Named vector input

If the chord positions are a named vector, there is no need to pass both positions and names separately to chord_set. It will check the first argument for names before looking to the second argument.

#>            d:m              f            g:m              a 
#> "x;x;o;2;3;1;" "1;3;3;2;1;1;" "3;5;5;3;3;3;" "x;o;2;2;2;o;"
#> [1] TRUE

Analogous to phrase, chord_set is a simple function that manipulates the input strings into a named character vector of chord entries in a format understood by LilyPond.

Chord chart

Next, to demonstrate the chord chart, make a dummy song and include the chord set. The output for the dummy song now contains a chord chart centered at the top of the first page of sheet music.


The next example highlights several facts about chord specification for fretboard diagrams and chord charts.

Chord symbols and sequences

You have already seen chord symbols, placed above the fretboard diagrams above. Chord symbols refer to the shorthand chord notation, or chord labels, often shown above chord diagrams as well as above a music staff at the beginning of measures or at each chord change. These are the familiar labels such as C Dm F# F/C. The next use of chords is placement above the staff in time. This is the chord sequence.

In order to place chord symbols in time above a music staff, it is necessary to specify their sequence and the duration of each chord, just like is required for all the notes and chords shown inside the staff that are created from a sequence of phrase objects. The two examples below uses a simple melody of arpeggiated, broken chords played using the chords C, F and G. Those chord symbols are shown above the staff at the appropriate point in time based on the defined chord sequence.

notes <- "c e g c' e' c' g e g b d' g' f a c' f' c e g e c"
info <- c("8*20 2", "4*20 1")
strings <- pc(c(5:1, 2:4, 4:1, 4:1, 5:3, 4:5)) # almost not needed, but for 1st 2 notes of G chord
p1 <- p(notes, info[1], strings)
p2 <- p(notes, info[2], strings)
chords <- chord_set(c(c = "x32o1o", f = "xx3211", g = "xx5433", r = NA, s = NA))

Chord sequence

In the first version, there is a chord change halfway through a measure. Assign beat duration information for each chord in the sequence just as you would with the info argument to phrase, e.g., half a measure is given with 2. The C chord is played for a full measure both times while the F and G chords each last half a measure. The chord sequence is named just like chords above. This is how the correct chord symbol is applied above the staff at the correct time. Taking the names directly from chords as a chord dictionary for the song is the suggested way to avoid having to type chord symbols repeatedly.

Finally, score takes a chord_seq argument after the chords argument. Building on the previous example, here both are passed to score.

Using rests

Version two double the duration of all notes. Now the C chord lasts for two full measures while the F and G chords are played for one measure each. You can always specify a chord for every measure, in this case providing the C chord in the sequence twice in a row for one measure each. However, this example uses rests. Note the inclusion of r and s in the current chords vector.

To illustrate how rests factor into chord sequences, a silent rest is used for measure two. This avoids showing the C chord twice in a row without a chord change in between. Nothing is shown above the staff at this point in time. The final measure of the phrase uses a regular rest, which is not silent. This leads to the “no chord” symbol N.C. being printed above the staff. You do not show a chord as lasting longer than a measure by providing values less than one. This example also shows a very simple but also very common case where a song does have every chord in its chord sequence last for exactly one measure.

Overall picture

Since the chord chart is included and was only shown in prior examples zoomed in, here is the result above showing the full sheet, which includes the staves and chord symbols, the chord chart positioned top center, and for perspective the page numbering in the top right corner.

To sum up, chords are used in tabr in three ways. Using phrase, they appear among other notes in staves as the core component of the music transcription. They are also used by score to generate chord charts using fretboard diagrams that summarize all the chords that occur in a song. Finally, the same chord symbols can be listed in sequence with corresponding durations to be applied above a music staff, showing the chord progression throughout the song in proper time.