Skip to main content

Utilities to convert between midinotes, frequency and notenames

Project description

This module provides a set of functions to work with musical pitch. It enables to convert between frequenies, midinotes and notenames

Pitchtools

This module provides a set of functions to work with musical pitch. It enables to convert between frequenies, midinotes and notenames

Examples

Convert some note names to frequencies

>>> from pitchtools import *
>>> ebscale = "4Eb 4F 4G 4Ab 4Bb 5C 5D".split()
>>> for note in ebscale:
...     freq = n2f(note)
...     midinote = f2m(freq)
...     print(f"{note} = {freq:.1f}Hz (midinote = {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 = Converter(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

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

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

pitchtools-1.2.0.tar.gz (12.0 kB view details)

Uploaded Source

File details

Details for the file pitchtools-1.2.0.tar.gz.

File metadata

  • Download URL: pitchtools-1.2.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5

File hashes

Hashes for pitchtools-1.2.0.tar.gz
Algorithm Hash digest
SHA256 3303947eed89dd7ca1fbc9465451f5d3adbdeeab5e1a084338ff329260015d44
MD5 0af2cebd54d46571cd242f69c127bb33
BLAKE2b-256 8e04eb8e2854da5b941a7ca831eaa2b870d140097e4a406c8e7ad3133afd520d

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