Various tables (dicts) and functions for converting between note names, midi
Project description
midi_notes
Provides various tables (dicts) and functions for looking up / converting note names, scales, midi note pitch, frequencies, an a "Note" class which allows you constuct / represent Notes by MIDI pitch, note name or frequency.
Note class
You can construct a Note with either a (str) note name, (int) midi pitch, or (float) frequency.
from midi_notes import *
note = Note('C4')
print(f'"{note.name}" has midi pitch {note.pitch}')
print(f'"{note.name}" is in octave {note.octave}, and has a value of {note.interval_above_c}')
print(f'"{note.name}" has a frequency of {note.frequency}Hz')
frequency = 444.4
note = Note(frequency)
print(f'"{note.name}" with a frequency of {note.frequency}Hz is closest to {frequency}Hz')
... prints:
"C4" has MIDI pitch 60
"C4" is in octave 4, and has a value of 0
"C4" has a frequency of 261.626Hz
"A4" with a frequency of 440.0Hz is closest to 444.4Hz
When getting the "name" property of a Note which is an incidental, you can decide whether to retrieve the "sharp" or "flat" version of the note name ("D♯" is the same pitch as "E♭") by setting the "prefer_flats" property.
note = Note('D#5')
print(f'MIDI pitch {note.pitch} is "{note.name}"')
note.prefer_flats = True
print(f'MIDI pitch {note.pitch} is also "{note.name}"')
... prints:
MIDI pitch 75 is "D#5"
MIDI pitch 75 is also "Eb5"
You can also choose how to render incidentals:
note = Note('D#5')
note.incidentals_style = Note.INCIDENTAL_ASCII
print(f'INCIDENTAL_ASCII: "{note.name}"')
note.incidentals_style = Note.INCIDENTAL_UNICODE
print(f'INCIDENTAL_UNICODE: "{note.name}"')
note.incidentals_style = Note.INCIDENTAL_NAMES
print(f'INCIDENTAL_NAMES: "{note.name}"')
... prints:
INCIDENTAL_ASCII: "Eb5"
INCIDENTAL_UNICODE: "E♭5"
INCIDENTAL_NAMES: "E flat 5"
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file midi_notes-1.0.1.tar.gz.
File metadata
- Download URL: midi_notes-1.0.1.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b31f7e547b2c81f93d27d53ab3ecef8db3f024c9f38023facb3dee31f78d0cf
|
|
| MD5 |
f25f05e9621a790e03aa066b8b655508
|
|
| BLAKE2b-256 |
b145afa12af56258ec8016706dfa56bb48ebcdd6c4400d75ee44a514444ed836
|
File details
Details for the file midi_notes-1.0.1-py2.py3-none-any.whl.
File metadata
- Download URL: midi_notes-1.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54c8e5ba3a4f9686ae0674e107a6b82520d256d655e979ed43fe736510212d61
|
|
| MD5 |
077ce0234caff8baa6b1504e68de404b
|
|
| BLAKE2b-256 |
db700d4deeb689552e111458bbdf37edbb0ca5505be59dd8715ad01f63d9188e
|