| time | R Documentation |
These functions convert duration values to clock-time representations.
seconds() and ms() output numeric values.
dur() outputs a character string encoding the humdrum **dur
representation of time.
If seconds() 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 ms() 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 dur() 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:
seconds(
x,
...,
BPM = "*M60",
parseArgs = list(),
scale = 1,
unit = 1,
inPlace = FALSE
)
humData |> select(Token) |> seconds()
humData |> seconds(Token)
seconds(
x,
...,
BPM = "*M60",
parseArgs = list(),
scale = 1,
unit = 1,
inPlace = FALSE
)
## Default S3 method:
ms(
x,
...,
BPM = "*M60",
parseArgs = list(),
scale = 1,
unit = 1,
inPlace = FALSE
)
humData |> select(Token) |> ms()
humData |> ms(Token)
ms(
x,
...,
BPM = "*M60",
parseArgs = list(),
scale = 1,
unit = 1,
inPlace = FALSE
)
## Default S3 method:
dur(
x,
...,
BPM = "*M60",
minutes = FALSE,
hours = FALSE,
days = FALSE,
months = FALSE,
years = FALSE,
parseArgs = list(),
scale = 1,
unit = 1,
inPlace = FALSE
)
humData |> select(Token) |> dur()
humData |> dur(Token)
dur(
x,
...,
BPM = "*M60",
minutes = FALSE,
hours = FALSE,
days = FALSE,
months = FALSE,
years = FALSE,
parseArgs = list(),
scale = 1,
unit = 1,
inPlace = FALSE
)
x |
An input vector. The Must be parsable as rhythm infromation. |
... |
Arguments passed to the rhythm parser. There are also two hidden (advanced) arguments you can specify: |
scale |
A Defaults to Must be |
inPlace |
Should non-rhythm information be retained in the output string? Defaults to Must be a singleton Defaults to A singleton See "Grace notes" section below. |
minutes |
( |
hours |
( |
days |
( |
months |
( |
years |
( |
These functions require a BPM (beats-per-minute) argument to be specified.
By default, the value is 60 bpm.
The **dur output can be modified to include different clock-time units:
The minutes, hours, days, months, and years arguments are all true/false logical arguments, indicating whether
to use that unit in the output (all default to FALSE).
For example, if minutes = FALSE, an input of 90 seconds will return ":90" (90 seconds!), but if
minutes = TRUE, the output will be :1:30 (one minute and thirty seconds).
To better understand how this function works, read about the family of rhythm functions, or how rhythms are parsed and deparsed.
Other time functions:
bpm2sec()
tokens <- c('4.GG', '8G', '16E', '16F#', '16G', '16D', 'q8D#', '4E')
seconds(tokens)
seconds(tokens, BPM = '90')
ms(tokens, BPM = '90')
dur(tokens)
wholenotes <- c(10, 30, 90, 310, 5000)
dur(wholenotes)
dur(wholenotes, minutes = TRUE)
dur(wholenotes, minutes = TRUE, hours = TRUE)
quarternotes <- c(10, 30, 90, 310, 5000)
dur(quarternotes, minutes = TRUE, BPM = '120', parse(unit = '4'))
## Not run:
B075 <- readHumdrum(humdrumRroot, "HumdrumData/BeethovenVariations/B075_00_05_a.krn")
with(B075[[,3:4]], seconds(Token))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.