Skip to main content

An elegant library for representing pitch in Western music.

Project description

Table of Contents

Meantonal

Meantonal is a specification for representing pitch information in Western music, and a suite of tools for operating on this information. It's a small, focused library that aims to empower developers to build musical apps more easily.

Meantonal is:

  • Flexible with I/O: easily ingest and translate between Scientific Pitch Notation, Helmholtz notation, ABC and Lilypond. Extract MIDI values at any time.
  • Semantically nondestructive: the distinction between enharmonic notes such as C♯ and D♭ is maintained. Things that don't behave the same way musically are not encoded the same way in Meantonal.
  • Just vectors: under the hood pitches and intervals are 2d vectors. Operations are simple to understand, surprisingly powerful, and fast to execute.
  • Tuning-agnostic: Target any meantone tuning system, not just 12-tone equal temperament. You want 31 tones per octave? Done.

For the JS/TS implementation of Meantonal click here, or for the C implementation click here.

Installation

Adding Meantonal to your project is as simple as running:

pip install meantonal

You're now ready to import and use Meantonal's classes.

from meantonal import SPN, Helmholtz, Interval, TonalContext, MirrorAxis

p = SPN.to_pitch("C4")
q = Helmholtz.to_pitch("e'")

m = p.interval_to(q)  # M3
n = Interval.from_name("M3")

m.is_equal(n)  # True

context = TonalContext.from_strings("Eb", "major")

q = q.snap_to(context)  # q has now snapped to Eb4

axis = MirrorAxis.from_spn("D4", "A4")

q = q.invert(axis)  # q is now G#4

Since pitches and intervals are just vectors, the Python implementation also supports natural arithmetic on them, in the style of datetime/timedelta:

from meantonal import SPN, Interval

p = SPN.to_pitch("C4")
m = Interval.from_name("M3")

q = p + m       # E4 -- same as p.transpose_real(m)
q - p           # M3 -- same as Interval.between(p, q)
p - m           # Ab3 -- transpose down
m + m           # A5 (augmented 5th) -- same as m.add(m)
-m              # descending M3 -- same as m.negative
m * 3           # A7 -- same as m.times(3)

Documentation

A full reference of the Python implementation of Meantonal can be found here

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

meantonal-0.13.0.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

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

meantonal-0.13.0-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file meantonal-0.13.0.tar.gz.

File metadata

  • Download URL: meantonal-0.13.0.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for meantonal-0.13.0.tar.gz
Algorithm Hash digest
SHA256 1579883d461f37f80e7e9ca4c129ce7db0735d3a305313aaae16c8e8d211511f
MD5 6e30de6738c9e77c01c80006be79f5ab
BLAKE2b-256 c5be823f5f075cd8faef3bf5bcbce647c970a5eca82b3fb66b71503af9a97bb2

See more details on using hashes here.

File details

Details for the file meantonal-0.13.0-py3-none-any.whl.

File metadata

  • Download URL: meantonal-0.13.0-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for meantonal-0.13.0-py3-none-any.whl
Algorithm Hash digest
SHA256 32195f10163b9b7bf964a16194e7411ed00cfea02fc72db2dcdbc35ee426a16c
MD5 4bf775b7a170b8f071524732dbb21051
BLAKE2b-256 c950a5283b7d92c233bc34af91d03fa74ad4593944f06ec9e8de3daca85488ec

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