PercussionTone
PercussionTone(
relative_pitch: RelativePitch | None = None,
stroke: Stroke | None = None,
)An unpitched sound: a relative pitch and a stroke, each optional.
A PercussionTone abstracts over instruments as a pitch does: PercussionTone(relative_pitch=HIGH, stroke=OPEN) is the same value on congas, bongos or a djembe pair, and the Part says which. PercussionTone() is a plain hit on whatever the Part is; a triangle part or a concert bass drum part is a line of these, with a stroke only where it differs. The palettes in symbols collect the combinations that are meaningful for a class of instrument.
A relative pitch is not a pitch: pitch is None, as for any unpitched tone, and f-strings give the readable form.
>>> tone = PercussionTone(relative_pitch=RelativePitch.HIGH, stroke=Stroke.OPEN)
>>> tone
PercussionTone(relative_pitch=RelativePitch.HIGH, stroke=Stroke.OPEN)
>>> f"{tone}", str(PercussionTone(stroke=Stroke.RIM_SHOT)), str(PercussionTone())
('high open', 'rim shot', 'hit')
>>> tone.pitch is None, tone.tonal_system.name
(True, 'WSMN percussion')
>>> PercussionTone() == PercussionTone(), PercussionTone() in {tone, PercussionTone()}
(True, True)Attributes
| Name | Description |
|---|---|
__slots__ |
|
| pitch | The PitchRepresentation of this Tone, defined within a specific |
| relative_pitch | |
| stroke | |
| tonal_system |
Methods
| Name | Description |
|---|---|
| from_string | Parses a string and returns a Tone. |
__format__ |
Display form of the Tone, used by str.format and f-strings. |
__str__ |
|
__repr__ |
from_string
from_string(s: str)Parses a string and returns a Tone.
An optional hook: systems with a string form override it; the base raises.
>>> from openmusickit.systems.wsmn.tonal.tonal_vector import TonalVector
>>> TonalVector.from_string("G#")
TonalVector((4, 8))
>>> Tone.from_string("G#")
Traceback (most recent call last):
...
NotImplementedError__format__
__format__(spec: str)Display form of the Tone, used by str.format and f-strings.
For pitched tones, the format spec names an attribute of the Tone’s PitchRepresentation, defaulting to unicode; unpitched tones fall back to str(). str() and repr() are unaffected, so they remain available as debug forms (use {tone!r} or {tone!s} in a template to get them).
>>> from openmusickit.systems.wsmn.tonal.tonal_vector import TonalVector
>>> from openmusickit.values.tone.silent_tone import SilentTone
>>> Eb = TonalVector((2, 3))
>>> f"{Eb} major"
'E♭ major'
>>> f"{Eb:ascii} major"
'Eb major'
>>> f"{Eb!r}"
'TonalVector((2, 3))'
>>> f"{SilentTone()}"
'SilentTone()'The spec must name a string attribute of the PitchRepresentation:
>>> f"{Eb:nonsense}"
Traceback (most recent call last):
...
ValueError: ...__str__
__str__()__repr__
__repr__()