tabr (version 0.3.5)

note_is_natural: Inspect or coerce noteworthy string formats

Description

Helper functions for inspecting and setting formatting attributes of noteworthy strings including representation of timesteps, octaves and accidentals.

Usage

note_is_natural(notes)

note_is_accidental(notes)

note_is_flat(notes)

note_is_sharp(notes)

naturalize(notes, type = c("both", "flat", "sharp"), ignore_octave = FALSE)

sharpen_flat(notes, ignore_octave = FALSE)

flatten_sharp(notes, ignore_octave = FALSE)

note_set_key(notes, key = "c")

as_tick_octaves(notes)

as_integer_octaves(notes)

as_space_time(notes)

as_vector_time(notes)

pretty_notes(notes, ignore_octave = TRUE)

Arguments

notes

character, a noteworthy string, space-delimited or vector of individual entries.

type

character, type of note to naturalize.

ignore_octave

logical, strip any octave notation that may be present, returning only the basic notes without explicit pitch.

key

character, key signature to coerce any accidentals to the appropriate form for the key. May also specify "sharp" or "flat".

Value

character

Details

The note_is_* functions strictly allow individual notes, not chords. The other functions listed here accept any noteworthy string including those containing chords.

For sharpen_flat and flatten_sharp, sharpening flats and flattening sharps refer to inverting their respective notation, not to raising or lowering a flatted or sharped note by one semitone. For the latter, use naturalize, which removes flat and/or sharp notation from a string. note_set_key is used for coercing a noteworthy string to a specific and consistent notation for accidentals based on a key signature. This is a wrapper around sharpen_flat and flatten_sharp. as_tick_octaves, as_integer_octaves, as_space_time and as_vector_time similarly affect octave and timestep format. For simultaneous control over the representation of timesteps, octave numbering and accidentals, all three are available as arguments to as_noteworthy.

Examples

Run this code
# NOT RUN {
x <- "a_2 a a#'"
note_is_natural(x)
note_is_accidental(x)
note_is_flat(x)
note_is_sharp(x)

x <- "e_2 a_, b_, c#f#a# c#'f#'a#''"
note_set_key(x, "f")
note_set_key(x, "g")
as_tick_octaves(x)
as_integer_octaves(x)
y <- as_vector_time(x)
is_vector_time(y)
is_space_time(as_space_time(y))

naturalize(x)
naturalize(x, "sharp")
sharpen_flat(x)
flatten_sharp(x)
pretty_notes(x)
# }

Run the code above in your browser using DataCamp Workspace