Learn R Programming

musicMCT

The “MCT” in musicMCT stands for Modal Color Theory, a theory of musical scale structure developed by Paul Sherrill, “Modal Color Theory,” Journal of Music Theory 69/1 (2025): 1-49. The goal of this package is to give musicians and music scholars computational tools that make it easier to work with this theory. In a nutshell, Modal Color Theory models musical scales as points in a geometry. The locations of those points relative to various hyperplane arrangements tell us a lot about the scales’ internal structures and mutual relationships. The shape of those hyperplane arrangements gets pretty complex: for the important case of seven-note scales, the main arrangement has 42 hyperplanes in a 6-dimensional space. Computational tools are therefore very helpful.

If you’ve ever wondered why a piece of music uses one scale rather than another; if you want to know more about the jazz chord-scale concept of lydian being “bright” and locrian being “dark”; if you’ve ever wanted to design your own microtonal scale from scratch; if you’re a theorist who wants a geometrical perspective on concepts like voice leading and maximal evenness; if you’re an ethnomusicologist looking to interpret tuning data: musicMCT might be useful to you.

Installation

You can install the latest released version of musicMCT from CRAN with:

install.packages("musicMCT")

Alternatively, you can install the development version of musicMCT from GitHub with:

install.packages("remotes")
remotes::install_github("satbq/musicMCT")

In addition to the package itself, you will probably want to use the following large files which contain data about the MCT geometries:

  • representative_scales.rds (~80 MB) contains a list of all scalar colors for scales of 2-7 notes, with one concrete scale to represent each color
  • representative_signvectors.rds (~10 MB) contains a list of their corresponding sign vectors
  • color_adjacencies.rds (~130 MB) contains information about the adjacency relationships between all these colors (in the form of an adjacency list)

Download these files, save them to your working directory, and load them with:

representative_scales <- readRDS("representative_scales.rds")
representative_signvectors <- readRDS("representative_signvectords.rds")
color_adjacencies <- readRDS("color_adjacencies.rds")

Example

For a detailed introduction to using this package, please see the introductory vignette.

As a very quick example, let’s define the most common “just intonation” version of the major scale and run a few tests on it:

library(musicMCT)
just_dia_frequency_ratios <- c(1, 9/8, 5/4, 4/3, 3/2, 5/3, 15/8)
just_dia <- 12 * log2(just_dia_frequency_ratios)

# This definition of the just diatonic explicitly derives it from the 
# frequency ratios, which I've done to model that process for you. However,
# musicMCT also has a convenience function that will give us the 
# same result much faster: try out j(dia) or j(1,2,3,4,5,6,7) for yourself.

# The modes of the scale are displayed as the columns in this matrix:
sim(just_dia)
#>           [,1]     [,2]      [,3]      [,4]     [,5]      [,6]     [,7]
#> [1,]  0.000000 0.000000  0.000000  0.000000 0.000000  0.000000 0.000000
#> [2,]  2.039100 1.824037  1.117313  2.039100 1.824037  2.039100 1.117313
#> [3,]  3.863137 2.941350  3.156413  3.863137 3.863137  3.156413 3.156413
#> [4,]  4.980450 4.980450  4.980450  5.902237 4.980450  5.195513 4.980450
#> [5,]  7.019550 6.804487  7.019550  7.019550 7.019550  7.019550 6.097763
#> [6,]  8.843587 8.843587  8.136863  9.058650 8.843587  8.136863 8.136863
#> [7,] 10.882687 9.960900 10.175963 10.882687 9.960900 10.175963 9.960900

# A few pieces of evidence that the scale is "pairwise well-formed":
asword(just_dia)
#> [1] 3 2 1 3 2 3 1
howfree(just_dia)
#> [1] 2
isgwf(just_dia)
#> [1] TRUE

# A 15 equal-tempered approximation of just-dia which preserves its "color":
quantized_just_dia <- quantize_color(just_dia)
print(quantized_just_dia)
#> $set
#> [1]  0  3  5  6  9 11 14
#> 
#> $edo
#> [1] 15

# Finally, let's see a rough brightness graph for the scale. (R can assemble the
# necessary information, but musicMCT doesn't yet make the graphs pretty.)
brightnessgraph(quantized_just_dia$set, edo=quantized_just_dia$edo)

Acknowledgments

Thanks to Nate Mitchell for designing the package’s hex sticker logo.

Copy Link

Version

Install

install.packages('musicMCT')

Monthly Downloads

147

Version

0.4.0

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Paul Sherrill

Last Published

February 27th, 2026

Functions in musicMCT (0.4.0)

howfree

Count a scale's degrees of freedom
ifunc

All intervals from one set to another
get_relevant_rows

Which hyperplanes affect a given generic interval?
fpunique

Unique real values up to some tolerance
isproper

Rothenberg propriety
isgwf

Is a scale n-wise well formed?
ineqmats

Hyperplane arrangements for MCT spaces
ianring

Look up a scale at Ian Ring's Exciting Universe of Music Theory
make_roth_ineqmat

Define hyperplanes for Rothenberg arrangements
make_white_ineqmat

Define hyperplanes for white arrangements
ivec

Interval-class vector
j

Convenient just-intonation intervals and scales
make_offset_ineqmat

Translate a hyperplane arrangement to a new center
make_infrared_ineqmat

Define hyperplanes for infrared arrangements
dft

The musical Discrete Fourier Transform of a pitch-class set
point_on_flat

Generate one point on arbitrary combination of hyperplanes
populate_flat

Randomly generate scales on a flat
meantone_fifth

Define a tempered fifth for various meantone scales
minimize_vl

Smallest voice leading between two sets
musicMCT-package

musicMCT: Analyze the Structure of Musical Scales
move_to_hyperplane

Intersection of a line with a hyperplane
make_anaglyph_ineqmat

Define hyperplanes for cross-type voice leadings
make_black_ineqmat

Define hyperplanes for transposition-sensitive arrangements
ineqsym

Symmetries of hyperplane arrangements define equivalent scales
intervalspectrum

Specific sizes corresponding to each generic interval
roth_ineqmats

Hyperplane arrangements for Rothenberg arrangements
maxeven

Maximally even scales
iswellformed

Well-formedness, Myhill's property, and/or moment of symmetry
makeineqmat

Define hyperplanes for the Modal Color Theory arrangements
realize_stepword

Define scale by entering its relative step sizes
isym

Test for inversional symmetry
normal_form

Hook's OPTIC normal forms
primeform

Prime form of a set using Rahn's algorithm
primary_hue

Primary colors
quantize_hue

Find a scale mod k that matches a given hue
rotate

Circular rotation of an ordered tuple
set_to_distribution

Convert between pitch-class sets and distributions
set_from_signvector

Create a scale from a sign vector
same_hue

Do two scales lie on the same ray?
signvector

Detect a scale's location relative to a hyperplane arrangement
readSCL

Import a Scala (.scl) file as a scale
signed_interval_class

Ordered pitch-class interval represented as interval class with sign
tndists

Distances between continuous transpositions of a set
tc

Transpositional combination & pitch multiplication
scale_palette

Orbit of a scale under symmetries of hyperplane arrangement
sc_comp

Set class complement
tnprime

Transposition class of a given pc-set
subset_varieties

Specific varieties of scalar subsets given a generic shape
project_onto

Closest point on a given flat
subsetspectrum

Subset varieties for all subsets of a fixed size
optc_test

Does a scale lie in the canonical fundamental domain for OPTC symmetries?
sim

Scalar (and interscalar) interval matrix
simplify_scale

Best ways to regularize a scale
saturate

Modify evenness without changing hue
quantize_color

Find a scale mod k that matches a given color
sc

Set class from Forte's list
surround_set

Random scales uniformly distributed on a hypersphere around an input
tsym

Test for transpositional symmetry
vl_rolodex

Minimal voice leadings to all transpositions of some Tn-type mod k
vl_generators

Which transpositions give elementary voice leadings?
vl_dist

How far apart are two scales?
whichsvzeroes

Which interval-comparison equalities does a scale satisfy?
writeSCL

Create a Scala tuning file from a given scale
tn

Transposition and Inversion
step_signvector

Specify a scale's step pattern with a sign vector
zmate

Twin set in the Z-relation (Z mate)
z

Frequency ratios to logarithmic pitch intervals (e.g. semitones)
subset_multiplicities

Count the multiplicities of a subset-type's varieties
svzero_fingerprint

Distinguish different types of interval equalities
whichmodebest

Smallest crossing-free voice leading between two pitch-class sets
vlsig

Elementary voice leadings
brightness_comparisons

Voice-leading brightness relationships for a scale's modes
carlos_step

Define a step size for one of Wendy Carlos's scales
comparesignvecs

Do two sign vectors represent adjacent colors?
asword

Algebraic word of a set's step sizes
brightnessgraph

Visualize brightness relationships among modes of a scale
anazero_fingerprint

Are regularities within or between sets in a pair?
colornum

Reference numbers for scale structures
clockface

Visualize a set in pitch-class space
convert

Convert between octave measurements
clampitt_q

Voice leadings between inversions with maximal common tones
flex_points

Voice-leading inflection points
fortenum

Forte number from set class
eps

The brightness ratio
evenness

How even is a scale?
coord_to_edo

Coordinate systems for scale representation
emb

How many instances of a subset-type exist within a scale? How many scales embed a subset?
edoo

Perfectly even scales (the color white)
fortenums

Allen Forte's list of set classes
fpmod

Modulo division with rounding