Inspect basic metadata for noteworthy strings.

n_steps(x)

n_notes(notes)

n_chords(notes)

n_octaves(notes)

chord_size(notes)

octave_type(notes)

accidental_type(x)

time_format(x)

is_space_time(x)

is_vector_time(x)

note_is_tick(notes)

note_is_integer(notes)

note_has_tick(notes)

note_has_integer(notes)

note_is_rest(notes)

note_has_rest(notes)

Arguments

x

for generic functions: notes, info or music string.

notes

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

Value

varies by function

Details

These functions inspect the basic metadata of noteworthy strings. For functions that perform basic checks on strings, see note-checks().

The n_* functions give summary totals of the number of timesteps, number of individual note (non-chord) timesteps, number of chord time steps, and the number of distinct octaves present across timesteps.

Functions pertaining to type or format of a noteworthy string provide information on how a particular string is defined, e.g. time_format. Note that the result pertains to true noteworthy-class objects. If inspecting a standard character string, the result pertains to post-conversion to the noteworthy class and does not necessarily reflect what is found in notes verbatim. See examples.

A note on generic functions

n_steps() and the three time format functions are generic since they apply clearly to and are useful for not only noteworthy strings, but also note info, music, and lyrics objects. If x is still a simple character string, these functions attempt to guess if it is noteworthy, note info, or music. Lyrics content is arbitrary so is never considered for a simple character string. Best practice is to set the class before using these functions anyway.

There are many package functions that operate on noteworthy strings that could in concept also work on music objects, but the expectation is that sound and time/info are disentangled for analysis. The music class is convenient and relatively efficient data entry, e.g., for transcription purposes, but it is not sensible to perform data analysis with quantities like pitch and time tightly bound together in a single string. This would only lead to repetitive deconstructions and reconstructions of music class objects.

The music class is intended to be a transient class such as during data import, data entry, or data export. Most functions that operate on noteworthy strings or note info strings strictly apply to one or the other. Generic functions are reserved for only the most fundamental and generally applicable metadata retrieval and format coercion.

Examples

x <- "e_2 a_, c#f#a#"
n_steps(x)
#> [1] 3
n_notes(x)
#> [1] 2
n_chords(x)
#> [1] 1
n_octaves(x)
#> [1] 2
chord_size(x)
#> [1] 1 1 3

# Type is mixed in `x` but is inferred under default conversion rules.
# These check `x` once validated and coerced to 'noteworthy' class.
octave_type(x)
#> [1] "tick"
accidental_type(x)
#> [1] "flat"
# The default is tick octaves and flats
as_noteworthy(x)
#> <Noteworthy string>
#>   Format: space-delimited time
#>   Values: e_, a_, <d_g_b_>

time_format(x)
#> [1] "space-delimited time"
is_space_time(x)
#> [1] TRUE
is_vector_time(x)
#> [1] FALSE