pctheory.pcset

class SetClass

Represents a pitch-class set-class. Compatible with mod12 and mod24.

property derived_core

Gets derived core associations

property dsym

Gets the degree of symmetry of the set-class.

property ic_vector

Gets the IC vector

property ic_vector_long

Gets the IC vector in long format

property ic_vector_str

Gets the IC vector as a string

property ic_vector_long_str

Gets the IC vector in long format as a string

property is_z_relation

Whether or not this set-class is Z-related to another set-class

property mod

The mod index

property name_carter

Gets Elliott Carter’s number for this set-class

property name_forte

Get Allen Forte’s name for this set-class

property name_morris

Get Robert Morris’s name for this set-class. The Morris name is a combination of the Forte name and the prime form name.

property name_prime

Gets the prime form name for this set-class.

property num_forte

Gets the Forte number for this set-class.

property pcset

Gets the prime form pitch-class set.

property weight_right

Whether or not to calculate the prime form by weighting candidate pitch-class sets from the right (default: True). This does not affect the prime form of the vast majority of mod 12 set-classes.

__init__(self, pcset=None, pc_mod=None)

Creates a SetClass

Parameters:
  • pcset – A pcset to initialize the SetClass, or else the prime form name of the SetClass.

  • pc_mod – The modulo of the SetClass. If none is provided, it will be assumed from the pcset. If no pcset is provided, 12 is assumed.

__eq__(self, other)

Compares two SetClass objects for equality

Parameters:

other – The other SetClass to compare for equality

__hash__(self)

Gets the hash value of the SetClass.

__len__(self)

Gets the cardinality of the SetClass.

__lt__(self, other)

Compares two SetClass objects. Returns True if this set-class is less than the other set-class.

Parameters:

other – The other SetClass to compare

__ne__(self, other)

Compares two SetClass objects for inequality

Parameters:

other – The other SetClass to compare for inequality

__repr__(self)

Gets a representation of the SetClass.

__str__(self)

Gets a representation of the SetClass.

calculate_prime_form(pcset: set, weight_from_right: bool = True, pc_mod: int = 12)

Calculates the prime form of a pcset

Parameters:
  • pcset – The pcset

  • weight_from_right – Whether or not to pack from the right

  • pc_mod – The PitchClass mod value to use

Returns:

The prime form

contains_abstract_subset(self, sc)

Determines if a set-class is an abstract subset of this set-class

Parameters:

sc – A set-class

Returns:

A boolean

get_abstract_complement(self)

Gets the abstract complement of the SetClass

Returns:

The abstract complement SetClass

get_invariance_vector(self)

Gets the invariance vector of the SetClass

Returns:

The invariance vector, or None if the SetClass has a PitchClass modulo other than 12

get_abstract_subset_classes(self)

Gets a set of subset-classes contained in this SetClass

get_partition2_subset_classes(self)

Gets a set of set-class partitions of this SetClass

get_set_classes12(cardinalities: list = None)

Gets the chromatic set-classes

Parameters:

cardinalities – A list of cardinalities if you don’t want the entire list of 224 set-classes

Returns:

A list of the chromatic set-classes

get_z_relation(self)

Gets the Z-relation of the SetClass

Returns:

The Z-relation of the SetClass

is_all_combinatorial_hexachord(self)

Whether or not the SetClass is an all-combinatorial hexachord

Returns:

True or False

is_valid_name(name: str)

Determines if a chromatic (mod 12) set-class name is valid. Validates prime form, Forte, and Morris names. Prime form name format: [xxxx] Forte name format: x-x Morris name format: (x-x)[xxxx]

Parameters:

name – The name

Returns:

A boolean

load_from_name(self, name: str)

Loads a set-class from a prime-form, Morris, or Forte name

Parameters:

name – The name

def get_all_combinatorial_hexachord(name: str)

Gets an all-combinatorial hexachord (ACH) by name (A-F)

Parameters:

name – The name of the hexachord (A-F)

Returns:

The hexachord set-class

*Only produces mod 12 SetClasses

get_complement(pcset: set)

Gets the complement of a pcset

Parameters:

pcset – A pcset

Returns:

The complement pcset

*Compatible with all PitchClass modulos

get_complement_map_utos(pcset: set)

Gets all UTOs that map a pcset into its complement

Parameters:

pcset – A pcset

Returns:

A set of UTOs

*Compatible with PitchClasses mod 12 and 24

get_corpus(pcset: set)

Gets all transformations of a provided pcset

Parameters:

pcset – A pcset

Returns:

A set of all transformations of the pcset

*Compatible with all PitchClass modulos

get_self_map_utos(pcset: set)

Gets all UTOs that map a pcset into itself

Parameters:

pcset – A pcset

Returns:

A set of UTOs

*Compatible with PitchClasses mod 12 and 24

convert_to_pcset12(pcset: set)

Converts a microtonal pcset (mod 24) to a chromatic pcset (mod 12). Microtonal pitch classes are rounded down to the nearest chromatic pitch class.

Parameters:

args – A microtonal pcset (mod 24)

Returns:

A chromatic pcset (mod 12)

convert_to_pcset24(pcset: set)

Converts a chromatic pcset (mod 12) to a microtonal pcset (mod 24).

Parameters:

args – A chromatic pcset (mod 12)

Returns:

A microtonal pcset (mod 24)

invert(pcset: set)

Inverts a pcset

Parameters:

pcset – The pcset

Returns:

The inverted pcset

*Compatible with all PitchClass modulos

is_all_combinatorial_hexachord(pcset: set)

Whether or not a pcset is an all-combinatorial hexachord

Parameters:

pcset – A pcset

Returns:

True or False

*Only compatible with mod 12 SetClasses

make12(*args)

Makes a chromatic pcset (mod 12)

Parameters:

args – Integers that represent pitch classes

Returns:

A pcset

make_pcset12(*args)

Makes a chromatic pcset (mod 12). Alias for make12.

Parameters:

args – Integers that represent pitch classes

Returns:

A pcset

make24(*args)

Makes a microtonal pcset (mod 24)

Parameters:

args – Integers that represent pitch classes

Returns:

A pcset

make_pcset24(*args)

Makes a microtonal pcset (mod 24). Alias for make24.

Parameters:

args – Integers that represent pitch classes

Returns:

A pcset

make_subset_graph(set_class, smallest_cardinality=1, show_graph=False, size=(800, 1100))

Makes a subset graph

Parameters:
  • set_class – A set-class

  • smallest_cardinality – The smallest cardinality to include in the graph

  • show_graph – Whether or not to generate a visualization of the graph

  • size – The size of the visualized graph

Returns:

A graph

multiply(pcset: set, n: int)

Multiplies a pcset

Parameters:
  • pcset – The pcset

  • n – The multiplier

Returns:

The multiplied pcset

*Compatible with all PitchClass modulos

partitions2(pcset: set)

Gets all partitions of a pcset (size 2 or 1)

Parameters:

pcset – A pcset

Returns:

A list of all partitions

*Compatible with all PitchClass modulos

permutations(pcset: set)

Generates all permutations of a pcset. Uses a swapping notion derived from the Bauer-Mengelberg/Ferentz algorithm for generating all-interval twelve-tone rows. Note: The number of permutations will be n! where n is the length of the pcset. The amount of pcsegs is therefore O(n!). You may not want to try generating all permutations of a twelve-note set. You have been warned.

Parameters:

pcs – A pcset

Returns:

A list of pcsegs

*Compatible with all PitchClass modulos

set_class_filter12(name: str, sets: list)

Filters a list of pcsets

Parameters:
  • name – The name to find

  • sets – A list of sets to filter

Returns:

A filtered list

*Compatible with all PitchClass modulos. For pcsets of modulo 12, also supports Forte and Morris names.

subsets(pcset: set)

Gets all subsets of a pcset

Parameters:

pcset – A pcset

Returns:

A list containing all subsets of the pcset

transform(pcset, string)

Transforms a pcset with a provided transformation string - Tn: transpose - I: invert - Mn: multiply

Parameters:
  • pcset – The pcset to transform

  • string – The transformation string

Returns:

The transformed pcset

transpose(pcset: set, n: int)

Transposes a pcset

Parameters:
  • pcset – The pcset

  • n – The index of transposition

Returns:

The transposed pcset

*Compatible with all PitchClass modulos

transpositional_combination(pcset1: set, pcset2: set)

Transpositionally combines (TC) two pcsets. This is Boulez’s “multiplication.”

Parameters:
  • pcset1 – A pcset

  • pcset2 – A pcset

Returns:

The TC pcset

*Compatible with all PitchClass modulos

visualize(pcset: set)

Visualizes a pcset

Parameters:

pcset – A pcset

Returns:

A visualization

*Compatible with all PitchClass modulos