grid | R Documentation |
These functions read and write a sequencer-like representation of rhythm.
Rhythms are represented as either strings or vectors of "on"/"off" values,
which indicate where rhythmic onsets occur in a regular time grid.
For example, "X00X00X0"
or c(1, 0, 0, 1, 0, 0, 1, 0)
.
If grid()
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:
grid(x, ..., parseArgs = list(), scale = 1, unit = 1, inPlace = FALSE)
humData |> select(Token) |> grid()
humData |> grid(Token)
grid(x, ..., parseArgs = list(), scale = 1, unit = 1, inPlace = FALSE)
togrid(
x,
tick = tatum(x),
measure = "1",
on = "X",
off = "O",
collapse = TRUE,
sep = ""
)
fromgrid(x, tick, meter)
## S3 method for class 'matrix'
fromgrid(x, tick = "16")
## S3 method for class 'character'
fromgrid(x, tick = "16", on = "X", off = "O", sep = "", deparser = recip, ...)
## S3 method for class 'logical'
fromgrid(x, tick = "16", deparser = rint2recip, ...)
## S3 method for class 'numeric'
fromgrid(x, tick = "16", deparser = recip, ...)
## S3 method for class 'integer'
fromgrid(x, tick = "16", deparser = recip, ...)
x |
An input vector. The Must be parsable as rhythm infromation. |
... |
Argments passed to the deparser. |
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. |
tick |
What is the unit of the grid? Defaults to sixteenth-note ( Must be parsed as a rhythm by |
on , off |
What represents onsets (attacks) and rests in the grid? Default to Must be singleton atomic values. |
collapse |
Should the output be collapsed to a single string per measure? Defaults to Must be singleton |
sep |
Separator between ticks in collapsed output. Defaults to an empty string (no separator). Must be a singleton |
deparser |
What output representation should be returned? Defaults to Must be a function which accepts |
The grid()
function, is a fully vectorized rhythm function, which translates
individual durations to a grid-representation strings.
For example, on a 16th-note grid, a dotted eighth-note would be represented "XOO"
.
The fromgrid()
and togrid()
functions create/read fuller
grid representations, representing whole rhythms at once: in their case,
the length of input and output will not be the same.
To better understand how grid()
works,
read about the family of rhythm functions,
or how rhythms are parsed and deparsed.
Other rhythm functions:
duration()
,
notehead()
,
recip()
rhythm <- c('8.', '8.', '8', '8.', '8', '16', '8')
grid(rhythm)
togrid(rhythm, on = '1', off = '0')
togrid(rhythm, collapse = FALSE)
fromgrid('XOXOXOOXXOXOXXOO', tick = '8')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.