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.2.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.2-py2.py3-none-any.whl (21.3 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: midi_notes-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 69b4b7f5367001855c9c49cbbad11acf15b0a5ac573dcb44b24c53c54899abd2
MD5 d559862eddfb6b5524f167779a7f67c8
BLAKE2b-256 a7dd5e19af675679aa57c825358738f79eec47b0cedbf7350610e5d69ed4c148

See more details on using hashes here.

File details

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

File metadata

  • Download URL: midi_notes-1.0.2-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.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0b98097c3a25af91141cd8e3538b6ae973ccc68e4e0f3fc9d4c38a8480628d15
MD5 a5cad9b39602ddbf3411dcb334f20f32
BLAKE2b-256 c5bd1001dcc67c016442574bb7d55d9601a9a164e19fcb17e4094315c54dac1c

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