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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

midi_notes-1.3.1.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

midi_notes-1.3.1-py2.py3-none-any.whl (23.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file midi_notes-1.3.1.tar.gz.

File metadata

  • Download URL: midi_notes-1.3.1.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for midi_notes-1.3.1.tar.gz
Algorithm Hash digest
SHA256 4ff4856606ea9ad86e0a68cc10d90a2913a86453c7eb96e129358bc2785c62d1
MD5 0153e6269b2bdb8cf9706ed8dfea1c14
BLAKE2b-256 eb5a7ae6adbc9fcc3814e7ba296bf918dcccb7a3e33855b44672ebf5ccdbf6c7

See more details on using hashes here.

File details

Details for the file midi_notes-1.3.1-py2.py3-none-any.whl.

File metadata

  • Download URL: midi_notes-1.3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for midi_notes-1.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 22a890483723dda7188c9db232efc8abf750f3c62a61068f9ad4543c55e88055
MD5 b7a76ffa7a31932ec037c8cb213a99b1
BLAKE2b-256 0e596c024ce7728a197b004af5cfda891e9ba6cf52f90671457a2fa730640e0e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.3.1 This release

2 files

1.3.0

2 files

1.2.0

2 files

1.1.1

2 files

1.1.0

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

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