pctheory.pitch

class PitchClass

Represents a pitch-class

property mod

The pitch-class modulo

property pc

The pitch-class, as an integer

property pc_str

The pitch-class, as a string

__init__(self, pc: int = 0, mod: int = 12)

Creates a PitchClass

Parameters:
  • pc – The pitch class integer

  • mod – The mod number (12 for default chromatic pitch-classes,

24 for quarter-tone pitch-classes)

__add__(self, other)

Adds a PitchClass or integer to this PitchClass.

Parameters:

other – The other item to add

Returns:

A new PitchClass

__eq__(self, other)

Compares two pitch-classes for equality.

Parameters:

other – The other PitchClass

Returns:

True or False

Return type:

bool

__ge__(self, other)

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

Parameters:

other – The other PitchClass

Returns:

True or False

Return type:

bool

__gt__(self, other)

Determines if this PitchClass is greater than another PitchClass.

Parameters:

other – The other PitchClass

Returns:

True or False

Return type:

bool

__hash__(self)

Gets the hash value of this PitchClass.

Returns:

The hash value

__le__(self, other)

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

Parameters:

other – The other PitchClass

Returns:

True or False

Return type:

bool

__lt__(self, other)

Determines if this PitchClass is less than another PitchClass.

Parameters:

other – The other PitchClass

Returns:

True or False

Return type:

bool

__mul__(self, other)

Multiplies a PitchClass or integer by this PitchClass.

Parameters:

other – The item to multiply by

Returns:

A new PitchClass

__ne__(self, other)

Compares two pitch-classes for equality.

Parameters:

other – The other PitchClass

Returns:

True or False

Return type:

bool

__repr__(self)

Gets a representation of this PitchClass.

Returns:

A representation

__str__(self)

Gets a representation of this PitchClass.

Returns:

A representation

__sub__(self, other)

Subtracts a PitchClass or integer from this PitchClass.

Parameters:

other – The item to subtract

Returns:

A new PitchClass

class Pitch(PitchClass)

Represents a pitch

property p

The pitch number

property pname

The pitch name

property midi

The MIDI number

__init__(self, p: int = 0, pc_mod: int = 12, pname: str = 0)

Creates a Pitch

Parameters:
  • p – The pitch integer

  • pc_mod – The modulo for the underlying PitchClass

  • pname – The pitch name as a string (optional, for display purposes)

__add__(self, other)

Adds a Pitch or integer to this Pitch.

Parameters:

other – The other item to add

Returns:

A new Pitch

__eq__(self, other)

Compares two pitches for equality.

Parameters:

other – The other Pitch

Returns:

True or False

Return type:

bool

__ge__(self, other)

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

Parameters:

other – The other Pitch

Returns:

True or False

Return type:

bool

__gt__(self, other)

Determines if this Pitch is greater than another Pitch.

Parameters:

other – The other Pitch

Returns:

True or False

Return type:

bool

__hash__(self)

Gets the hash value of this Pitch.

Returns:

The hash value

__le__(self, other)

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

Parameters:

other – The other Pitch

Returns:

True or False

Return type:

bool

__lt__(self, other)

Determines if this Pitch is less than another Pitch.

Parameters:

other – The other Pitch

Returns:

True or False

Return type:

bool

__mul__(self, other)

Multiplies a Pitch or integer by this Pitch.

Parameters:

other – The item to multiply by

Returns:

A new Pitch

__ne__(self, other)

Compares two pitches for equality.

Parameters:

other – The other Pitch

Returns:

True or False

Return type:

bool

__repr__(self)

Gets a representation of this Pitch.

Returns:

A representation

__str__(self)

Gets a representation of this Pitch.

Returns:

A representation

__sub__(self, other)

Subtracts a Pitch or integer from this Pitch.

Parameters:

other – The item to subtract

Returns:

A new Pitch