Class PitchClassSetCatalog
Optional, user-supplied catalog for mapping PCS prime forms to labels (e.g., Forte numbers). This project intentionally ships without any built-in Forte table.
public sealed class PitchClassSetCatalog
- Inheritance
-
PitchClassSetCatalog
- Inherited Members
Methods
Load(string)
Load a catalog from the JSON file at path.
public static PitchClassSetCatalog Load(string path)
Parameters
pathstring
Returns
LoadJson(string)
Load a catalog from a JSON string. Entries with a blank Forte label or empty prime form are skipped.
public static PitchClassSetCatalog LoadJson(string json)
Parameters
jsonstring
Returns
Exceptions
- ArgumentNullException
jsonis null.- InvalidDataException
jsonis not valid JSON.
NormalizePrimeForm(int[])
A prime form as the catalogue keeps it: every value folded into 0-11 and the set sorted
ascending. The catalogue's entries and its lookups both go through this, so an entry
written as [19, 15, 12] is stored, and found, as [0, 3, 7].
public static int[] NormalizePrimeForm(int[] primeForm)
Parameters
primeFormint[]
Returns
- int[]
Exceptions
- ArgumentNullException
primeFormis null.
PrimeFormKey(int[])
The text key a catalogue stores a prime form under — its pitch classes folded, sorted and joined with commas, so "0,3,7" for a minor triad however its notes were given.
public static string PrimeFormKey(int[] primeForm)
Parameters
primeFormint[]
Returns
Remarks
Normalises first, the way TryGetByPrimeForm(int[], out PitchClassSetCatalogEntry?) and LoadJson(string) do
before they call this. It used to fold without sorting, so a caller building their own
index with it from [7, 3, 0] got "7,3,0" — a key the catalogue has never stored
anything under, since it sorts on load — and every lookup through it missed.
Exceptions
- ArgumentNullException
primeFormis null.
TryGetByPrimeForm(int[], out PitchClassSetCatalogEntry?)
Looks up the entry for a prime form, in whatever order and octave its pitch classes are
given; the form is normalised before the lookup, so [7, 3, 0] finds the minor
triad.
public bool TryGetByPrimeForm(int[] primeForm, out PitchClassSetCatalogEntry? entry)
Parameters
primeFormint[]entryPitchClassSetCatalogEntry
Returns
Exceptions
- ArgumentNullException
primeFormis null.