MusicTheory Docs API Toolbox GitHub NuGet
Contents

API / MusicTheory

PitchClassSet record

An unordered set of pitch classes (0 to 11), the object of pitch-class set theory. Duplicates and order are ignored, and equality is set equality. PitchClassSet.NormalForm, PitchClassSet.PrimeForm and PitchClassSet.IntervalClassVector are pinned against music21 for all 4,095 non-empty sets.

Properties

int Cardinality { get; }
The number of distinct pitch classes.
IReadOnlyList<int> PitchClasses { get; }
The pitch classes in ascending order, 0 to 11.
PitchClassSet Complement { get; }
The pitch classes this set lacks.
IReadOnlyList<int> NormalForm { get; }
The most compact ascending ordering, as a list of pitch classes. Rotations are ranked by smallest span, then by the intervals from the first element outward (Forte's packing from the left), then by the lowest starting pitch class. Empty for PitchClassSet.Empty.
IReadOnlyList<int> PrimeForm { get; }
The normal form transposed to start on 0, or that of the inversion if it is smaller. Shared by every set of the same set class. Empty for PitchClassSet.Empty.
IReadOnlyList<int> IntervalClassVector { get; }
How often each interval class (1 to 6) occurs between pairs of members, as six counts.
string ForteName { get; }
Forte's name for the set class (TnI, no A/B suffix): 3-11 for major and minor triads, 4-Z15, 0-1 for PitchClassSet.Empty, 12-1 for PitchClassSet.Chromatic. Generated from music21 in ForteCatalog.
bool IsZRelated { get; }
Whether the set class shares its interval-class vector with another, not related by Tn or TnI.
PitchClassSet? ZPartner { get; }
The prime form of the Z-partner set class (4-Z15 and 4-Z29), or null when not Z-related.

Fields

static readonly PitchClassSet Empty
The empty set.
static readonly PitchClassSet Chromatic
All twelve pitch classes.

Methods

bool Contains(int pitchClass)
Whether the set holds the pitch class, reduced modulo 12.
static PitchClassSet FromForteName(string name)
The prime form of the named set class, for example 4-Z15 gives {0,1,4,6}. The Z may be lower case.

Throws ArgumentNullException name is null.

Throws FormatException The name is not in the catalogue; the message suggests a missing Z.

static PitchClassSet FromNotes(IEnumerable<Note> notes)
Builds a set from the Note.PitchClass of each note.
PitchClassSet Invert(int n = 0)
TnI: maps every pitch class x to n minus x, modulo 12.
bool IsTranspositionOf(PitchClassSet other)
Whether other is this set moved by some Tn.
bool IsTranspositionOrInversionOf(PitchClassSet other)
Whether other is this set moved by some Tn or TnI (the same prime form).
static PitchClassSet Of(ReadOnlySpan<int> pitchClasses)
Builds a set from pitch classes, each reduced modulo 12 (negatives allowed).
string ToString()
The set as {0,4,7}.
PitchClassSet Transpose(int n)
Tn: moves every pitch class up by n semitones, modulo 12.
static bool TryFromForteName(string? name, out PitchClassSet? set)
Like PitchClassSet.FromForteName but returns false instead of throwing.