duration: Numeric (double) representation of durations

durationR Documentation

Numeric (double) representation of durations

Description

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

## Default S3 method:
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)

## Default S3 method:
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), or NULL.

Must be parsable as rhythm infromation.

...

Arguments passed to the rhythm parser.

There are also two hidden (advanced) arguments you can specify: memoize and deparse (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, or NA.

See "Grace notes" section below.

See Also

To better understand how this function works, read about the family of rhythm functions, or how rhythms are parsed and deparsed.

Other rhythm functions: grid(), notehead(), recip()

Examples


tokens <- c('4.GG', '8G', '16E', '16F#', '16G', '16D', 'q8D#', '4E')

duration(tokens)
quarters(tokens, parse(grace = NA))
quarters(tokens, inPlace = TRUE)

## Not run: 
B075 <- readHumdrum(humdrumRroot, "HumdrumData/BeethovenVariations/B075_00_05_a.krn")

with(B075, subset = Spine > 2, duration(Token)) 
with(B075, subset = Spine > 2, quarters(Token)) 

## End(Not run)


Computational-Cognitive-Musicology-Lab/humdrumR documentation built on Oct. 22, 2024, 9:28 a.m.