Output is numeric
(real number).
If duration()
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 quarters()
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
.
Usage
# S3 method for default
duration(x, ..., parseArgs = list(), scale = 1, unit = 1, inPlace = FALSE)
humData |> select(Token) |> duration()
humData |> duration(Token)
humData |> duration(simple = TRUE)
duration(x, ..., parseArgs = list(), scale = 1, unit = 1, inPlace = FALSE)
# S3 method for default
quarters(x, ..., parseArgs = list(), scale = 1, unit = 1, inPlace = FALSE)
humData |> select(Token) |> quarters()
humData |> quarters(Token)
humData |> quarters(simple = TRUE)
quarters(x, ..., parseArgs = list(), scale = 1, unit = 1, inPlace = FALSE)
Arguments
- x
An input vector.
The
x
argument can be any (atomic) vector, or a rational (rhythmInterval), orNULL
.Must be parsable as rhythm infromation.
- ...
Arguments passed to the rhythm parser.
There are also two hidden (advanced) arguments you can specify:
memoize
anddeparse
(see the details below).- scale
A
numeric
or rational value which is used as the output unit of measurement.Defaults to
rational(1, 1)
.Must be
numeric
or rational.- inPlace
Should non-rhythm information be retained in the output string?
Defaults to
FALSE
.Must be a singleton
logical
value: an on/off switch.Defaults to
FALSE
.A singleton
logical
value, orNA
.See "Grace notes" section below.
Examples
tokens <- c('4.GG', '8G', '16E', '16F#', '16G', '16D', 'q8D#', '4E')
duration(tokens)
#> **duration (numeric)
#> [1] 0.3750 0.1250 0.0625 0.0625 0.0625 0.0625 0.0000 0.2500
quarters(tokens, parse(grace = NA))
#> **quarters (numeric)
#> [1] 1.50 0.50 0.25 0.25 0.25 0.25 . 1.00
quarters(tokens, inPlace = TRUE)
#> [1] "1.5GG" "0.5G" "0.25E" "0.25F#" "0.25G" "0.25D" "0D#" "1E"
if (FALSE) {
B075 <- readHumdrum(humdrumRroot, "HumdrumData/BeethovenVariations/B075_00_05_a.krn")
with(B075, subset = Spine > 2, duration(Token))
with(B075, subset = Spine > 2, quarters(Token))
}