pctheory.transformations

class OTO

Represents an ordered tone operator. Originally called a “row operator” or “RO” by Morris, it has been renamed here because this class is also used with mod 24 ordered pitch successions (“pitch segments”). Multiplication is performed first, then transposition. These operators can be used with pcsegs.

__init__(self, T=0, R=False, M=1)

Creates an OTO.

Parameters:
  • T (int) – The index of transposition. Alternately, the OTO may be provided as a transformation string (e.g. “T5I”).

  • R (int) – Whether or not to retrograde

  • M (int) – The multiplier

__eq__(self, other)

Compares this OTO with another OTO for equality.

Parameters:

other (OTO) – The other OTO

Returns:

True or False

Return type:

bool

__ge__(self, other)

Determines if this OTO is greater than or equal to another OTO.

Parameters:

other (OTO) – The other OTO

Returns:

True or False

Return type:

bool

__gt__(self, other)

Determines if this OTO is greater than another OTO.

Parameters:

other (OTO) – The other OTO

Returns:

True or False

Return type:

bool

__hash__(self)

Gets the hash value of this OTO.

Returns:

The hash value

__le__(self, other)

Determines if this OTO is less than or equal to another OTO.

Parameters:

other (OTO) – The other OTO

Returns:

True or False

Return type:

bool

__lt__(self, other)

Determines if this OTO is less than another OTO.

Parameters:

other (OTO) – The other OTO

Returns:

True or False

Return type:

bool

__ne__(self, other)

Compares this OTO with another OTO for inequality.

Parameters:

other (OTO) – The other OTO

Returns:

True or False

Return type:

bool

__repr__(self)

Gets a representation of this OTO.

Returns:

A representation

__str__(self)

Gets a representation of this OTO.

Returns:

A representation

transform(self, item)

Transforms an item (can be a pitch-class, list, set, or any number of nestings of these objects).

Parameters:

item – An item

Returns:

The transformed item

__call__(self, item)

Same as OTO.transform().

Parameters:

item – An item

Returns:

The transformed item

class UTO

Represents an unordered tone operator. This is a bijective mapping A -> B. Originally called a “twelve-tone operator” or “TTO” by Morris, it has been renamed here because this class is also used with mod 24 sets. Multiplication is performed first, then transposition. These operators can be used with pcsets or pcsegs.

__init__(self, T=0, M=1)

Creates a UTO

Parameters:
  • T (int) – The index of transposition. Alternately, the UTO may be provided as a transformation string (e.g. “T5I”).

  • M (int) – The index of multiplication

__eq__(self, other)

Compares two UTOs for equality.

Parameters:

other (UTO) – The other UTO

Returns:

True or False

Return type:

bool

__ge__(self, other)

Determines if this UTO is greater than or equal to another UTO.

Parameters:

other (UTO) – The other UTO

Returns:

True or False

Return type:

bool

__gt__(self, other)

Determines if this UTO is greater than another UTO.

Parameters:

other (UTO) – The other UTO

Returns:

True or False

Return type:

bool

__hash__(self)

Gets the hash value of this UTO.

Returns:

The hash value

__le__(self, other)

Determines if this UTO is less than or equal to another UTO.

Parameters:

other (UTO) – The other UTO

Returns:

True or False

Return type:

bool

__lt__(self, other)

Determines if this UTO is less than another UTO.

Parameters:

other (UTO) – The other UTO

Returns:

True or False

Return type:

bool

__ne__(self, other)

Compares two UTOs for inequality.

Parameters:

other (UTO) – The other UTO

Returns:

True or False

Return type:

bool

__repr__(self)

Gets a representation of this UTO.

Returns:

A representation

__str__(self)

Gets a representation of this UTO.

Returns:

A representation

cycles(self, mod: int = 12)

Gets the cycles of the UTO.

Parameters:

mod (int) – The number of possible pcs in the system.

Returns:

The cycles, as a list of lists

Returns:

list

inverse(self, mod: int = 12)

Gets the inverse of the UTO.

Parameters:

mod (int) – The number of possible pcs in the system.

Returns:

The inverse

Return type:

UTO

transform(self, item)

Transforms a pcset, pcseg, or pc.

Parameters:

item – A pcset, pcseg, or pc

Returns:

The transformed item

__call__(self, item)

Same as UTO.transform().

Parameters:

item – A pcset, pcseg, or pc

Returns:

The transformed item

find_otos(pcseg1: list, pcseg2: list)

Gets all OTO transformations of pcseg1 that contain pcseg2 as an ordered subseg.

Parameters:
  • pcseg1 – A pcseg

  • pcseg2 – A pcseg

Returns:

A set of OTOs that transform pcseg1 so that it contains pcseg2.

*Compatible with PitchClasses mod 12 and 24

find_utos(pcset1: set, pcset2: set)

Finds the UTOS that transform pcset1 so it contains pcset2. pcset2 can be a subset of pcset1.

Parameters:
  • pcset1 – A pcset

  • pcset2 – A pcset

Returns:

A list of UTOS

get_otos12()

Gets chromatic OTOs (ROs).

Returns:

A list of OTOs

Return type:

list

get_otos24()

Gets microtonal OTOs.

Returns:

A list of microtonal OTOs

Return type:

list

get_utos12()

Gets the twelve-tone UTOs (TTOs).

Returns:

A dictionary of UTOs

Return type:

dict

get_utos24()

Gets the 24-tone UTOs (24TOs).

Returns:

A dictionary of UTOs

Return type:

dict

left_multiply_utos(*args, mod: int = 12)

Left-multiplies a list of UTOs.

Parameters:
  • args – A collection of UTOs (can be one argument as a list, or multiple UTOs separated by commas. The highest index is evaluated first, and the lowest index is evaluated last.)

  • mod (int) – The number of pcs in the system

Returns:

The result

Return type:

UTO

make_uto_list(*args)

Makes a UTO list.

Parameters:

args – One or more tuples or lists representing UTOs

Returns:

A UTO list

Return type:

list