Now that you have had an overview of the concept of noteworthy
strings and the noteworthy
class that provides this
structure to objects, next consider the noteinfo
class.
noteinfo
objects are similarly built from character
strings. Note information is supplemental information that is stored in
a noteinfo
object. A note info string is generally a
companion to a noteworthy string. They share many of the same properties
as noteworthy
objects and have similar generic method
implementations.
noteinfo
class
The data stored in a noteinfo
object always includes
duration, but can also consist of various other pieces of sheet music
notation markup syntax; information that is distinct from the pitch
itself, for example slurs or staccato notes. Because all the available
information aside from note duration tends to be specifically relevant
to sheet music transcription, you can find more details in the
transcription vignettes that introduce the phrase
class. It
is worth browsing the table in the phrases
vignette if any note info notation below is unfamiliar.
A string can be checked directly with informable()
.
x <- "2. 4.. 8 t8-. t8- t8^ 16"
informable(x)
#> [1] TRUE
informable("5")
#> [1] FALSE
This reports whether the entire string conforms to all requirements
for it to be valid noteinfo
syntax. In the special case
where only durations are provided and no other information, and these
durations do not include any triplets "t"
or dotted notes
"."
, then an integer vector will suffice. Even so, a digit
like 5
does not belong.
Use as_noteinfo()
to coerce to a noteinfo
object. Here are the print and summary statements.
x <- as_noteinfo(x)
x
#> <Note info string>
#> Format: space-delimited time
#> Values: 2. 4.. 8 t8-. t8- t8^ 16
summary(x)
#> <Note info string>
#> Timesteps: 7
#> Format: space-delimited time
#> Values: 2. 4.. 8 t8-. t8- t8^ 16
Similar to noteworthy
object, here are some generic
methods as applied to the noteinfo
class.
length(x)
#> [1] 7
rev(x)
#> <Note info string>
#> Format: space-delimited time
#> Values: 16 t8^ t8- t8-. 8 4.. 2.
x[2:4]
#> <Note info string>
#> Format: space-delimited time
#> Values: 4.. 8 t8-.
x[2:3] <- c("1(", "2)")
x
#> <Note info string>
#> Format: space-delimited time
#> Values: 2. 1( 2) t8-. t8- t8^ 16
As with the noteworthy
class, there are helper functions
available that make it convenient to extract and manipulate the data in
noteinfo
objects. Here are some examples.
a <- notate("t8x", "Start here")
x <- paste(a, "t8x t8-. 16 4.. 16- 16 2^ 2 4. 8( 4)( 4) 8*4 1 1")
info_duration(x)
#> <Note info string>
#> Format: vectorized time
#> Values: t8 t8 t8 16 4.. 16 16 2 2 4. 8 4 4 8 8 8 8 1 1
info_slur_on(x)
#> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE
#> [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE
#> [13] TRUE FALSE FALSE FALSE FALSE FALSE FALSE
info_slide(x)
#> [1] FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
#> [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
info_dotted(x)
#> [1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
#> [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [1] "Start here" NA NA NA NA
#> [6] NA NA NA NA NA
#> [11] NA NA NA NA NA
#> [16] NA NA NA NA
info_duration()
is a handy function that strips away all
information but note durations. Most of the other functions return
logical vectors indicating timesteps where certain types of information
are present. info_annotation()
extracts text annotations at
timesteps, returning NA
where there is no annotation.
It is unlikely to have reason to use noteinfo
objects in
isolation. They are meant to compliment noteworthy
objects
of the same timestep length. You will see them used in combination to
construct phrases for sheet music transcription, but also to build a
music
object. Music objects are the subject of the next
tutorial.
The key takeaway here is that noteworthy
- and
noteinfo
-class objects are intended to provide clean
separation of sound and time, respectively. It is true that note
information can be more than just duration, including notation markup
that represents things that have an effect on how a note sounds, but the
focus here is specifically on separating pitch from time (and everything
else).
There is much analysis that can be done on a sequence of pitches
alone. The temporal information meant to be included in a
noteworthy
object is at the rank level. There is a temporal
sequence; the object is built around timesteps. But interval/ratio level
data is not part of the definition. When this is needed,
noteinfo
is paired with pitch.