NamedPitchClass

class pitchtools.NamedPitchClass(name='c')

Named pitch-class.

>>> import abjad
>>> import pytest

Initializes from pitch-class name:

>>> abjad.NamedPitchClass('cs')
NamedPitchClass('cs')

Initializes quartertone from pitch-class name:

>>> abjad.NamedPitchClass('cqs')
NamedPitchClass('cqs')

Initializes from number of semitones:

>>> abjad.NamedPitchClass(14)
NamedPitchClass('d')

Initializes quartertone from number of semitones:

>>> abjad.NamedPitchClass(14.5)
NamedPitchClass('dqs')

Initializes from named pitch:

>>> abjad.NamedPitchClass(abjad.NamedPitch('g,'))
NamedPitchClass('g')

Initializes from numbered pitch:

>>> abjad.NamedPitchClass(abjad.NumberedPitch(15))
NamedPitchClass('ef')

Initializes from numbered pitch-class:

>>> abjad.NamedPitchClass(abjad.NumberedPitchClass(4))
NamedPitchClass('e')

Initializes from pitch-class / octave-number string:

>>> abjad.NamedPitchClass('C#5')
NamedPitchClass('cs')

Initializes quartertone from pitch-class / octave-number string:

>>> abjad.NamedPitchClass('C+5')
NamedPitchClass('cqs')

Initializes from pitch-class abbreviation:

>>> abjad.NamedPitchClass('C#5')
NamedPitchClass('cs')

Initializes quartertone from pitch-class / octave-number string:

>>> abjad.NamedPitchClass('C+') 

Note

Make this work.

Initializes from named pitch-class:

>>> abjad.NamedPitchClass(abjad.Note("a'8."))
NamedPitchClass('a')

Initializes from pitch-class name:

>>> abjad.NamedPitchClass('cs')
NamedPitchClass('cs')

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" [color=1, group=0, label=AbjadValueObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.abctools.AbjadValueObject.AbjadValueObject"; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_pitchtools { graph [label=pitchtools]; "abjad.tools.pitchtools.NamedPitchClass.NamedPitchClass" [color=black, fontcolor=white, group=2, label=<<B>NamedPitchClass</B>>, shape=box, style="filled, rounded"]; "abjad.tools.pitchtools.PitchClass.PitchClass" [color=3, group=2, label=PitchClass, shape=oval, style=bold]; "abjad.tools.pitchtools.PitchClass.PitchClass" -> "abjad.tools.pitchtools.NamedPitchClass.NamedPitchClass"; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" -> "abjad.tools.pitchtools.PitchClass.PitchClass"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

accidental Gets accidental.
invert([axis]) Inverts named pitch-class.
is_diatonic_pitch_class_name(argument) Is true when argument is a diatonic pitch-class name.
is_diatonic_pitch_class_number(argument) Is true when argument is a diatonic pitch-class number.
is_pitch_class_name(argument) Is true when argument is a pitch-class name.
is_pitch_class_number(argument) Is true when argument is a pitch-class number.
multiply([n]) Multiplies named pitch-class by n.
name Gets name of named pitch-class.
number Gets number.
pitch_class_label Gets pitch-class label.
transpose([n]) Transposes named pitch-class by index named interval n.
__add__(named_interval) Adds named_interval to named pitch-class.
__copy__(*arguments) Copies named pitch-class.
__eq__(argument) Is true when argument can be coerced to a named pitch-class with pitch-class name equal to that of this named pitch-class.
__float__() Coerce to float.
__format__([format_specification]) Formats named pitch-class.
__ge__(other[, NotImplemented]) Return a >= b.
__gt__(other[, NotImplemented]) Return a > b.
__hash__() Hashes named pitch-class.
__le__(other[, NotImplemented]) Return a <= b.
__lt__(argument) Is true when argument is a named pitch-class with a pitch number greater than that of this named pitch-class.
__ne__(argument) Is true when Abjad object does not equal argument.
__radd__(interval) Right-addition not defined on named pitch-classes.
__repr__() Gets interpreter representation of Abjad object.
__str__() Gets string representation of named pitch-class.
__sub__(argument) Subtracts argument from named pitch-class.

Read-only properties

NamedPitchClass.accidental

Gets accidental.

>>> abjad.NamedPitchClass('cs').accidental
Accidental('sharp')

Returns accidental.

NamedPitchClass.name

Gets name of named pitch-class.

>>> abjad.NamedPitchClass('cs').name
'cs'

Returns string.

NamedPitchClass.number

Gets number.

>>> abjad.NamedPitchClass('cs').number
1

Returns nonnegative integer or float.

NamedPitchClass.pitch_class_label

Gets pitch-class label.

>>> abjad.NamedPitchClass('cs').pitch_class_label
'C#'

Returns string.

Methods

NamedPitchClass.invert(axis=None)

Inverts named pitch-class.

Not yet implemented.

NamedPitchClass.multiply(n=1)

Multiplies named pitch-class by n.

>>> abjad.NamedPitchClass('cs').multiply(3)
NamedPitchClass('ef')

Returns new named pitch-class.

NamedPitchClass.transpose(n=0)

Transposes named pitch-class by index named interval n.

>>> interval = abjad.NamedInterval('-M2')
>>> abjad.NamedPitchClass('cs').transpose(interval)
NamedPitchClass('b')
>>> interval = abjad.NamedInterval('P1')
>>> abjad.NamedPitchClass('cs').transpose(interval)
NamedPitchClass('cs')
>>> interval = abjad.NamedInterval('+M2')
>>> abjad.NamedPitchClass('cs').transpose(interval)
NamedPitchClass('ds')

Returns new named pitch-class.

Class & static methods

(PitchClass).is_diatonic_pitch_class_name(argument)

Is true when argument is a diatonic pitch-class name. Otherwise false.

>>> abjad.PitchClass.is_diatonic_pitch_class_name('g')
True
>>> abjad.PitchClass.is_diatonic_pitch_class_name('G')
True
>>> abjad.PitchClass.is_diatonic_pitch_class_name('Allegro')
False

The regex ^[a-g,A-G]$ underlies this predicate.

Returns true or false.

(PitchClass).is_diatonic_pitch_class_number(argument)

Is true when argument is a diatonic pitch-class number. Otherwise false.

>>> abjad.PitchClass.is_diatonic_pitch_class_number(0)
True
>>> abjad.PitchClass.is_diatonic_pitch_class_number(-5)
False

The diatonic pitch-class numbers are equal to the set [0, 1, 2, 3, 4, 5, 6].

Returns true or false.

(PitchClass).is_pitch_class_name(argument)

Is true when argument is a pitch-class name. Otherwise false.

>>> abjad.PitchClass.is_pitch_class_name('fs')
True
>>> abjad.PitchClass.is_pitch_class_name('fqs')
True
>>> abjad.PitchClass.is_pitch_class_name('f,,')
False

The regex ^([a-g,A-G])(([s]{1,2}|[f]{1,2}|t?q?[fs]|)!?)$ underlies this predicate.

Returns true or false.

(PitchClass).is_pitch_class_number(argument)

Is true when argument is a pitch-class number. Otherwise false.

>>> abjad.PitchClass.is_pitch_class_number(1)
True
>>> abjad.PitchClass.is_pitch_class_number(1.5)
True
>>> abjad.PitchClass.is_pitch_class_number(12)
False

The pitch-class numbers are equal to the set [0, 0.5, ..., 11, 11.5].

Returns true or false.

Special methods

NamedPitchClass.__add__(named_interval)

Adds named_interval to named pitch-class.

>>> abjad.NamedPitchClass('cs') + abjad.NamedInterval('+M9')
NamedPitchClass('ds')
>>> abjad.NamedPitchClass('cs') + abjad.NamedInterval('-M9')
NamedPitchClass('b')

Returns new named pitch-class.

NamedPitchClass.__copy__(*arguments)

Copies named pitch-class.

>>> import copy
>>> copy.copy(abjad.NamedPitchClass('cs'))
NamedPitchClass('cs')

Returns new named pitch-class.

NamedPitchClass.__eq__(argument)

Is true when argument can be coerced to a named pitch-class with pitch-class name equal to that of this named pitch-class.

>>> pitch_class_1 = abjad.NamedPitchClass('cs')
>>> pitch_class_2 = abjad.NamedPitchClass('cs')
>>> pitch_class_3 = abjad.NamedPitchClass('df')
>>> pitch_class_1 == pitch_class_1
True
>>> pitch_class_1 == pitch_class_2
True
>>> pitch_class_1 == pitch_class_3
False
>>> pitch_class_2 == pitch_class_1
True
>>> pitch_class_2 == pitch_class_2
True
>>> pitch_class_2 == pitch_class_3
False
>>> pitch_class_3 == pitch_class_1
False
>>> pitch_class_3 == pitch_class_2
False
>>> pitch_class_3 == pitch_class_3
True

Returns true or false.

(PitchClass).__float__()

Coerce to float.

Returns float.

NamedPitchClass.__format__(format_specification='')

Formats named pitch-class.

>>> format(abjad.NamedPitchClass('cs'))
"abjad.NamedPitchClass('cs')"

Set format_specification to ‘’, ‘lilypond’ or ‘storage’.

Returns string.

(PitchClass).__ge__(other, NotImplemented=NotImplemented)

Return a >= b. Computed by @total_ordering from (not a < b).

(PitchClass).__gt__(other, NotImplemented=NotImplemented)

Return a > b. Computed by @total_ordering from (not a < b) and (a != b).

NamedPitchClass.__hash__()

Hashes named pitch-class.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

(PitchClass).__le__(other, NotImplemented=NotImplemented)

Return a <= b. Computed by @total_ordering from (a < b) or (a == b).

NamedPitchClass.__lt__(argument)

Is true when argument is a named pitch-class with a pitch number greater than that of this named pitch-class.

Compares less than:

>>> abjad.NamedPitchClass('cs') < abjad.NamedPitchClass('d')
True

Does not compare less than:

>>> abjad.NamedPitchClass('d') < abjad.NamedPitchClass('cs')
False

Raises type error when argument is not a named pitch-class.

(AbjadObject).__ne__(argument)

Is true when Abjad object does not equal argument. Otherwise false.

Returns true or false.

NamedPitchClass.__radd__(interval)

Right-addition not defined on named pitch-classes.

>>> statement = 'abjad.NamedPitchClass("cs").__radd__(1)'
>>> pytest.raises(NotImplementedError, statement)
<ExceptionInfo NotImplementedError ...>
(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

NamedPitchClass.__str__()

Gets string representation of named pitch-class.

>>> str(abjad.NamedPitchClass('cs'))
'cs'

Returns string.

NamedPitchClass.__sub__(argument)

Subtracts argument from named pitch-class.

>>> abjad.NamedPitchClass('cs') - abjad.NamedPitchClass('g')
NamedInversionEquivalentIntervalClass('+aug4')
>>> abjad.NamedPitchClass('c') - abjad.NamedPitchClass('cf')
NamedInversionEquivalentIntervalClass('aug1')
>>> abjad.NamedPitchClass('cf') - abjad.NamedPitchClass('c')
NamedInversionEquivalentIntervalClass('aug1')

Returns named inversion-equivalent interval-class.