tabr (version 0.3.5)

phrase: Create a musical phrase

Description

Create a musical phrase from character strings that define notes, note metadata, and optionally explicit strings fretted. The latter can be used to ensure proper tablature layout.

Usage

phrase(notes, info, string = NULL, bar = FALSE)

p(notes, info, string = NULL, bar = FALSE)

Arguments

notes

character, notes a through g, comprising a noteworthy string. notes. See details.

info

character, metadata pertaining to the notes . See details.

string

character, optional string that specifies which guitar strings to play for each specific note.

bar

logical, insert a bar check at the end of the phrase.

Value

a phrase.

Details

Meeting all of the requirements for a string of notes to be valid tabr syntax is referred to as noteworthy. Noteworthy strings are referred to throughout the documentation. Such requirements are outlined below.

Noteworthy strings use space-delimited time. This means that notes and chords separated in time are separated in the notes string by spaces. This is by far the most common usage. However, many functions in tabr, including phrase, allow a notes or similar first function argument to be provided in vector form where each vector element is a single note or chord (single point in time). Internally, functions like phrase will manipulate these forms back and forth as needed. Having both input options provides useful flexibility for music programming in tabr in general. The pipe operator can also be leveraged to chain several functions together.

Sharps and flats are indicated by appending # and _, respectively, e.g. f# or g_.

Specifying notes that are one or multiple octaves below or above the third octave can be done by appending one or multiple commas or single quote tick marks, respectively, e.g. c, or c''. But this is not necessary. Instead, you can use octave numbering. This may be easier to read, generally more familiar, potentially requires less typing, can still be omitted completely for the third octave (no need to type c3, d3, ...), and is automatically converted for you by phrase to the tick mark format interpreted by LilyPond. That said, using the raised and lowered tick mark approach can be surprisingly easier to read for chords, which have no spaces between notes, especially six-string chords, given that the tick marks help break up the notes in the chord visually much more so than integers do. See examples.

The function p is a convenient shorthand wrapper for phrase.

Tied notes indicated by ~ are part of the note notation and not part of the info notation, e.g. c''~.

Notes can comprise chords. These are bound tightly rather than space-delimited, as they are not separated in time. For example, a C chord could be given as ceg and in the case of tied notes would be c~e~g~.

Other information about a note is indicated with the info string. The most pertinent information, minimally required, is the note duration. A string of space-delimited notes will always be accompanied by a space-delimited string of an equal number of integer durations. Durations are powers of 2: 1, 2, 4, 8, 16, 32, 64. They represent the fraction of a measure, e.g., 2 means 1/2 of a measure and 8 refers to an eighth note. Dotted notes are indicated by adding . immediately after the integer, e.g., 2. or 2... Any other note metadata is appended to these durations. See examples.

Opening and closing slurs (or hammer ons and pull offs) are indicated with opening and closing parentheses, slides with -, and simple bends with ^. Text annotations aligned vertically with a note in time on the staff is done by appending the text to the note info entry itself. See notate. For more details and example, see the package vignettes.

Examples

Run this code
# NOT RUN {
phrase("c ec'g' ec'g'", "4 4 2") # no string numbers (not recommended)
phrase("c ec4g4 ec4g4", "4 4 2") # same as above
phrase("c b, c", "4. 8( 8)", "5 5 5") # direction implies hammer on
phrase("b2 c d", "4( 4)- 2", "5 5 5") # hammer and slide

phrase("c ec'g' ec'g'", "1 1 1", "5 432 432")
p("c ec'g' ec'g'", "1 1 1", "5 432 432") # same as above
# }

Run the code above in your browser using DataCamp Workspace