pcollections¶
Classes
Numbered pitch-class segment. |
|
Numbered pitch-class set. |
|
Pitch range. |
|
Named pitch segment. |
|
Numbered pitch set. |
|
Twelve-tone row. |
- class abjad.pcollections.PitchClassSegment(items=())[source]¶
Numbered pitch-class segment.
>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7]) >>> segment PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
Attributes Summary
Adds
argument
to numbered pitch-class segment.Is true when numbered pitch-class segment contains
argument
.Return self==value.
Gets
argument
from numbered pitch-class segment.Iterates numbered pitch-class segment.
Gets length of numbered pitch-class segment.
Multiplies numbered pitch-class segment by
n
.Gets repr.
Multiplies
n
by numbered pitch-class segment.Gets string representation of numbered pitch-class segment.
Inverts numbered pitch-class segment.
Multiplies pitch-classes in numbered pitch-class segment by
n
.Gets retrograde of numbered pitch-class segment.
Rotates numbered pitch-class segment by index
n
.Transposes numbered pitch-class segment by index
n
.Special methods
- __contains__(argument)[source]¶
Is true when numbered pitch-class segment contains
argument
.- Return type:
- overridden __eq__(other)¶
Return self==value.
- __mul__(n)[source]¶
Multiplies numbered pitch-class segment by
n
.>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> 2 * segment PitchClassSegment([10, 10.5, 6, 7, 10.5, 7, 10, 10.5, 6, 7, 10.5, 7])
- Return type:
- __rmul__(n)[source]¶
Multiplies
n
by numbered pitch-class segment.>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> segment * 2 PitchClassSegment([10, 10.5, 6, 7, 10.5, 7, 10, 10.5, 6, 7, 10.5, 7])
- Return type:
- overridden __str__()[source]¶
Gets string representation of numbered pitch-class segment.
>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7]) >>> str(segment) 'PC<10, 10.5, 6, 7, 10.5, 7>'
- Return type:
Methods
- invert(axis=None)[source]¶
Inverts numbered pitch-class segment.
>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> segment.invert() PitchClassSegment([2, 1.5, 6, 5, 1.5, 5])
>>> segment.invert().invert() PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
- Return type:
- multiply(n=1)[source]¶
Multiplies pitch-classes in numbered pitch-class segment by
n
.>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7]) >>> segment PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> segment.multiply(n=1) PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
>>> segment.multiply(n=5) PitchClassSegment([2, 4.5, 6, 11, 4.5, 11])
>>> segment.multiply(n=7) PitchClassSegment([10, 1.5, 6, 1, 1.5, 1])
>>> segment.multiply(n=99) PitchClassSegment([6, 7.5, 6, 9, 7.5, 9])
- Return type:
- retrograde()[source]¶
Gets retrograde of numbered pitch-class segment.
>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> segment.retrograde() PitchClassSegment([7, 10.5, 7, 6, 10.5, 10])
>>> segment.retrograde().retrograde() PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
- Return type:
- rotate(n=0)[source]¶
Rotates numbered pitch-class segment by index
n
.>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> segment.rotate(n=1) PitchClassSegment([7, 10, 10.5, 6, 7, 10.5])
>>> segment.rotate(n=-1) PitchClassSegment([10.5, 6, 7, 10.5, 7, 10])
>>> segment.rotate(n=0) PitchClassSegment([10, 10.5, 6, 7, 10.5, 7])
- Return type:
- class abjad.pcollections.PitchClassSet(argument=())[source]¶
Numbered pitch-class set.
>>> set_ = abjad.PitchClassSet([-2, -1.5, 6, 7, -1.5, 7]) >>> set_ PitchClassSet([6, 7, 10, 10.5])
>>> str(set_) 'PC{6, 7, 10, 10.5}'
>>> abjad.NamedPitch("fs") in set_ False
>>> abjad.NamedPitch("f") in set_ False
>>> 6 in set_ False
>>> 5 in set_ False
>>> abjad.NumberedPitchClass(5) in set_ False
>>> abjad.NumberedPitchClass(6) in set_ True
Classical operators:
>>> set_1 = abjad.PitchClassSet([0, 2, 4, 5]) >>> set_2 = abjad.PitchClassSet([4, 5, 9])
>>> set_1 & set_2 PitchClassSet([4, 5])
>>> set_1 | set_2 PitchClassSet([0, 2, 4, 5, 9])
>>> set_1 ^ set_2 PitchClassSet([0, 2, 9])
>>> set_1 - set_2 PitchClassSet([0, 2])
>>> set_2 - set_1 PitchClassSet([9])
Attributes Summary
Return self&value.
Return self|value.
Return repr(self).
Return str(self).
Return self-value.
Return self^value.
Return the difference of two or more sets as a new set.
Gets normal order.
Gets prime form.
Return the intersection of two sets as a new set.
Inverts pitch-class set.
Multiplies pitch-class set by
n
.Return the symmetric difference of two sets as a new set.
Transposes all pitch-classes in pitch-class set by index
n
.Return the union of sets as a new set.
Special methods
- overridden __and__(*arguments)¶
Return self&value.
-
(
frozenset
).__class_getitem__()¶ See PEP 585
-
(
frozenset
).__contains__()¶ x.__contains__(y) <==> y in x.
-
(
frozenset
).__eq__(value, /)¶ Return self==value.
-
(
frozenset
).__ge__(value, /)¶ Return self>=value.
-
(
frozenset
).__gt__(value, /)¶ Return self>value.
-
(
frozenset
).__hash__()¶ Return hash(self).
-
(
frozenset
).__iter__()¶ Implement iter(self).
-
(
frozenset
).__le__(value, /)¶ Return self<=value.
-
(
frozenset
).__len__()¶ Return len(self).
-
(
frozenset
).__lt__(value, /)¶ Return self<value.
-
(
frozenset
).__ne__(value, /)¶ Return self!=value.
- overridden __or__(*arguments)¶
Return self|value.
-
(
frozenset
).__rand__(value, /)¶ Return value&self.
-
(
frozenset
).__ror__(value, /)¶ Return value|self.
-
(
frozenset
).__rsub__(value, /)¶ Return value-self.
-
(
frozenset
).__rxor__(value, /)¶ Return value^self.
- overridden __sub__(*arguments)¶
Return self-value.
- overridden __xor__(*arguments)¶
Return self^value.
Methods
-
(
frozenset
).copy()¶ Return a shallow copy of a set.
- overridden difference(*arguments)¶
Return the difference of two or more sets as a new set.
(i.e. all elements that are in this set but not the others.)
- get_normal_order()[source]¶
Gets normal order.
Gets normal order of empty pitch-class set:
>>> pc_set = abjad.PitchClassSet() >>> pc_set.get_normal_order() PitchClassSegment([])
Gets normal order:
>>> pc_set = abjad.PitchClassSet([0, 1, 10, 11]) >>> pc_set.get_normal_order() PitchClassSegment([10, 11, 0, 1])
Gets normal order:
>>> pc_set = abjad.PitchClassSet([2, 8, 9]) >>> pc_set.get_normal_order() PitchClassSegment([8, 9, 2])
Gets normal order of pitch-class set with degree of symmetry equal to 2:
>>> pc_set = abjad.PitchClassSet([1, 2, 7, 8]) >>> pc_set.get_normal_order() PitchClassSegment([1, 2, 7, 8])
Gets normal order of pitch-class set with degree of symmetry equal to 4:
>>> pc_set = abjad.PitchClassSet([0, 3, 6, 9]) >>> pc_set.get_normal_order() PitchClassSegment([0, 3, 6, 9])
- Return type:
- get_prime_form(transposition_only=False)[source]¶
Gets prime form.
Gets prime form of empty pitch-class set:
>>> pc_set = abjad.PitchClassSet() >>> pc_set.get_prime_form() PitchClassSet([])
>>> pc_set = abjad.PitchClassSet() >>> pc_set.get_prime_form(transposition_only=True) PitchClassSet([])
Gets prime form:
>>> pc_set = abjad.PitchClassSet([0, 1, 10, 11]) >>> pc_set.get_prime_form() PitchClassSet([0, 1, 2, 3])
>>> pc_set = abjad.PitchClassSet([0, 1, 10, 11]) >>> pc_set.get_prime_form(transposition_only=True) PitchClassSet([0, 1, 2, 3])
Gets prime form:
>>> pc_set = abjad.PitchClassSet([2, 8, 9]) >>> pc_set.get_prime_form() PitchClassSet([0, 1, 6])
>>> pc_set = abjad.PitchClassSet([2, 8, 9]) >>> pc_set.get_prime_form(transposition_only=True) PitchClassSet([0, 1, 6])
Gets prime form of pitch-class set with degree of symmetry equal to 2:
>>> pc_set = abjad.PitchClassSet([1, 2, 7, 8]) >>> pc_set.get_prime_form() PitchClassSet([0, 1, 6, 7])
>>> pc_set = abjad.PitchClassSet([1, 2, 7, 8]) >>> pc_set.get_prime_form(transposition_only=True) PitchClassSet([0, 1, 6, 7])
Gets prime form of pitch-class set with degree of symmetry equal to 4:
>>> pc_set = abjad.PitchClassSet([0, 3, 6, 9]) >>> pc_set.get_prime_form() PitchClassSet([0, 3, 6, 9])
>>> pc_set = abjad.PitchClassSet([0, 3, 6, 9]) >>> pc_set.get_prime_form(transposition_only=True) PitchClassSet([0, 3, 6, 9])
Gets prime form of pitch-class that is not inversion-equivalent:
>>> pc_set = abjad.PitchClassSet([0, 4, 6, 7]) >>> pc_set.get_prime_form() PitchClassSet([0, 1, 3, 7])
>>> pc_set = abjad.PitchClassSet([0, 4, 6, 7]) >>> pc_set.get_prime_form(transposition_only=True) PitchClassSet([0, 4, 6, 7])
Gets prime form of inversionally nonequivalent pitch-class set:
>>> pc_set = abjad.PitchClassSet([0, 4, 7]) >>> pc_set.get_prime_form() PitchClassSet([0, 3, 7])
>>> pc_set = abjad.PitchClassSet([0, 4, 7]) >>> pc_set.get_prime_form(transposition_only=True) PitchClassSet([0, 4, 7])
REGRESSION:
>>> pc_set = abjad.PitchClassSet([0, 1, 2, 5, 8, 9]) >>> pc_set.get_prime_form() PitchClassSet([0, 1, 2, 5, 6, 9])
REGRESSION:
>>> pc_set = abjad.PitchClassSet([0, 1, 2, 3, 6, 7]) >>> pc_set.get_prime_form() PitchClassSet([0, 1, 2, 3, 6, 7])
Returns new pitch-class set.
- Return type:
- overridden intersection(*arguments)¶
Return the intersection of two sets as a new set.
(i.e. all elements that are in both sets.)
- invert(axis=None)[source]¶
Inverts pitch-class set.
>>> abjad.PitchClassSet([-2, -1.5, 6, 7, -1.5, 7]).invert() PitchClassSet([1.5, 2, 5, 6])
- Return type:
-
(
frozenset
).isdisjoint()¶ Return True if two sets have a null intersection.
-
(
frozenset
).issubset()¶ Report whether another set contains this set.
-
(
frozenset
).issuperset()¶ Report whether this set contains another set.
- multiply(n)[source]¶
Multiplies pitch-class set by
n
.>>> abjad.PitchClassSet([-2, -1.5, 6, 7, -1.5, 7]).multiply(5) PitchClassSet([2, 4.5, 6, 11])
- Return type:
- overridden symmetric_difference(*arguments)¶
Return the symmetric difference of two sets as a new set.
(i.e. all elements that are in exactly one of the sets.)
- transpose(n=0)[source]¶
Transposes all pitch-classes in pitch-class set by index
n
.>>> set_ = abjad.PitchClassSet([-2, -1.5, 6, 7, -1.5, 7]) >>> for n in range(12): ... print(n, set_.transpose(n)) ... 0 PC{6, 7, 10, 10.5} 1 PC{7, 8, 11, 11.5} 2 PC{0, 0.5, 8, 9} 3 PC{1, 1.5, 9, 10} 4 PC{2, 2.5, 10, 11} 5 PC{0, 3, 3.5, 11} 6 PC{0, 1, 4, 4.5} 7 PC{1, 2, 5, 5.5} 8 PC{2, 3, 6, 6.5} 9 PC{3, 4, 7, 7.5} 10 PC{4, 5, 8, 8.5} 11 PC{5, 6, 9, 9.5}
- Return type:
- overridden union(*arguments)¶
Return the union of sets as a new set.
(i.e. all elements that are in either set.)
Read-only properties
- cardinality¶
- class abjad.pcollections.PitchRange(range_string='[A0, C8]')[source]¶
Pitch range.
Pitches from C3 to C7, inclusive:
>>> pitch_range = abjad.PitchRange("[C3, C7]") >>> lilypond_file = abjad.illustrate(pitch_range) >>> abjad.show(lilypond_file)
Attributes Summary
Is true when pitch range contains
argument
.Is true when
argument
is a pitch range withrange_string
equal to this pitch range.Return a >= b.
Return a > b.
Hashes pitch range.
Return a <= b.
Is true when start pitch of this pitch-range is less than start pitch of
argument
pitch range.Gets pitch range interpreter representation.
Initializes pitch range from octave.
Gets range string of pitch range.
Start pitch of pitch range.
Stop pitch of pitch range.
Voices
pitch_class
.Special methods
- __contains__(argument)[source]¶
Is true when pitch range contains
argument
.Closed / closed range:
>>> range_ = abjad.PitchRange("[A0, C8]")
>>> "C0" in range_ False
>>> "A0" in range_ True
>>> "C4" in range_ True
>>> "C8" in range_ True
>>> "C12" in range_ False
Closed / open range:
>>> range_ = abjad.PitchRange("[A0, C8)")
>>> "C0" in range_ False
>>> "A0" in range_ True
>>> "C4" in range_ True
>>> "C8" in range_ False
>>> "C12" in range_ False
Closed / infinite range:
>>> range_ = abjad.PitchRange("[A0, +inf]")
>>> "C0" in range_ False
>>> "A0" in range_ True
>>> "C4" in range_ True
>>> "C8" in range_ True
>>> "C12" in range_ True
Open / closed range:
>>> range_ = abjad.PitchRange("(A0, C8]")
>>> "C0" in range_ False
>>> "A0" in range_ False
>>> "C4" in range_ True
>>> "C8" in range_ True
>>> "C12" in range_ False
Open / open range:
>>> range_ = abjad.PitchRange("(A0, C8)")
>>> "C0" in range_ False
>>> "A0" in range_ False
>>> "C4" in range_ True
>>> "C8" in range_ False
>>> "C12" in range_ False
Infinite / closed range:
>>> range_ = abjad.PitchRange("[-inf, C8]")
>>> "C0" in range_ True
>>> "A0" in range_ True
>>> "C4" in range_ True
>>> "C8" in range_ True
>>> "C12" in range_ False
Infinite / open range:
>>> range_ = abjad.PitchRange("[-inf, C8)")
>>> "C0" in range_ True
>>> "A0" in range_ True
>>> "C4" in range_ True
>>> "C8" in range_ False
>>> "C12" in range_ False
Infinite / infinite range:
>>> range_ = abjad.PitchRange("[-inf, +inf]")
>>> "C0" in range_ True
>>> "A0" in range_ True
>>> "C4" in range_ True
>>> "C8" in range_ True
>>> "C12" in range_ True
Raises exception when argument is not a named pitch or string:
>>> -99 in range_ Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/trevor/abjad/abjad/pcollections.py", line 856, in __contains__ raise Exception(f"must be named pitch or string (not {argument!r}).") Exception: must be named pitch or string (not -99).
- Return type:
- overridden __eq__(argument)[source]¶
Is true when
argument
is a pitch range withrange_string
equal to this pitch range.>>> range_1 = abjad.PitchRange("[A0, C4]") >>> range_2 = abjad.PitchRange("[A0, C4]") >>> range_3 = abjad.PitchRange("[A0, C8]")
>>> range_1 == range_1 True
>>> range_1 == range_2 True
>>> range_1 == range_3 False
>>> range_2 == range_1 True
>>> range_2 == range_2 True
>>> range_2 == range_3 False
>>> range_3 == range_1 False
>>> range_3 == range_2 False
>>> range_3 == range_3 True
- Return type:
- overridden __ge__(other)¶
Return a >= b. Computed by @total_ordering from (not a < b).
- overridden __gt__(other)¶
Return a > b. Computed by @total_ordering from (not a < b) and (a != b).
- overridden __le__(other)¶
Return a <= b. Computed by @total_ordering from (a < b) or (a == b).
- overridden __lt__(argument)[source]¶
Is true when start pitch of this pitch-range is less than start pitch of
argument
pitch range.>>> range_1 = abjad.PitchRange("[A0, C4]") >>> range_2 = abjad.PitchRange("[A0, C4]") >>> range_3 = abjad.PitchRange("[A0, C8]")
>>> range_1 < range_1 False
>>> range_1 < range_2 False
>>> range_1 < range_3 True
>>> range_2 < range_1 False
>>> range_2 < range_2 False
>>> range_2 < range_3 True
>>> range_3 < range_1 False
>>> range_3 < range_2 False
>>> range_3 < range_3 False
- Return type:
Methods
- voice_pitch_class(pitch_class)[source]¶
Voices
pitch_class
.Voices C three times:
>>> pitch_range = abjad.PitchRange("[C4, C6]") >>> pitch_range.voice_pitch_class("c") (NamedPitch("c'"), NamedPitch("c''"), NamedPitch("c'''"))
Voices B two times:
>>> pitch_range = abjad.PitchRange("[C4, C6]") >>> pitch_range.voice_pitch_class("b") (NamedPitch("b'"), NamedPitch("b''"))
Returns empty because B can not voice:
>>> pitch_range = abjad.PitchRange("[C4, A4)") >>> pitch_range.voice_pitch_class("b") ()
Class & static methods
- static from_octave(octave)[source]¶
Initializes pitch range from octave.
>>> abjad.PitchRange.from_octave(5) PitchRange(range_string='[C5, C6)')
- Return type:
Read-only properties
- range_string¶
Gets range string of pitch range.
>>> abjad.PitchRange("[C3, C7]").range_string '[C3, C7]'
>>> abjad.PitchRange("[-inf, C7]").range_string '[-inf, C7]'
>>> abjad.PitchRange("[C3, +inf]").range_string '[C3, +inf]'
>>> abjad.PitchRange("[-inf, +inf]").range_string '[-inf, +inf]'
- start_pitch¶
Start pitch of pitch range.
>>> abjad.PitchRange("[C3, C7]").start_pitch NamedPitch('c')
>>> abjad.PitchRange("[-inf, C7]").start_pitch is None True
- stop_pitch¶
Stop pitch of pitch range.
>>> abjad.PitchRange("[C3, C7]").stop_pitch NamedPitch("c''''")
>>> abjad.PitchRange("[C8, +inf]").stop_pitch is None True
- class abjad.pcollections.PitchSegment(items=())[source]¶
Named pitch segment.
>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> str(segment) '<-2, -1.5, 6, 7, -1.5, 7>'
>>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
Attributes Summary
Is true when named pitch segment contains
argument
.Return self==value.
Gets item at
argument
in named pitch segment.Iterates named pitch segment.
Gets length of named pitch segment.
Gets repr.
Gets string.
Inverts named pitch segment about
axis
.Multiplies pitch segment by index
n
.Retrograde of pitch segment.
Rotates pitch segment by index
n
.Transposes pitch segment by index
n
.Special methods
- __contains__(argument)[source]¶
Is true when named pitch segment contains
argument
.>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> abjad.NamedPitch("fs'") in segment False
>>> abjad.NamedPitch(6) in segment False
>>> abjad.NamedPitch("fs") in segment False
>>> 6 in segment True
>>> abjad.NumberedPitch(6) in segment True
>>> abjad.NumberedPitch("fs'") in segment True
>>> abjad.NamedPitch("f") in segment False
>>> 5 in segment False
- Return type:
- overridden __eq__(other)¶
Return self==value.
- overridden __str__()[source]¶
Gets string.
>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> str(segment) '<-2, -1.5, 6, 7, -1.5, 7>'
- Return type:
Methods
- invert(axis=None)[source]¶
Inverts named pitch segment about
axis
.>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
>>> segment = segment.invert(axis=0)
>>> str(segment) '<2, 1.5, -6, -7, 1.5, -7>'
>>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
- Return type:
- multiply(n=1)[source]¶
Multiplies pitch segment by index
n
.>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
>>> segment = segment.multiply(n=3)
>>> str(segment) '<-6, -4.5, 18, 21, -4.5, 21>'
>>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
- Return type:
- retrograde()[source]¶
Retrograde of pitch segment.
>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
>>> segment = segment.retrograde()
>>> str(segment) '<7, -1.5, 7, 6, -1.5, -2>'
>>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
- Return type:
- rotate(n=0)[source]¶
Rotates pitch segment by index
n
.>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
>>> segment = segment.rotate(n=1)
>>> str(segment) '<7, -2, -1.5, 6, 7, -1.5>'
>>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
- Return type:
- transpose(n=0)[source]¶
Transposes pitch segment by index
n
.>>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
>>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
>>> segment = segment.transpose(n=11)
>>> str(segment) '<9, 9.5, 17, 18, 9.5, 18>'
>>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
- Return type:
- class abjad.pcollections.PitchSet(argument=())[source]¶
Numbered pitch set.
>>> set_1 = abjad.PitchSet([-26, -2.5, 6, 7, -1.5, 7]) >>> set_2 = abjad.PitchSet([-1.5, 7, 9, 12])
>>> set_1 PitchSet([-26, -2.5, -1.5, 6, 7])
>>> set_2 PitchSet([-1.5, 7, 9, 12])
>>> str(set_1) '{-26, -2.5, -1.5, 6, 7}'
>>> str(set_2) '{-1.5, 7, 9, 12}'
>>> -1.5 in set_1 False
>>> abjad.NumberedPitch(-1.5) in set_1 True
>>> abjad.NumberedPitch("aqs") in set_2 False
>>> len(set_1) 5
>>> len(set_2) 4
Classical operators:
>>> set_1 = abjad.PitchSet([-26, -2.5, 6, 7, -1.5, 7]) >>> set_2 = abjad.PitchSet([-1.5, 7, 9, 12])
>>> set_1 & set_2 PitchSet([-1.5, 7])
>>> set_2 & set_1 PitchSet([-1.5, 7])
>>> set_1.intersection(set_2) PitchSet([-1.5, 7])
>>> set_2.intersection(set_1) PitchSet([-1.5, 7])
>>> set_1 | set_2 PitchSet([-26, -2.5, -1.5, 6, 7, 9, 12])
>>> set_2 | set_1 PitchSet([-26, -2.5, -1.5, 6, 7, 9, 12])
>>> set_1.union(set_2) PitchSet([-26, -2.5, -1.5, 6, 7, 9, 12])
>>> set_2.union(set_1) PitchSet([-26, -2.5, -1.5, 6, 7, 9, 12])
>>> set_1 - set_2 PitchSet([-26, -2.5, 6])
>>> set_1.difference(set_2) PitchSet([-26, -2.5, 6])
>>> set_2 - set_1 PitchSet([9, 12])
>>> set_2.difference(set_1) PitchSet([9, 12])
>>> set_1 ^ set_2 PitchSet([-26, -2.5, 6, 9, 12])
>>> set_2 ^ set_1 PitchSet([-26, -2.5, 6, 9, 12])
>>> set_1.symmetric_difference(set_2) PitchSet([-26, -2.5, 6, 9, 12])
>>> set_2.symmetric_difference(set_1) PitchSet([-26, -2.5, 6, 9, 12])
>>> set_1 = abjad.PitchSet([-6, -5, -3, -1]) >>> set_2 = abjad.PitchSet([-3, -1]) >>> set_3 = abjad.PitchSet([1, 3, 4])
Predicates:
>>> set_1.isdisjoint(set_3) True
>>> set_2.issubset(set_1) True
>>> set_1.issuperset(set_2) True
>>> set_1 = abjad.PitchSet([-26, -2.5, 6, 7, -1.5, 7]) >>> set_2 = abjad.PitchSet([-1.5, 7, 9, 12])
Comparison:
>>> set_1 == set_1 True
>>> set_1 == set_2 False
>>> set_1 < set_1 False
>>> set_1 < set_2 False
>>> set_1 <= set_1 True
>>> set_1 <= set_2 False
>>> set_1 > set_1 False
>>> set_1 > set_2 False
>>> set_1 >= set_1 True
>>> set_1 >= set_2 False
Copy:
>>> import copy >>> set_1_copy = copy.copy(set_1) >>> set_1_copy PitchSet([-26, -2.5, -1.5, 6, 7])
>>> set_1 == set_1_copy True
Empty set:
>>> set_ = abjad.PitchSet() >>> set_ PitchSet()
>>> str(set_) '{}'
>>> len(set_) 0
>>> bool(set_) False
Attributes Summary
Return self&value.
Return self|value.
Gets repr.
Gets string.
Return self-value.
Return self^value.
Return the difference of two or more sets as a new set.
Return the intersection of two sets as a new set.
Return the symmetric difference of two sets as a new set.
Return the union of sets as a new set.
Special methods
- overridden __and__(*arguments)¶
Return self&value.
-
(
frozenset
).__class_getitem__()¶ See PEP 585
-
(
frozenset
).__contains__()¶ x.__contains__(y) <==> y in x.
-
(
frozenset
).__eq__(value, /)¶ Return self==value.
-
(
frozenset
).__ge__(value, /)¶ Return self>=value.
-
(
frozenset
).__gt__(value, /)¶ Return self>value.
-
(
frozenset
).__hash__()¶ Return hash(self).
-
(
frozenset
).__iter__()¶ Implement iter(self).
-
(
frozenset
).__le__(value, /)¶ Return self<=value.
-
(
frozenset
).__len__()¶ Return len(self).
-
(
frozenset
).__lt__(value, /)¶ Return self<value.
-
(
frozenset
).__ne__(value, /)¶ Return self!=value.
- overridden __or__(*arguments)¶
Return self|value.
-
(
frozenset
).__rand__(value, /)¶ Return value&self.
-
(
frozenset
).__ror__(value, /)¶ Return value|self.
-
(
frozenset
).__rsub__(value, /)¶ Return value-self.
-
(
frozenset
).__rxor__(value, /)¶ Return value^self.
- overridden __sub__(*arguments)¶
Return self-value.
- overridden __xor__(*arguments)¶
Return self^value.
Methods
-
(
frozenset
).copy()¶ Return a shallow copy of a set.
- overridden difference(*arguments)¶
Return the difference of two or more sets as a new set.
(i.e. all elements that are in this set but not the others.)
- overridden intersection(*arguments)¶
Return the intersection of two sets as a new set.
(i.e. all elements that are in both sets.)
-
(
frozenset
).isdisjoint()¶ Return True if two sets have a null intersection.
-
(
frozenset
).issubset()¶ Report whether another set contains this set.
-
(
frozenset
).issuperset()¶ Report whether this set contains another set.
- overridden symmetric_difference(*arguments)¶
Return the symmetric difference of two sets as a new set.
(i.e. all elements that are in exactly one of the sets.)
- overridden union(*arguments)¶
Return the union of sets as a new set.
(i.e. all elements that are in either set.)
- class abjad.pcollections.TwelveToneRow(items=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11))[source]¶
Twelve-tone row.
Initializes from defaults:
>>> row = abjad.TwelveToneRow() >>> lilypond_file = abjad.illustrate(row) >>> abjad.show(lilypond_file)
Initializes from integers:
>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0] >>> row = abjad.TwelveToneRow(numbers) >>> lilypond_file = abjad.illustrate(row) >>> abjad.show(lilypond_file)
Interpreter representation:
>>> row TwelveToneRow(items=(NumberedPitchClass(1), NumberedPitchClass(11), NumberedPitchClass(9), NumberedPitchClass(3), NumberedPitchClass(6), NumberedPitchClass(7), NumberedPitchClass(5), NumberedPitchClass(4), NumberedPitchClass(10), NumberedPitchClass(2), NumberedPitchClass(8), NumberedPitchClass(0)))
Attributes Summary
Calls row on
pitch_classes
.Return self==value.
Gets item or slice identified by
argument
.Multiplies row by
argument
.Gets repr.
Multiplies
argument
by row.Inverts row about optional
axis
.Multiplies pitch-classes in row by
n
.Gets retrograde of row.
Rotates row by index
n
.Transposes row by index
n
.Special methods
-
(
PitchClassSegment
).__add__(argument)¶ Adds
argument
to numbered pitch-class segment.- Return type:
- overridden __call__(pitch_classes)[source]¶
Calls row on
pitch_classes
.Example row:
>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0] >>> row = abjad.TwelveToneRow(numbers) >>> lilypond_file = abjad.illustrate(row) >>> abjad.show(lilypond_file)
Permutes pitch-classes:
>>> row([abjad.NumberedPitchClass(2)]) [NumberedPitchClass(9)]
>>> row([abjad.NumberedPitchClass(3)]) [NumberedPitchClass(3)]
>>> row([abjad.NumberedPitchClass(4)]) [NumberedPitchClass(6)]
Permutes pitch-class segment:
>>> segment = abjad.PitchClassSegment([-2, -1, 6, 7, -1, 7]) >>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
>>> voice = lilypond_file["Voice"] >>> string = abjad.lilypond(voice) >>> print(string) \context Voice = "Voice" { bf'8 b'8 fs'8 g'8 b'8 g'8 \bar "|." \override Score.BarLine.transparent = ##f }
>>> row_ = abjad.TwelveToneRow([10, 0, 2, 6, 8, 7, 5, 3, 1, 9, 4, 11]) >>> segment = row_(segment) >>> segment PitchClassSegment([4, 11, 5, 3, 11, 3])
>>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
Permutes row:
>>> numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] >>> row_2 = abjad.TwelveToneRow(numbers) >>> lilypond_file = abjad.illustrate(row_2) >>> abjad.show(lilypond_file)
>>> row_3 = row(row_2) >>> lilypond_file = abjad.illustrate(row_3) >>> abjad.show(lilypond_file)
Permutes row:
>>> numbers = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] >>> row_2 = abjad.TwelveToneRow(numbers) >>> lilypond_file = abjad.illustrate(row_2) >>> abjad.show(lilypond_file)
>>> row_3 = row(row_2) >>> lilypond_file = abjad.illustrate(row_3) >>> abjad.show(lilypond_file)
Permutes row:
>>> numbers = [10, 0, 2, 6, 8, 7, 5, 3, 1, 9, 4, 11] >>> row_2 = abjad.TwelveToneRow(numbers) >>> lilypond_file = abjad.illustrate(row_2) >>> abjad.show(lilypond_file)
>>> row_3 = row(row_2) >>> lilypond_file = abjad.illustrate(row_3) >>> abjad.show(lilypond_file)
Returns permuted pitch-classes in object of type
pitch_classes
.
-
(
PitchClassSegment
).__contains__(argument)¶ Is true when numbered pitch-class segment contains
argument
.- Return type:
- overridden __eq__(other)¶
Return self==value.
- overridden __getitem__(argument)[source]¶
Gets item or slice identified by
argument
.Example row:
>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0] >>> row = abjad.TwelveToneRow(numbers) >>> lilypond_file = abjad.illustrate(row) >>> abjad.show(lilypond_file)
Gets first hexachord:
>>> lilypond_file = abjad.illustrate(row[:6]) >>> abjad.show(lilypond_file)
Gets second hexachord:
>>> lilypond_file = abjad.illustrate(row[-6:]) >>> abjad.show(lilypond_file)
Gets items in row:
>>> row = abjad.TwelveToneRow() >>> lilypond_file = abjad.illustrate(row) >>> abjad.show(lilypond_file)
>>> for item in row.items: ... item ... NumberedPitchClass(0) NumberedPitchClass(1) NumberedPitchClass(2) NumberedPitchClass(3) NumberedPitchClass(4) NumberedPitchClass(5) NumberedPitchClass(6) NumberedPitchClass(7) NumberedPitchClass(8) NumberedPitchClass(9) NumberedPitchClass(10) NumberedPitchClass(11)
Gets items in row:
>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0] >>> row = abjad.TwelveToneRow(numbers) >>> lilypond_file = abjad.illustrate(row) >>> abjad.show(lilypond_file)
>>> for item in row.items: ... item ... NumberedPitchClass(1) NumberedPitchClass(11) NumberedPitchClass(9) NumberedPitchClass(3) NumberedPitchClass(6) NumberedPitchClass(7) NumberedPitchClass(5) NumberedPitchClass(4) NumberedPitchClass(10) NumberedPitchClass(2) NumberedPitchClass(8) NumberedPitchClass(0)
-
(
PitchClassSegment
).__iter__()¶ Iterates numbered pitch-class segment.
-
(
PitchClassSegment
).__len__()¶ Gets length of numbered pitch-class segment.
- overridden __mul__(argument)[source]¶
Multiplies row by
argument
.Multiplies row:
>>> row = abjad.TwelveToneRow() >>> lilypond_file = abjad.illustrate(row) >>> abjad.show(lilypond_file)
>>> segment = 2 * row >>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
Multiplies row:
>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0] >>> row = abjad.TwelveToneRow(numbers) >>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
>>> segment = 2 * row >>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
- Return type:
- overridden __repr__()¶
Gets repr.
- overridden __rmul__(argument)[source]¶
Multiplies
argument
by row.Multiplies integer by row:
>>> row = abjad.TwelveToneRow() >>> lilypond_file = abjad.illustrate(row) >>> abjad.show(lilypond_file)
>>> segment = row * 2 >>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
Multiplies integer by row:
>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0] >>> row = abjad.TwelveToneRow(numbers) >>> lilypond_file = abjad.illustrate(row) >>> abjad.show(lilypond_file)
>>> segment = row * 2 >>> lilypond_file = abjad.illustrate(segment) >>> abjad.show(lilypond_file)
- Return type:
-
(
PitchClassSegment
).__str__()¶ Gets string representation of numbered pitch-class segment.
>>> segment = abjad.PitchClassSegment([-2, -1.5, 6, 7, -1.5, 7]) >>> str(segment) 'PC<10, 10.5, 6, 7, 10.5, 7>'
- Return type:
Methods
- overridden invert(axis=None)[source]¶
Inverts row about optional
axis
.Example row:
>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0] >>> row = abjad.TwelveToneRow(numbers) >>> lilypond_file = abjad.illustrate(row) >>> abjad.show(lilypond_file)
Inverts row about first pitch-class when
axis
is none:>>> inversion = row.invert() >>> lilypond_file = abjad.illustrate(inversion) >>> abjad.show(lilypond_file)
First pitch-classes are equal:
>>> row[0] == inversion[0] True
Inverts row about pitch-class 1:
>>> inversion = row.invert(axis=1) >>> lilypond_file = abjad.illustrate(inversion) >>> abjad.show(lilypond_file)
Same result as above.
Inverts row about pitch-class 0:
>>> inversion = row.invert(axis=0) >>> lilypond_file = abjad.illustrate(inversion) >>> abjad.show(lilypond_file)
Inverts row about pitch-class 5:
>>> inversion = row.invert(axis=5) >>> lilypond_file = abjad.illustrate(inversion) >>> abjad.show(lilypond_file)
- Return type:
- overridden multiply(n=1)[source]¶
Multiplies pitch-classes in row by
n
.Example row:
>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0] >>> row = abjad.TwelveToneRow(numbers) >>> lilypond_file = abjad.illustrate(row) >>> abjad.show(lilypond_file)
Multiplies pitch-classes in row by 5:
>>> multiplication = row.multiply(n=5) >>> lilypond_file = abjad.illustrate(multiplication) >>> abjad.show(lilypond_file)
Multiplies pitch-classes in row by 7:
>>> multiplication = row.multiply(n=7) >>> lilypond_file = abjad.illustrate(multiplication) >>> abjad.show(lilypond_file)
Multiplies pitch-classes in row by 1:
>>> multiplication = row.multiply(n=1) >>> lilypond_file = abjad.illustrate(multiplication) >>> abjad.show(lilypond_file)
- Return type:
- overridden retrograde()[source]¶
Gets retrograde of row.
Example row:
>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0] >>> row = abjad.TwelveToneRow(numbers) >>> lilypond_file = abjad.illustrate(row) >>> abjad.show(lilypond_file)
Gets retrograde of row:
>>> retrograde = row.retrograde() >>> lilypond_file = abjad.illustrate(retrograde) >>> abjad.show(lilypond_file)
Gets retrograde of retrograde of row:
>>> retrograde = row.retrograde().retrograde() >>> lilypond_file = abjad.illustrate(retrograde) >>> abjad.show(lilypond_file)
>>> retrograde == row True
- Return type:
- overridden rotate(n=0)[source]¶
Rotates row by index
n
.Example row:
>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0] >>> row = abjad.TwelveToneRow(numbers) >>> lilypond_file = abjad.illustrate(row) >>> abjad.show(lilypond_file)
Rotates row to the right:
>>> rotation = row.rotate(n=1) >>> lilypond_file = abjad.illustrate(rotation) >>> abjad.show(lilypond_file)
Rotates row to the left:
>>> rotation = row.rotate(n=-1) >>> lilypond_file = abjad.illustrate(rotation) >>> abjad.show(lilypond_file)
Rotates row by zero:
>>> rotation = row.rotate(n=0) >>> lilypond_file = abjad.illustrate(rotation) >>> abjad.show(lilypond_file)
>>> rotation == row True
- Return type:
- overridden transpose(n=0)[source]¶
Transposes row by index
n
.Example row:
>>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0] >>> row = abjad.TwelveToneRow(numbers) >>> lilypond_file = abjad.illustrate(row) >>> abjad.show(lilypond_file)
Transposes row by positive index:
>>> transposition = row.transpose(n=13) >>> lilypond_file = abjad.illustrate(transposition) >>> abjad.show(lilypond_file)
Transposes row by negative index:
>>> transposition = row.transpose(n=-13) >>> lilypond_file = abjad.illustrate(transposition) >>> abjad.show(lilypond_file)
Transposes row by zero index:
>>> transposition = row.transpose(n=0) >>> lilypond_file = abjad.illustrate(transposition) >>> abjad.show(lilypond_file)
>>> transposition == row True
- Return type:
-
(
Functions
Makes interval-class vector. |
|
Voices named |
|
Voices named |
- abjad.pcollections.voice_horizontally(pcs, initial_octave=Octave(number=4))[source]¶
Voices named
pcs
with each pitch as close to the previous pitch as possible.>>> pcs = [abjad.NamedPitchClass(_) for _ in "c b d e f g e b a c".split()] >>> pitches = abjad.pcollections.voice_horizontally(pcs) >>> staff = abjad.Staff([abjad.Note(_, (1, 8)) for _ in pitches]) >>> abjad.show(staff)
- Return type:
- abjad.pcollections.voice_vertically(pcs, initial_octave=Octave(number=4))[source]¶
Voices named
pcs
with each pitch not lower than the previous.>>> pcs = [abjad.NamedPitchClass(_) for _ in "c ef g bf d f af".split()] >>> pitches = abjad.pcollections.voice_vertically(pcs) >>> staff = abjad.Staff([abjad.Note(_, (1, 8)) for _ in pitches]) >>> abjad.show(staff)
- Return type: