set_to_distribution {musicMCT} | R Documentation |
Convert between pitch-class sets and distributions
Description
For applications of the Discrete Fourier Transform to pitch-class set theory, it's typically convenient to represent musical sets in terms of distributions rather than lists of their elements. (See Chapter 1 of Amiot 2016, doi:10.1007/978-3-319-45581-5.) These functions convert back and forth between those representations. s2d() and d2s() are shorthands for set_to_distribution() and distribution_to_set(), respectively.
Usage
set_to_distribution(set, edo = 12, rounder = 10)
distribution_to_set(
distro,
multiset = TRUE,
reconvert = TRUE,
edo = 12,
rounder = 10
)
s2d(...)
d2s(...)
Arguments
set |
Numeric vector of pitch-classes in the set. May be a multiset, in which case the result is different from the corresponding set with repetitions removed. Entries must be integers. |
edo |
Number of unit steps in an octave. Defaults to |
rounder |
Numeric (expected integer), defaults to |
distro |
Numeric vector representing a pitch-class distribution. |
multiset |
Boolean. Should distribution_to_set() return a multiset if
element weights are greater than 1? Defaults to |
reconvert |
Boolean. Should the scale be converted to the input edo?
Defaults to |
... |
Arguments to be passed from s2d() or d2s() to unabbreviated functions. |
Value
set_to_distribution() returns a numeric vector with length
edo
, whose i
th entry represents the weight assigned to pitch-class
i
in the distribution. distribution_to_set() returns a (multi)set
represented by listing its elements in a vector. (Non-integer weights are rounded
up to the next highest integer if multiset
is TRUE
.)
Examples
set_to_distribution(c(0, 4, 7))
s2d(c(0, 4, 7)) # Same result but quicker to type
s2d(c(0, 4, 4, 7)) # The doubled third is reflected by the value 2 in the result
minor_triad_distro <- c(2, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0)
distribution_to_set(minor_triad_distro)
d2s(minor_triad_distro, multiset=FALSE)
# distribution_to_set automatically converts to 12edo, which
# can sometimes be undesirable, as in this case:
tresillo_distro <- c(1, 0, 0, 1, 0, 0, 1, 0)
d2s(tresillo_distro)
d2s(tresillo_distro, reconvert=FALSE)