Skip to main content

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}')
"C4" has MIDI pitch 60

>>> print(f'"{note.name}" is in octave {note.octave}, and has a value of {note.interval_above_c}')
"C4" is in octave 4, and has a value of 0

>>> print(f'"{note.name}" has a frequency of {note.frequency}Hz')
"C4" has a frequency of 261.626Hz

>>> frequency = 444.4
>>> note = Note(frequency)
>>> print(f'"{note.name}" with a frequency of {note.frequency}Hz is closest to {frequency}Hz')
"A4" with a frequency of 440.0Hz is closest to 444.4Hz

Sharps and Flats

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}"')
MIDI pitch 75 is "D#5"

>>> note.prefer_flats = True
>>> print(f'MIDI pitch {note.pitch} is also "{note.name}"')
MIDI pitch 75 is also "Eb5"

Incidentals styles

You can also choose how to render incidentals:

>>> note = Note('D#5')

>>> note.incidentals_style = Note.INCIDENTAL_ASCII
>>> print(f'INCIDENTAL_ASCII: "{note.name}"')
INCIDENTAL_ASCII: "Eb5"

>>> note.incidentals_style = Note.INCIDENTAL_UNICODE
>>> print(f'INCIDENTAL_UNICODE: "{note.name}"')
INCIDENTAL_UNICODE: "E♭5"

>>> note.incidentals_style = Note.INCIDENTAL_NAMES
>>> print(f'INCIDENTAL_NAMES: "{note.name}"')
INCIDENTAL_NAMES: "E flat 5"

Constants

The following constants are defined:

MIDDLE_C

CHAR_FLAT
CHAR_FLAT_ASCII
CHAR_FLAT_UNICODE
CHAR_SHARP
CHAR_SHARP_ASCII
CHAR_SHARP_UNICODE

NOTE_TABLE
NOTE_NAMES
NOTE_PITCHES
NOTE_FREQUENCIES
NOTE_OFFSETS
NOTE_NAME_SHARPS
NOTE_NAME_FLATS

MAJOR_SCALE_INTERVALS
MINOR_SCALE_INTERVALS
COMMON_MAJOR_KEYS
MAJOR_SCALES
COMMON_MINOR_KEYS
MINOR_SCALES

DURATION_NAMES
DURATION_SYMBOLS
DURATION_FRACTIONS

MIDI_NOTE_OFF
MIDI_NOTE_ON
MIDI_POLY_PRESSURE
MIDI_CONTROL_CHANGE
MIDI_PROGRAM_SELECT
MIDI_PRESSURE
MIDI_PITCH_BEND
MIDI_PROGRAM_NAMES

MIDI_DRUM_IDS
MIDI_DRUM_PITCHES
MIDI_DRUM_NAMES

Metadata

Release files for midi-notes 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for midi-notes 1.3.1
File Size Uploaded Provenance
midi_notes-1.3.1.tar.gz 22.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for midi-notes 1.3.1
File Interpreter ABI Platform
midi_notes-1.3.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 46.0 kB

Release files / midi_notes-1.3.1.tar.gz

Download URL midi_notes-1.3.1.tar.gz
Size 22.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4ff4856606ea9ad86e0a68cc10d90a2913a86453c7eb96e129358bc2785c62d1
BLAKE2b-256 checksum
How to use checksums
eb5a7ae6adbc9fcc3814e7ba296bf918dcccb7a3e33855b44672ebf5ccdbf6c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / midi_notes-1.3.1-py2.py3-none-any.whl

Download URL midi_notes-1.3.1-py2.py3-none-any.whl
Size 23.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
22a890483723dda7188c9db232efc8abf750f3c62a61068f9ad4543c55e88055
BLAKE2b-256 checksum
How to use checksums
0e596c024ce7728a197b004af5cfda891e9ba6cf52f90671457a2fa730640e0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for midi-notes 1.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page