tabr (version 0.3.5)

valid-notes: Check note and chord validity

Description

Check whether a string is comprised exclusively of valid note and/or chord substring syntax. is_note and is_chord are vectorized and their positive results are mutually exclusive. noteworthy is also vectorized and performs both checks, but it returns a scalar logical result indicating whether the entire set contains exclusively valid entries.

Usage

is_note(x)

is_chord(x)

noteworthy(x)

is_diatonic(x, key = "c")

as_noteworthy(x, format = NULL, octaves = NULL, accidentals = NULL)

Arguments

x

character, space-delimited entries or a vector of single, non-delimited entries.

key

character, key signature.

format

NULL or character ("space" or "vector"), the timestep delimiter format.

octaves

NULL or character ("tick" or "integer"), the octave representation.

accidentals

NULL or character ("flat" or "sharp"), the accidentals representation.

Value

logical

Details

as_noteworthy can be used to coerce to the noteworthy class. Coercion will fail if the string is not noteworthy. Using the noteworthy class is generally not needed by the user during an interactive session, but is available and offers its own print and summary methods for noteworthy strings. It is more likely to be used by other functions and functions that output a noteworthy string generally attach the noteworthy class.

is_diatonic performs a vectorized logical check on a noteworthy string for all notes and chords. To check strictly notes or chords, see note_in_scale and chord_is_diatonic.

See Also

note_in_scale, chord_is_diatonic

Examples

Run this code
# NOT RUN {
x <- "a# b_ c, d'' e3 g_4 A m c2e_2g2 cegh"
data.frame(
  x = strsplit(x, " ")[[1]],
  note = is_note(x),
  chord = is_chord(x),
  either = noteworthy(x))

is_diatonic("ace ac#e d e_", "c")

x <- "a# b_ c,~ c, d'' e3 g_4 c2e_2g2"
x <- as_noteworthy(x)
x

summary(x)

x <- as_noteworthy(x, format = "vector", octaves = "integer",
                   accidentals = "flat")
x

summary(x)
# }

Run the code above in your browser using DataLab