Skip to main content

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}')
"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

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

midi_notes-1.0.3.tar.gz (21.0 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.0.3-py2.py3-none-any.whl (21.3 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: midi_notes-1.0.3.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for midi_notes-1.0.3.tar.gz
Algorithm Hash digest
SHA256 b3b49df0048d89b4d5febc2303fd5c9da1145dc00ae5545412c11722db561bcc
MD5 fd6f9b9546f1ececffaa40f6d55ba705
BLAKE2b-256 aee285e6be60ceaae7866181547dcffa1e86a01bf77ffef450d0bcec4789b6a3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: midi_notes-1.0.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for midi_notes-1.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7ccd5560b3d07f75e6cfb147fffd49b8cc35a64122d87b531158143097b88a69
MD5 a3d83e217c2f4697a4e31465323748dc
BLAKE2b-256 0ab468fe68446884bd2f122ec03e4c07c7a481af157becc9432e7db49b9c179d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page