metlev | R Documentation |
These functions take vectors of rhythmic duration values and
compute the metric position of each rhythmic onset.
metlev()
identifies the metric level of each onset;
metcount()
counts beats within a measure;
metsubpos()
measures the distance
between an onset and the nearest metric beat.
metcount()
and metsubpos()
parallel the more general timecount()
and subpos()
functions.
## Default S3 method:
metlev(
dur,
meter = duple(5),
pickup = NULL,
value = TRUE,
offBeats = TRUE,
remainderSubdivides = FALSE,
deparser = recip,
groupby = list(),
...,
parseArgs = list()
)
metlev(
dur,
meter = duple(5),
pickup = NULL,
value = TRUE,
offBeats = TRUE,
remainderSubdivides = FALSE,
deparser = recip,
groupby = list(),
...,
parseArgs = list()
)
## Default S3 method:
metcount(
dur,
meter = duple(5),
level = tactus(meter),
pickup = NULL,
...,
offBeats = TRUE,
withinNext = FALSE,
remainderSubdivides = FALSE,
groupby = list(),
parseArgs = list(),
Exclusive = NULL
)
metcount(
dur,
meter = duple(5),
level = tactus(meter),
pickup = NULL,
...,
offBeats = TRUE,
withinNext = FALSE,
remainderSubdivides = FALSE,
groupby = list(),
parseArgs = list(),
Exclusive = NULL
)
## Default S3 method:
metsubpos(
dur,
meter = duple(5),
pickup = NULL,
deparser = duration,
...,
remainderSubdivides = TRUE,
groupby = list(),
parseArgs = list()
)
metsubpos(
dur,
meter = duple(5),
pickup = NULL,
deparser = duration,
...,
remainderSubdivides = TRUE,
groupby = list(),
parseArgs = list()
)
dur |
An input vector of rhythmic durations. Must be a Is parsed using |
meter |
The meter(s) to compute levels from. Defaults to a standard, five-level duple (4/4) meter. Must be a For |
pickup |
Where is there a pickup (anacrusis)? Defaults to Must be |
value |
Should the output levels be represented as rhythmic duration values? Defaults to Must be a singleton |
offBeats |
Should off-beat onsets be numbered in the output, or Defaults to Must be a single |
remainderSubdivides |
Should off-beat onsets only be associated with beat levels that they evenly subdivide? Defaults to A singleton |
groupby |
A Defaults to Must be a To function as a by-record timeline, the |
parseArgs |
An optional list of arguments passed to the rhythm parser. Defaults to an empty Must be a |
level |
Which metric level should be counted? Defaults to the tactus of the A single A |
withinNext |
Should beats be counted within the next highest beat of the meter? Defaults to Must be a singleton |
Watch out! These met...()
functions require meter information and their output is
highly dependent on how you interpret meter from scores.
For a full discussion of how meter can represented, parsed, and created in humdrumR
,
see the meter()
manual.
Effective use of the meter()
function is essential to use of metlev()
, metcount()
, and metsubpos()
.
metlev()
identifies the "highest" (longest) metric level that each onset lands in/on:
For example, in 4/4 time:
An onset on the downbeat is at the highest level of all, the whole-note level;
An onset on beat three of the 4/4 measure is on the half-note level;
Onsets on the backbeats (beats two and two) fall on the quarter-note level;
The next level down is the eighth-note level, in between each quarter-note beat;
etc.
The metlev()
output expresses beat levels as the duration of
the the level, in recip()
format by default.
So the whole-note level is "1"
and the quarter-note level (backbeats) is "4"
.
You can specify a different deparsing function
(like duration()
) using the deparser
argument.
(If deparser
is NULL
, rational()
numbers are returned.)
Another option is to express the metric levels simply as natural numbers, which you can achieve
with the argument value = FALSE
.
In this case, the top level of the meter is 1
, which each next lower-level incrementing up:
i.e., the quarter-note level (of 4/4) would be 3
, while the sixteenth-note level would be 5
.
1 | & | 2 | & | 3 | & | 4 | & | |
Level (recip() ) | "1" | "8" | "4" | "8" | "2" | "8" | "4" | "8" |
Level (value = FALSE ) | 1 | 4 | 3 | 4 | 2 | 4 | 3 | 4 |
1 | & | 2 | & | 3 | & | |
Level (recip() ) | "1" | "8" | "4" | "8" | "4" | "8" |
Level (value = FALSE ) | 1 | 3 | 2 | 3 | 2 | 3 |
1 | & | a | 2 | & | a | |
Level (recip() ) | "1" | "8" | "8" | "4." | "8" | "8" |
Level (value = FALSE ) | 1 | 3 | 3 | 2 | 3 | 3 |
The metcount()
function counts one beat level in a metric hierarchy within the span of highest ('measure') level (by default).
Which level you want to count is controlled by the level
argument, which can be either a character
string
in recip()
format or a natural number (1
is top level, 2
is next lowest level, etc.).
If you tell metcount()
to count the highest (measure) level in the meter, it will count bars.
An additional option is to count beats within the next highest beat (which is not necessarily the full bar).
For example, if we count eighth-notes in a 6/8 meter, the default behavior is to count 1, 2, 3, 4, 5, 6.
However, if we specify withinNext = TRUE
, the eighth-notes will be counted within the next highest
6/8 beat level, which is the dotted-quarter note. So the eighth notes in a bar would be counted 1, 2, 3, 1, 2, 3.
The exact counting behavior can then be further controlled by changing exactly how the specifying meter()
is specified.
If withinNext = FALSE
:
1 | & | 2 | & | 3 | & | 4 | & | |
"1" (whole) | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
"2" (half) | 1 | 1 | 1 | 1 | 2 | 2 | 2 | 2 |
"4" (quarter) | 1 | 1 | 2 | 2 | 3 | 3 | 4 | 4 |
"8" (eighth) | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
If withinNext = TRUE
:
1 | & | 2 | & | 3 | & | 4 | & | |
"1" (whole) | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
"2" (half) | 1 | 1 | 1 | 1 | 2 | 2 | 2 | 2 |
"4" (quarter) | 1 | 1 | 2 | 2 | 1 | 1 | 2 | 2 |
"8" (eighth) | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 |
If withinNext = FALSE
:
1 | & | 2 | & | 3 | & | |
"2." (dotted-half) | 1 | 1 | 1 | 1 | 1 | 1 |
"4" (quarter) | 1 | 1 | 2 | 2 | 3 | 3 |
"8" (eighth) | 1 | 2 | 3 | 4 | 5 | 6 |
If withinNext = TRUE
:
1 | & | 2 | & | 3 | & | |
"2." (dotted-half) | 1 | 1 | 1 | 1 | 1 | 1 |
"4" (quarter) | 1 | 1 | 2 | 2 | 3 | 3 |
"8" (eighth) | 1 | 2 | 1 | 2 | 1 | 2 |
If withinNext = FALSE
:
1 | & | a | 2 | & | a | |
"2." (dotted-half) | 1 | 1 | 1 | 1 | 1 | 1 |
"4." (dotted-quarter) | 1 | 1 | 1 | 2 | 2 | 2 |
"8" (eighth) | 1 | 2 | 3 | 4 | 5 | 6 |
If withinNext = TRUE
:
1 | & | a | 2 | & | a | |
"2." (dotted-half) | 1 | 1 | 1 | 1 | 1 | 1 |
"4." (dotted-quarter) | 1 | 1 | 1 | 2 | 2 | 2 |
"8" (eighth) | 1 | 2 | 3 | 1 | 2 | 3 |
1 | & | 2 | & | 3 | & | 4 | & | |
"1" (whole) | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
"4" (quarter) | 1 | 1 | 2 | 2 | 3 | 3 | 4 | 4 |
"8" (eighth) | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 |
You can do this with meter('M4/4', fill.levels = 'below')
.
In some cases, onsets may occur which do not land on any beat specified in the meter.
This could be very fast beat levels (e.g., 32nd notes), triplets, or other tuplets.
In these cases, you might consider adding these levels to the meter()
; for example,
if you want to have a 32nd-note level in 4/4, you could use meter('M4/4', tick = '32')
.
For metlev()
and metcount()
, the offBeats
argument can be set to FALSE
to cause
offbeat onsets to return NA
.
Another option is to use metsubpos()
, which measures how far an onset is from the nearest
associated beat in the meter.
By default, off-beat onsets are always associated with the closets previous position in any level in the meter.
If the remainderSubdivides
argument is TRUE
, off-beat onsets are associated with the previous metric level
which the subposition makes an even subdivision of.
Another option is to pass the pickup
argument a logical vector of the same length as the input x
.
Within each piece/group, any block of TRUE
values at the beginning of the pickup
vector
indicate a pickup.
The first index where the pickup
logical is FALSE
is used as the starting point of the timeline/timecount;
All the earlier (pickup == TRUE
) points will be negative numbers, measured backwards from the start index.
In humdrumR
, and datapoints before the first barline record (=
) are labeled Bar == 0
in the Bar
field.
Thus, a common use for the pickup
argument is within(humData, timeline(Token, pickup = Bar < 1)
, which makes the downbeat of
the first complete bar 1
the starting point of the timeline—any notes in pickup bars are negative on the timeline.
The timecount()
and subpos()
functions are more basic versions of metcount()
and metsubpos()
,
based only on counting a single beat level, rather then a hierarchy of beat levels.
rhythm <- c('4', '8', '8', '4', '8', '16', '16','4.', '8','2')
metlev(rhythm)
metlev(rhythm, meter = 'M6/8')
metcount(rhythm)
metcount(rhythm, offBeats = FALSE)
metcount(rhythm, meter = 'M6/8', offBeats = FALSE)
# chorales
chorales <- readHumdrum(humdrumRroot, 'HumdrumData/BachChorales/.*krn')
within(chorales, metlev(Token, pickup = Bar < 1))
within(chorales, metcount(Token, pickup = Bar < 1, fill.levels = 'below'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.