Skip to contents

This function attempts to take in a sign vector (and associated cardinality and ineqmat) and create a scale whose sign vector matches the input. This is not always possible because not all sign vectors correspond to colors that actually exist (just like there is no Fortean set class with the interval-class vector <1 1 0 1 0 0>). The function will do its best but may eventually time out, using a similar process as quantize_color(). You can increase the search time by increasing nmax, but in some cases you could search forever and still find nothing. I don't advise trying to use this function on many sign vectors at the same time.

Usage

set_from_signvector(
  signvec,
  card,
  nmax = 12,
  reconvert = FALSE,
  ineqmat = NULL,
  edo = 12,
  rounder = 10
)

Arguments

signvec

Vector of 0, -1, and 1s: the sign vector that you want to realize.

card

Integer: the number of notes in your desired scale.

nmax

Integer, essentially a limit to how far the function should search before giving up. Although every real color should have a rational representation in some mod k universe, for some colors that k must be very high. Increasing nmax makes the function run longer but might be necessary if small chromatic universes don't produce a result. Defaults to 12.

reconvert

Boolean. Should the scale be converted to 12edo? Defaults to FALSE.

ineqmat

Specifies which hyperplane arrangement to consider. By default (or by explicitly entering "mct") it supplies the standard "Modal Color Theory" arrangements of getineqmat(), but can be set to "white," "roth", "pastel," or "rosy", giving the ineqmats of make_white_ineqmat(), make_roth_ineqmat(), make_pastel_ineqmat(), and make_rosy_ineqmat(). For other arrangements, the desired inequality matrix can be entered directly.

edo

Number of unit steps in an octave. Defaults to 12.

rounder

Numeric (expected integer), defaults to 10: number of decimal places to round to when testing for equality.

Value

If reconvert=FALSE, a list of two elements: element 1 is set with a vector of integers representing the realized scale; element 2 is edo representing the number k of unit steps in the mod k universe. If reconvert=TRUE, returns a single numeric vector converted to measurement relative to 12-tone equal tempered semitones. May also return a vector of NAs of length card if no suitable scale was found beneath the limit given by nmax.

Examples

# This first command produces a real tetrachord:
set_from_signvector(c(-1, 1, 1, -1, -1, -1, 0, -1), 4)
#> $set
#> [1] 0 2 5 6
#> 
#> $edo
#> [1] 10
#> 

# But this one, which changes only the last entry of the previous sign vector
# has no solution so will return four `NA` values.
set_from_signvector(c(-1, 1, 1, -1, -1, -1, 0, 1), 4)
#> [1] NA NA NA NA