UnpitchedTone
UnpitchedTone()A Tone that is a sound with no pitch.
This is the general idea behind a drum stroke, a tabla bol, a cymbal crash, a hand clap: WSMN’s PercussionTone (a relative pitch and a stroke, on whatever instrument the Part names) is one implementation. pitch is None, as for any unpitched Tone, so Tone.__format__ gives the tone’s str(); a system decides what else a sound is made of, and declares its own TonalSystem.
Silence is not a sound: SilentTone is a Tone but not an UnpitchedTone.
>>> from openmusickit.values.tone.silent_tone import SilentTone
>>> from openmusickit.values.tone.tone import ANY_TONAL_SYSTEM
>>> class Knock(UnpitchedTone):
... @property
... def tonal_system(self):
... return ANY_TONAL_SYSTEM
>>> isinstance(Knock(), Tone), Knock().pitch is None
(True, True)
>>> isinstance(SilentTone(), UnpitchedTone)
FalseAttributes
| Name | Description |
|---|---|
| tonal_system | The TonalSystem this tone belongs to (for introspection and compatibility checks). |
| pitch | The PitchRepresentation of this Tone, defined within a specific |
__slots__ |
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. |
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: ...