musically meaningful pitch types
Project description
pitchtypes
Musically meaningful types
The purpose of this Python library is to:
- Provide types that handle pitch in a musically correct way.
- Make it easy to implement other musically meaningful types.
For instance, spelled pitch is handled correctly:
>>> from pitchtypes import SpelledPitchClass
>>> p1 = SpelledPitchClass("C#")
>>> p2 = SpelledPitchClass("Gb")
>>> i = p1 - p2
>>> type(i)
<class 'pitchtypes.datatypes.SpelledIntervalClass'>
>>> i
+AA4
Of course, you can also convert spelled pitches to their enharmonic equivalents:
>>> from pitchtypes import SpelledPitch, EnharmonicPitch
>>> spelled = SpelledPitch("C#4")
>>> enharmonic = spelled.convert_to(EnharmonicPitch)
>>> type(enharmonic)
<class 'pitchtypes.datatypes.EnharmonicPitch'>
>>> enharmonic.midi
61
>>> enharmonic.name('sharp')
C#4
>>> enharmonic.name('flat')
Db4
And used continuous log-frequency space (assuming twelve-tone equal temperament for enharmonic pitch):
>>> from pitchtypes import EnharmonicPitch, LogFreqPitch
>>> enharmonic = EnharmonicPitch("A4")
>>> logfreq = enharmonic.convert_to(LogFreqPitch)
>>> logfreq
440.Hz
For more examples, have a look at the Tutorial.ipynb!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pitchtypes-0.1.0.tar.gz
(10.8 kB
view hashes)
Built Distribution
pitchtypes-0.1.0-py3-none-any.whl
(22.3 kB
view hashes)
Close
Hashes for pitchtypes-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64f9d01f47658c702067844d2ea23e6fe1de9a7c893f21067653ce1ce3c2f9bf |
|
MD5 | a043d2629dadb82df5381c1d582a3de5 |
|
BLAKE2b-256 | 3caf6c4a4cedd4c960189d78e453532fdd864d15ce1f2bcbaba31adae1ac20c2 |