ioi | R Documentation |
These functions are used to sum (melodically) adjacent rhythmic duration values which are not associated with new onsets/attacks.
ioi()
adds the duration of rests to the previous
non-rest (onset) duration, to create interonset intervals (IOIs).
sumTies()
sums tied durations.
If ioi()
is applied to a humdrumR data class
you may use the data's fields as arguments.
If no field names are specified, the first selectedField is used as x
.
If sumTies()
is applied to a humdrumR data class
you may use the data's fields as arguments.
If no field names are specified, the first selectedField is used as x
.
## Default S3 method:
ioi(
x,
onsets = !grepl("r", x) & !is.na(x) & x != ".",
...,
finalOnset = FALSE,
groupby = list(),
parseArgs = list(),
Exclusive = NULL,
inPlace = TRUE
)
humData |> select(Token) |> ioi()
humData |> ioi(Token)
ioi(
x,
onsets = !grepl("r", x) & !is.na(x) & x != ".",
...,
finalOnset = FALSE,
groupby = list(),
parseArgs = list(),
Exclusive = NULL,
inPlace = TRUE
)
## Default S3 method:
sumTies(x, open = "[", close = "]", ..., groupby = list(), inPlace = TRUE)
humData |> select(Token) |> sumTies()
humData |> sumTies(Token)
sumTies(x, open = "[", close = "]", ..., groupby = list(), inPlace = TRUE)
x |
Input rhythm information. The Must be parsable as rhythm information. |
onsets |
A Defaults to a Must be All durations in |
finalOnset |
Whether to count the last onset. Defaults to Must be a singleton If |
groupby |
A Defaults to Must be a |
parseArgs |
An optional list of arguments passed to the rhythm parser. Defaults to an empty Must be a |
inPlace |
Should non-rhythm information be retained in the output string? Defaults to Must be a singleton |
open |
How are the beginnings of ties indicated in Defaults to Must be a single |
close |
How are the ends of ties indicated in Defaults to Must be a single |
Both functions return "collapsed" durations are as null data tokens.
For example, sumTies(c('[4a', '4a]', '2g'))
returns c('2a', '.', '2g')
, with the second (tied) duration null ("."
).
For interonset intervals, the last duration in a string of durations is undefined—there is a final onset, but no next onset, so there
can't really be a "interonset" interval.
Thus, by default, ioi()
will return NA
at the location of the final duration.
However, if the finalOnset
argument is set to TRUE
, the function will act like there is one additional onset after the end of the sequence:
the last "IOI" is calculated between the last onset and this fictional "final onset."
For example, if we run ioi(c('4.a','8r', '4.a','8r','2a', '2r'))
the result is c("2a", ".", "2a", ".", NA, ".")
,
with the last onset (2a
) returning NA
.
However, if we run ioi(c('4.a','8r', '4.a','8r','2a', '2r'), finalOnset = TRUE)
the result is c("2a", ".", "2a", ".", "1a", ".")
—the
last onset's whole duration through the end is returned!
Non-onsets (rests) that occur before the first onset are returned as null.
tokens_withrests <- c('2c', '4d', '4e', '4r', '8f','8d#', '4r', '4e')
ioi(tokens_withrests)
ioi(tokens_withrests, finalOnset = TRUE)
tokens_withties <- c('2c', '4d', '[4e', '4e]', '8f','[8d#', '4d#]', '4e')
sumTies(tokens_withties)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.