Skip to main content

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.

Metadata

Release files for aeberscale 0.1.2

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

Source distribution (sdist)

Source distribution for aeberscale 0.1.2
File Size Uploaded
aeberscale-0.1.2.tar.gz 10.4 kB Details

Built distribution (wheel)

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

Total release size: 21.2 kB

Release files / aeberscale-0.1.2.tar.gz

Download URL aeberscale-0.1.2.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0a7b8ffb66b1254b1be00798b1960b5cb01b820d3dc22cac6f0b964de639c08f
BLAKE2b-256 checksum
How to use checksums
1619f60db096a98e29838d7d75b6394e3b2d0037a21c0d1c438d8c9dd2e561f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.0

Release files / aeberscale-0.1.2-py3-none-any.whl

Download URL aeberscale-0.1.2-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7078cd641e742a090f7ad165c8652cdc60edf17335aab073e6ffd9dcf785dd57
BLAKE2b-256 checksum
How to use checksums
a8048741dce80df47007b9a17587ffe9fac4f2a6951a684282df3f80427ec9a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.0

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

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