The simplest functions for inspecting noteworthy strings to see if their notes have certain properties.

note_is_accidental(notes)

note_is_natural(notes)

note_is_flat(notes)

note_is_sharp(notes)

note_has_accidental(notes)

note_has_natural(notes)

note_has_flat(notes)

note_has_sharp(notes)

Arguments

notes

character, a noteworthy string.

Value

logical

Details

Note that these functions are the weakest in terms of checking noteworthiness. They are simple regular expression-based wrappers. They are often used internally by more complex functions without wasting computational overhead on performing input validity checks, but they are exported from the package for user convenience. Their results will only make sense on strings that you define in accordance with noteworthy string rules.

The note_is_* functions return a logical vector with length equal to the number of timesteps in notes. The note_has_* functions summarize these to a single logical value.

Examples

x <- "r a_2 a a#' s"
note_has_accidental(x)
#> [1] TRUE
note_has_natural(x)
#> [1] TRUE
note_has_flat(x)
#> [1] TRUE
note_has_sharp(x)
#> [1] TRUE
note_is_accidental(x)
#> [1] FALSE  TRUE FALSE  TRUE FALSE
note_is_natural(x)
#> [1]  TRUE FALSE  TRUE FALSE  TRUE
note_is_flat(x)
#> [1] FALSE  TRUE FALSE FALSE FALSE
note_is_sharp(x)
#> [1] FALSE FALSE FALSE  TRUE FALSE
note_has_tick(x)
#> [1] TRUE
note_has_integer(x)
#> [1] TRUE
note_is_tick(x)
#> [1] FALSE FALSE FALSE  TRUE FALSE
note_is_integer(x)
#> [1] FALSE  TRUE FALSE FALSE FALSE
note_has_rest(x)
#> [1] TRUE
note_is_rest(x)
#> [1]  TRUE FALSE FALSE FALSE  TRUE