Skip to content

Commit 06f5171

Browse files
committed
Update documentation, update functions, bug fixes, for building against newer version of Lilypond (2.24.2).
1 parent ad41927 commit 06f5171

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+1956
-2176
lines changed

NAMESPACE

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,12 @@ S3method(tail,music)
9393
S3method(tail,noteinfo)
9494
S3method(tail,noteworthy)
9595
S3method(time_format,character)
96+
S3method(time_format,double)
9697
S3method(time_format,lyrics)
9798
S3method(time_format,music)
9899
S3method(time_format,noteinfo)
99100
S3method(time_format,noteworthy)
100-
export("%>%")
101+
S3method(time_format,numeric)
101102
export(accidental_type)
102103
export(as_integer_octaves)
103104
export(as_lyrics)
@@ -404,10 +405,9 @@ export(xm9)
404405
export(xma9)
405406
export(xs2)
406407
export(xs4)
407-
importFrom(dplyr,tibble)
408408
importFrom(graphics,par)
409409
importFrom(graphics,plot.new)
410410
importFrom(graphics,rasterImage)
411-
importFrom(magrittr,"%>%")
411+
importFrom(tibble,tibble)
412412
importFrom(utils,head)
413413
importFrom(utils,tail)

R/chord_mapping.R

Lines changed: 46 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,39 @@
44
#'
55
#' This function creates a tibble data frame containing information defining
66
#' various attributes of chords.
7-
#' It is used to create the \code{guitarChords} dataset, but can be used to
8-
#' create other pre-defined chord collections.
7+
#' It is used to create the `guitarChords` dataset, but can be used to create
8+
#' other pre-defined chord collections.
99
#' The tibble has only one row, providing all information for the defined chord.
1010
#' The user can decide which arguments to vectorize over when creating a chord
1111
#' collection. See examples.
1212
#'
13-
#' This function uses a vector of fret integers (\code{NA} for muted string) to
14-
#' define a chord, in conjunction with a string \code{tuning} (defaults to
15-
#' standard tuning, six-string guitar).
16-
#' \code{fret} is from lowest to highest pitch strings, e.g., strings six
17-
#' through one.
13+
#' This function uses a vector of fret integers (`NA` for muted string) to
14+
#' define a chord, in conjunction with a string `tuning` (defaults to standard
15+
#' tuning, six-string guitar). `fret` is from lowest to highest pitch strings,
16+
#' e.g., strings six through one.
1817
#'
19-
#' The \code{id} is passed directly to the output. It represents the type of
20-
#' chord and should conform to accepted \code{tabr} notation. See \code{id}
21-
#' column in \code{guitar Chords} for examples.
18+
#' The `id` is passed directly to the output. It represents the type of chord
19+
#' and should conform to accepted `tabr` notation. See `id` column in
20+
#' `guitarChords` for examples.
2221
#'
23-
#' Note that the \code{semitones} column gives semitone intervals between chord
22+
#' Note that the `semitones` column gives semitone intervals between chord
2423
#' notes. These count from zero as the lowest pitch based on the tuning of the
2524
#' instrument, e.g., zero is E2 with standard guitar tuning. To convert these
2625
#' semitone intervals to standard semitone values assigned to pitches, use
27-
#' e.g., \code{pitch_semitones("e2")} (40) if that is the lowest pitch and add
26+
#' e.g., `pitch_semitones("e2")` (40) if that is the lowest pitch and add
2827
#' that value to the instrument semitone interval values.
2928
#' This is the explanation, but doing this is not necessary. You can use
30-
#' \code{\link{chord_semitones}} to compute semitones directly on pitches in a
29+
#' [chord_semitones()] to compute semitones directly on pitches in a
3130
#' chord.
3231
#'
3332
#' @param fret integer vector defining fretted chord. See details.
3433
#' @param id character, the chord type. See details.
35-
#' @param optional \code{NA} when all notes required. Otherwise an integer
36-
#' vector giving the indices of\code{fret} that are considered optional notes
34+
#' @param optional `NA` when all notes required. Otherwise an integer
35+
#' vector giving the indices of`fret` that are considered optional notes
3736
#' for the chord.
38-
#' @param tuning character, string tuning. See \code{tunings} for predefined
39-
#' tunings. Custom tunings are specified with a similar \code{value} string.
40-
#' @param ... additional arguments passed to \code{transpose}.
37+
#' @param tuning character, string tuning. See `tunings` for predefined
38+
#' tunings. Custom tunings are specified with a similar `value` string.
39+
#' @param ... additional arguments passed to `transpose()`.
4140
#'
4241
#' @return a data frame
4342
#' @export
@@ -114,19 +113,19 @@ chord_def <- function(fret, id, optional = NA, tuning = "standard", ...){
114113
#'
115114
#' Obtain LilyPond quasi-chord notation.
116115
#'
117-
#' These functions take a \code{tabr} syntax representation of a chord name and
116+
#' These functions take a `tabr` syntax representation of a chord name and
118117
#' convert it to quasi-LilyPond syntax;
119-
#' "quasi" because the result still uses \code{_} for flats and \code{#} for
120-
#' sharps, whereas LilyPond itself uses \code{es} and \code{is} (mostly).
121-
#' This is the format used by \code{tabr} functions involved in communicating
122-
#' with LilyPond for music transcription, and they make these final conversions
123-
#' on the fly.
124-
#' This can be overridden with \code{exact = TRUE}.
118+
#' "quasi" because the result still uses `_` for flats and `#` for sharps,
119+
#' whereas LilyPond itself uses `es` and `is` (mostly).
120+
#' This is the format used by `tabr` functions involved in communicating with
121+
#' LilyPond for music transcription, and they make these final conversions on
122+
#' the fly.
123+
#' This can be overridden with `exact = TRUE`.
125124
#'
126125
#' @param root character, root note.
127-
#' @param chord character, \code{tabr} format chord name.
126+
#' @param chord character, `tabr` format chord name.
128127
#' @param exact logical, return a more exact LilyPond chord representation.
129-
#' @param ... additional arguments passed to \code{transpose}.
128+
#' @param ... additional arguments passed to `transpose()`.
130129
#'
131130
#' @return character
132131
#' @export
@@ -198,34 +197,31 @@ lp_chord_mod <- function(root, chord, exact = FALSE, ...){
198197
#' These functions assist with mapping between different information that
199198
#' define chords.
200199
#'
201-
#' For \code{gc_is_known}, a check is done against chords in the
202-
#' \code{guitarChords} dataset.
203-
#' A simple noteworthy string is permitted, but any single-note entry will
204-
#' automatically yield a \code{FALSE} result.
200+
#' For `gc_is_known()`, a check is done against chords in the `guitarChords`
201+
#' dataset. A simple noteworthy string is permitted, but any single-note entry
202+
#' will automatically yield a `FALSE` result.
205203
#'
206-
#' \code{gc_info} returns a tibble data frame containing complete information
207-
#' for the subset of predefined guitar chords specified by \code{name} and
208-
#' \code{key}.
209-
#' Any accidentals present in the chord root of \code{name} (but not in the
210-
#' chord modifier, e.g., \code{m7_5} or \code{m7#5}) are converted according to
211-
#' \code{key} if necessary.
212-
#' \code{gc_notes} and \code{gc_fretboard} are wrappers around \code{gc_info},
213-
#' which return noteworthy strings of chord notes and a named vector of
214-
#' LilyPond fretboard diagram data, respectively.
204+
#' `gc_info()` returns a tibble data frame containing complete information for
205+
#' the subset of predefined guitar chords specified by `name` and `key`.
206+
#' Any accidentals present in the chord root of `name` (but not in the chord
207+
#' modifier, e.g., `m7_5` or `m7#5`) are converted according to `key` if
208+
#' necessary.
209+
#' `gc_notes()` and `gc_fretboard()` are wrappers around `gc_info()`, which
210+
#' return noteworthy strings of chord notes and a named vector of LilyPond
211+
#' fretboard diagram data, respectively.
215212
#' Note that although the input to these functions can contain multiple chord
216213
#' names, whether as a vector or as a single space-delimited string, the result
217214
#' is not intended to be of equal length.
218-
#' These functions filter \code{guitarChords}. The result is the set of all
215+
#' These functions filter `guitarChords`. The result is the set of all
219216
#' chords matched by the supplied input filters.
220217
#'
221-
#' \code{gc_name_split} splits a vector or space-delimited set of chord
222-
#' names into a tibble data frame containing separate chord root and chord
223-
#' modifier columns.
224-
#' \code{gc_name_root} and \code{gc_name_mod} are wrappers around this.
218+
#' `gc_name_split()` splits a vector or space-delimited set of chord names into
219+
#' a tibble data frame containing separate chord root and chord modifier columns.
220+
#' `gc_name_root()` and `gc_name_mod()` are wrappers around this.
225221
#'
226222
#' @param notes character, a noteworthy string.
227-
#' @param name character, chord name in \code{tabr} format, e.g.,
228-
#' \code{"bM b_m b_m7#5"}, etc.
223+
#' @param name character, chord name in `tabr` format, e.g., `"bM b_m b_m7#5"`,
224+
#' etc.
229225
#' @param root_octave integer, optional filter for chords whose root note is in
230226
#' a set of octave numbers. May be a vector.
231227
#' @param root_fret integer, optional filter for chords whose root note matches
@@ -234,11 +230,11 @@ lp_chord_mod <- function(root, chord, exact = FALSE, ...){
234230
#' or above a specific fret. May be a vector.
235231
#' @param bass_string integer, optional filter for chords whose lowest pitch
236232
#' string matches a specific string, 6, 5, or 4. May be a vector.
237-
#' @param open logical, optional filter for open and movable chords. \code{NULL}
233+
#' @param open logical, optional filter for open and movable chords. `NULL`
238234
#' retains both types.
239235
#' @param key character, key signature, used to enforce type of accidentals.
240-
#' @param ignore_octave logical, if \code{TRUE}, functions like \code{gc_info}
241-
#' and \code{gc_fretboard} return more results.
236+
#' @param ignore_octave logical, if `TRUE`, functions like `gc_info()` and
237+
#' `gc_fretboard()` return more results.
242238
#'
243239
#' @return various, see details regarding each function.
244240
#' @export

R/chords.R

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#' Chord inversion
22
#'
3-
#' This function inverts a single chord given as a character string.
4-
#' If \code{n = 0}, \code{chord} is returned immediately.
5-
#' Otherwise, the notes of the chord are inverted. If \code{abs(n)} is greater
6-
#' than the number of inversions (excluding root position), an error is thrown.
3+
#' This function inverts a single chord given as a character string. If `n = 0`,
4+
#' `chord` is returned immediately. Otherwise, the notes of the chord are
5+
#' inverted. If `abs(n)` is greater than the number of inversions (excluding
6+
#' root position), an error is thrown.
77
#'
8-
#' Note that \code{chord_invert} has no knowledge of whether a chord might be
8+
#' Note that `chord_invert()` has no knowledge of whether a chord might be
99
#' considered as in root position or some inversion already, as informed by a
1010
#' key signature, chord name or user's intent.
1111
#' This function simply inverts what it receives, treating any defined chord
@@ -20,7 +20,7 @@
2020
#' having the highest pitch.
2121
#' The second lowest note becomes the lowest. It's octave does not change.
2222
#' This pattern is repeated for higher order inversions. The opposite happens
23-
#' if \code{n} is negative.
23+
#' if `n` is negative.
2424
#'
2525
#' The procedure ensures that the resulting inverted chord is still defined by
2626
#' notes of increasing pitch.
@@ -76,15 +76,15 @@ chord_invert <- function(chord, n = 0, limit = FALSE){
7676
#'
7777
#' Create an arpeggio from a chord.
7878
#'
79-
#' This function is based on \code{chord_invert}. If \code{n = 0} then
80-
#' \code{chord} is returned immediately; other arguments are ignored.
79+
#' This function is based on `chord_invert`. If `n = 0` then `chord` is returned
80+
#' immediately; other arguments are ignored.
8181
#'
8282
#' @param chord character, a single chord.
8383
#' @param n integer, number of steps, negative indicates reverse direction
8484
#' (decreasing pitch).
85-
#' @param by whether each of the \code{n} steps refers to individual notes in
86-
#' the chord (an inversion) or raising the entire chord in its given position
87-
#' by one octave.
85+
#' @param by whether each of the `n` steps refers to individual notes in the
86+
#' chord (an inversion) or raising the entire chord in its given position by one
87+
#' octave.
8888
#' @param broken logical, return result as an arpeggio of broken chords.
8989
#' @param collapse logical, collapse result into a single string ready for
9090
#' phrase construction.
@@ -141,26 +141,26 @@ chord_break <- function(notes){
141141
#'
142142
#' Construct a dyad given one note, an interval, and a direction.
143143
#'
144-
#' The \code{interval} may be specified by semitones of by common interval name
144+
#' The `interval` may be specified by semitones of by common interval name
145145
#' or abbreviation. See examples.
146146
#' For a complete list of valid interval names and abbreviations see
147-
#' \code{\link{mainIntervals}}.
148-
#' \code{key} enforces the use of sharps or flats. This function is based on
149-
#' \code{transpose}.
150-
#' \code{notes} and \code{interval} may be vectors, but must be equal length.
147+
#' [mainIntervals()].
148+
#' `key` enforces the use of sharps or flats. This function is based on
149+
#' `transpose()`.
150+
#' `notes` and `interval` may be vectors, but must be equal length.
151151
#' Recycling occurs only if one argument is scalar.
152152
#'
153153
#' @param notes character, a noteworthy string, single notes only, no chords.
154-
#' Number of timesteps must equal the length of \code{interval}.
154+
#' Number of timesteps must equal the length of `interval`.
155155
#' @param interval integer or character vector; semitones or interval ID,
156156
#' respectively. See details.
157157
#' @param reverse logical, reverse the transposition direction. Useful when
158-
#' \code{interval} is character.
159-
#' @param octaves,accidentals,key See \code{\link{transpose}}.
158+
#' `interval` is character.
159+
#' @param octaves,accidentals,key See [transpose()].
160160
#'
161161
#' @return character
162162
#' @export
163-
#' @seealso \code{\link{mainIntervals}}
163+
#' @seealso [mainIntervals()]
164164
#'
165165
#' @examples
166166
#' dyad("a", 4)
@@ -218,7 +218,7 @@ dyad <- function(notes, interval, reverse = FALSE,
218218
#' @param pitch character, how ranking of chords is determined; lowest pitch,
219219
#' mean pitch, or highest pitch.
220220
#' @param decreasing logical, sort in decreasing order.
221-
#' @param ... additional arguments passed to \code{rank} or \code{order}.
221+
#' @param ... additional arguments passed to `rank()` or `order()`.
222222
#'
223223
#' @return integer for rank and order, character for sort
224224
#' @export
@@ -273,9 +273,8 @@ chord_sort <- function(notes, pitch = c("min", "mean", "max"),
273273
#' simplify them.
274274
#' They operate based only on ordered pitches.
275275
#'
276-
#' For \code{chord_slice}, any entry that is empty after slicing is dropped.
277-
#' An error is thrown is \code{index} is completely out of bounds for all
278-
#' chords.
276+
#' For `chord_slice()`, any entry that is empty after slicing is dropped. An
277+
#' error is thrown is `index` is completely out of bounds for all chords.
279278
#'
280279
#' @param notes character, a noteworthy string.
281280
#' @param index integer, the order of a note in a chord by pitch (not scale
@@ -349,8 +348,8 @@ chord_slice <- function(notes, index){
349348
#' are sorted by pitch.
350349
#'
351350
#' In several cases including single notes or no major or minor third interval
352-
#' present, \code{NA} is returned.
353-
#' \code{TRUE} or \code{FALSE} is only returned if such an interval is present.
351+
#' present, `NA` is returned.
352+
#' `TRUE` or `FALSE` is only returned if such an interval is present.
354353
#' If more than one is present, it is based on the lowest in pitch.
355354
#' It prioritizes major/minor and minor/major adjacent intervals (recognizing a
356355
#' common triad). If these do not occur adjacent, the lowest third is selected.
@@ -413,25 +412,25 @@ chord_is_minor <- function(notes){
413412

414413
#' Chord constructors
415414
#'
416-
#' These functions construct basic chord string notation from root \code{notes}.
415+
#' These functions construct basic chord string notation from root `notes`.
417416
#'
418-
#' Providing a \code{key} signature is used only to ensure flats or sharps for
417+
#' Providing a `key` signature is used only to ensure flats or sharps for
419418
#' accidentals.
420-
#' An additional set of aliases with efficient names, of the
421-
#' form \code{x*} where \code{*} is a chord modifier abbreviation, is provided
422-
#' to complement the set of \code{chord_*} functions.
419+
#' An additional set of aliases with efficient names, of the form `x*` where `*`
420+
#' is a chord modifier abbreviation, is provided to complement the set of
421+
#' `chord_*` functions.
423422
#'
424423
#' These functions create standard chords, not the multi-octave spanning types
425424
#' of chords commonly played on guitar.
426425
#'
427426
#' @param notes character, a noteworthy string of chord root notes.
428427
#' @param key key signature. See details.
429-
#' @param octaves character, passed to \code{transpose}.
428+
#' @param octaves character, passed to `transpose()`.
430429
#'
431430
#' @return character
432431
#' @export
433432
#' @name chords
434-
#' @seealso \code{\link{transpose}}
433+
#' @seealso [transpose()]
435434
#'
436435
#' @examples
437436
#' chord_min("d")
@@ -653,8 +652,6 @@ chord_maj13 <- function(notes, key = "c", octaves = "tick"){
653652
.asnw(x)
654653
}
655654

656-
# lintr will catch function name casing violation # nolint start
657-
658655
#' @export
659656
#' @rdname chords
660657
xm <- chord_min
@@ -770,5 +767,3 @@ xm13 <- chord_min13
770767
#' @export
771768
#' @rdname chords
772769
xM13 <- chord_maj13
773-
774-
# nolint end

0 commit comments

Comments
 (0)