Skip to main content

A simple key-finding algorithm designed for jazz

Project description

AeberScale

AeberScale is a scale finding algorithm that modifies the famous Krumhansl-Schmuckler key-finding algorithm for jazz music. In particular, rather than using solely major or minor key profiles, we adapt the scales from the (equally famous!) Jamey Aebersold Scale Syllabus. This syllabus is perhaps best known to musicians for its inclusion in copies of the Charlie Parker Omnibook (check the back page!).

Usage

AeberScale is an extremely simple package that has no external dependencies. It relies on you providing it a set of pitch classes and their corresponding durations. It is up to you how you extract this information, so you might find it handy to use a package like pretty-midi or music21, depending on what sort of input you are using.

Once you have this information, you can use aeberscale.find_key to estimate the key:

from pretty_midi import PrettyMIDI
from aeberscale import find_scale

# Extract notes and durations from MIDI file
pm = PrettyMIDI("path/to/a/midi/file")
nots = [p.pitch for p in pm.instruments[0].notes]
durs = [p.duration for p in pm.instruments[0].notes]

# grab the scale with aeberscale
out = find_scale(nots, durs)
print(out)
>>> "F major"

Note that the returned object from find_scale is an instance of a subclass aeberscale.Scale. This provides some useful helper properties and methods:

print(out.notes)
>>> ["F", "G", "A", "A#", "C", "D", "E"]

print(out.note_numbers)
>>> [5, 7, 9, 10, 0, 2, 4]

print(out.family)
>>> "major"

You can also easily convert from note names or chromatic scale steps to diatonic scale steps (useful in, e.g., $n$-gram extraction and computation). Notes that are not contained within the current key will be returned as None:

ss = ["C", "D", "Eb", "F", "D", "Bb", "C"]
dia = out.notes_to_diatonic_scale_steps(ss)

print(dia)
>>> [5, 6, None, 0, 6, 4, 5]

Installation

Easy:

pip install aeberscale

To run the tests:

git clone https://github.com/HuwCheston/aeberscale.git
cd aeberscale
pytest tests

Algorithm

The process is as follows:

  • For provided notes, obtain a histogram of summed pitch-class durations (e.g., note 5 held for X seconds, note 6 held for Y...)
  • For all scales in the Jamey Aebersold syllabus and all possible root notes, obtain a binary distribution (key profile)
    • Where 1 == PC contained in scale, 0 == not (and PC \in {0, 1, 2, ..., 11})
  • Compute the maximum possible correlation coefficient between the provided input and all scale/root note combinations

For more information on the Krumhansl-Schmuckler algorithm, check out this paper. Note that the only difference between the original implementation and AeberScale is that we use a binary distribution for the key profiles, rather than obtaining these through perceptual experiments.

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

aeberscale-0.1.2.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

aeberscale-0.1.2-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file aeberscale-0.1.2.tar.gz.

File metadata

  • Download URL: aeberscale-0.1.2.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for aeberscale-0.1.2.tar.gz
Algorithm Hash digest
SHA256 0a7b8ffb66b1254b1be00798b1960b5cb01b820d3dc22cac6f0b964de639c08f
MD5 c7d7143591eac0a5c32e6d0b99a59549
BLAKE2b-256 1619f60db096a98e29838d7d75b6394e3b2d0037a21c0d1c438d8c9dd2e561f2

See more details on using hashes here.

File details

Details for the file aeberscale-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: aeberscale-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for aeberscale-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7078cd641e742a090f7ad165c8652cdc60edf17335aab073e6ffd9dcf785dd57
MD5 31410dd15d73e26da91cb2f2b9ba2b1e
BLAKE2b-256 a8048741dce80df47007b9a17587ffe9fac4f2a6951a684282df3f80427ec9a3

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