Skip to main content

pitchtools provides a set of functions to work with musical pitches.

Features

  • convert between frequencies, midinotes and notenames

  • microtones are fully supported

  • split a pitch into its multiple components (pitch class, octave, microtonal deviation, etc.)

  • transpose a pitch taking its spelling into consideration

  • create custom pitch converters to work with custom reference frequencies, or modify the reference frequency globally

Documentation

https://pitchtools.readthedocs.io/en/latest/

Examples

Convert some note names to frequencies

>>> from pitchtools import *
>>> eflat_scale = "4Eb 4F 4G 4Ab 4Bb 5C 5D".split()
>>> for note in eflat_scale:
...     # convert notename to frequency using the default reference frequency (442 Hz)
...     freq = n2f(note)
...     # convert frequency to midi
...     midinote = f2m(freq)
...     print(f"{note} = {freq:.1f}Hz (midi = {midinote})")
4Eb = 312.5 Hz (midi = 63.0)
4F  = 350.8 Hz (midi = 65.0)
4G  = 393.7 Hz (midi = 67.0)
4Ab = 417.2 Hz (midi = 68.0)
4Bb = 468.3 Hz (midi = 70.0)
5C  = 525.6 Hz (midi = 72.0)
5D  = 590.0 Hz (midi = 74.0)

The same but with a different reference frequency

from pitchtools import *
ebscale = "4Eb 4F 4G 4Ab 4Bb 5C 5D".split()
cnv = PitchConverter(a4=435)
for note in ebscale:
    # Convert to frequency with default a4=442 Hz
    freq = cnv.n2f(note)
    midinote = cnv.[Of2m(freq)
    print(f"{note} = {freq} Hz (midinote = {midinote})")

Microtones

Microtones are fully supported, either as fractional midinotes or as notenames.

>>> from pitchtools import *
>>> n2m("4C+")
60.5
>>> n2m("4Db-10")
60.9
>>> m2n(61.2)
4C#+20

Microtonal notation

Midinote

Notename

60.25

4C+25 / 4C>

60.45

4C+45

60.5

4C

60.75

4Db-25

61.5

4D-

61.80

4D-20

63

4D#

63.5

4D#+

63.7

4E-30


Installation

pip install pitchtools

Release files for pitchtools 1.17.1

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

Source distribution (sdist)

Source distribution for pitchtools 1.17.1
File Size Uploaded
pitchtools-1.17.1.tar.gz 27.5 kB Details

Built distribution (wheel)

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

Total release size: 48.2 kB

Release files / pitchtools-1.17.1.tar.gz

Download URL pitchtools-1.17.1.tar.gz
Size 27.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2fdec54b909bb974f6c89cf4ca3fdb5087122f74be5aefe98b1df4322e302887
BLAKE2b-256 checksum
How to use checksums
c3dd29e5e6a07b146e3fc152dc682136f2ec2d563e9bce2b096c2d5b765e9e67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.22

Release files / pitchtools-1.17.1-py3-none-any.whl

Download URL pitchtools-1.17.1-py3-none-any.whl
Size 20.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43b18b842d01dcc40f89c604d5f71a73a1f5dfd26b48f214134b7d7871414c98
BLAKE2b-256 checksum
How to use checksums
73ad18db03289210ebfb5787cfd903ab96868206cb415501212ee0319c18f082
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.22

Release history Release notifications | RSS feed

This release

1.17.1 This release

2 release files

1.15.2

2 release files

1.15.1

2 release files

1.15.0

2 release files

1.14.0

1 release file

1.13.0

1 release file

1.12.0

1 release file

1.11.2

1 release file

1.11.1

2 release files

1.11.0

2 release files

1.9.3

2 release files

1.9.2

2 release files

1.9.1

1 release file

1.9.0

1 release file

1.8.0

1 release file

1.7.2

1 release file

1.7.1

1 release file

1.7.0

1 release file

1.6.1

1 release file

1.6

1 release file

1.5

1 release file

1.4

1 release file

1.3.0

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

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