The standard approach to representing conventional note values in humdrum
is the "reciprocal" **recip.
Representation.
The **recip
rhythmic values are often used as a part of **kern
representation,
which also includes pitch information and notation details.
If recip()
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
recip(
x,
...,
sep = "%",
parseArgs = list(),
scale = 1,
unit = 1,
inPlace = FALSE
)
## humdrumR S3 method:
humData |> select(Token) |> recip()
humData |> recip(simple = TRUE)
humData |> recip(Token, Key = Key)
recip(
x,
...,
sep = "%",
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).- sep
The separator printed between numerator and denominator.
A single
character
string.Must be a single
character
string.- 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.
Details
**recip
values are literally the reciprocal of a duration value.
Since most note values in conventional music notation are simple fractions
the reciprocal approach is highly concise and very similar to conventional western notation and terminology.
A "quarter note" is represented as the reciprocal of 1/4: simply "4"
.
Full reciprocal fractions can be specified: "2%3"
to indicate 3/2.
The %
separator can be changed using the sep
argument.
As in conventional note values, "dots" can be added after a value to increase the duration by
the ratio of (2 - (2^{-n}))
, where n
is the number of dots.
(One dot is 3/2; two dots is 7/4; etc.).
Examples
tokens <- c('4.GG', '8G', '16E', '16F#', '16G', '16D', 'q8D#', '4E')
recip(tokens)
#> **recip (character)
#> [1] 4. 8 16 16 16 16 1%0 4
recip(tokens, parse(grace = NA))
#> **recip (character)
#> [1] 4. 8 16 16 16 16 . 4
recip(tokens, scale = 2)
#> **recip (character)
#> [1] 2. 4 8 8 8 8 1%0 2
recip(c(.25, .25, .25, .25, .5, 1))
#> **recip (character)
#> [1] 4 4 4 4 2 1
recip(c(.25, .25, .25, .25, .5, 1), parse(unit = '4'))
#> **recip (character)
#> [1] 16 16 16 16 8 4
if (FALSE) {
B075 <- readHumdrum(humdrumRroot, "HumdrumData/BeethovenVariations/B075_00_05_a.krn")
within(B075, subset = Spine > 2, recip(Token))
with(B075, subset = Spine > 2, recip(Token)) |> table()
}