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.1.tar.gz (6.2 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.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aeberscale-0.1.1.tar.gz
  • Upload date:
  • Size: 6.2 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.1.tar.gz
Algorithm Hash digest
SHA256 213e4473bd06f0c9eb685b13a970df4833f4d36c4a2aa59225a115be5d23d6a8
MD5 f036b859a15ff1a4525a4d4de4380921
BLAKE2b-256 ccc016cfcac3695af88b475e46149959bef833dd7bc98d0ab8ce37f58c373a1c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aeberscale-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a62b86c72320adffe9ae385f422975ee253b42117a2e9280d3ccd5563559ec3
MD5 a1b87ea615e712ec573f185b40480e52
BLAKE2b-256 48910918920a7ac846e37be3d2f1ba10112b635ba3d008cedfbd528d95bf6b07

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