Skip to main content

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

Metadata

Release files for meantonal 0.13.0

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

Source distribution (sdist)

Source distribution for meantonal 0.13.0
File Size Uploaded
meantonal-0.13.0.tar.gz 20.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for meantonal 0.13.0
File Interpreter ABI Platform
meantonal-0.13.0-py3-none-any.whl Python 3 none any Details

Total release size: 41.4 kB

Release files / meantonal-0.13.0.tar.gz

Download URL meantonal-0.13.0.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1579883d461f37f80e7e9ca4c129ce7db0735d3a305313aaae16c8e8d211511f
BLAKE2b-256 checksum
How to use checksums
c5be823f5f075cd8faef3bf5bcbce647c970a5eca82b3fb66b71503af9a97bb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / meantonal-0.13.0-py3-none-any.whl

Download URL meantonal-0.13.0-py3-none-any.whl
Size 20.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32195f10163b9b7bf964a16194e7411ed00cfea02fc72db2dcdbc35ee426a16c
BLAKE2b-256 checksum
How to use checksums
c950a5283b7d92c233bc34af91d03fa74ad4593944f06ec9e8de3daca85488ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release history Release notifications | RSS feed

This release

0.13.0 This release

2 release 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