Coder Social home page Coder Social logo

keyedin's Introduction

keyedin

Tool for distributional key-finding using Python.

Identifies the most likely key of a musical audio recording from among the major and minor diatonic scales. Approximates the audio's pitch class distribution using the constant-Q transform, and then provides a variety of classifiers for guessing its key based on this distribution.

Applications of automated key-finding range from computing metadata for music databases (which is extremely tedious to do by hand/ear) to making music producers' lives easier when they're working with samples.

[Note: The distributional view of tonality is well-known to be an incomplete picture of how the human auditory system identifies phenomena like 'key': It's an extreme abstraction which completely ignores structural information such as the order notes are heard in, which notes occur at the same time, etc. Despite this, in surprisingly many cases it allows for key-finding algorithms with acceptable accuracy. Google "distributional key-finding" or "pitch class distribution" for more info.]

Classifiers

Krumhansl-Schmuckler

Uses a method based on the Krumhansl-Schmuckler key-finding algorithm to find a 'best fit' to a pitch class distribution. Compares the distribution to the 'typical' distribution for each key by taking their Pearson correlation coefficient, and then takes the argmax over these.

Naive Bayes

Uses a Naive Bayes model wherein the audio's key is the class and the proportions of the audio made up by each note (i.e. the values of its pitch class distribution) are the features.

Others

Coming soon! The plan is to eventually include a classifier which uses a neural net (possibly just a multi-class perceptron), but first I need to figure out training data.

Example Usage

from keyedin import pitchdistribution as pd, classifiers

# Use naive Bayes classifier to guess the key of SongInGMajor.mp3
naive_bayes = classifiers.NaiveBayes()
dist = pd.PitchDistribution.from_file('path/to/SongInGMajor.mp3')
naive_bayes.get_key(dist) # Returns Key object Key('G', 'major')

# Use Krumhansl-Schmuckler classifier to guess the key of SongInBMinor.mp3
krumhansl_schmuckler = classifiers.KrumhanslSchmuckler()
dist = pd.PitchDistribution.from_file('path/to/SongInBMinor.mp3')
krumhansl_schmuckler.get_key(dist) # Returns Key object Key('B', 'minor')

# After key identification, tonal center and scale of keys are available through Key.get_tonic() and Key.get_scale()
k = pd.Key('F', 'major')
k.get_tonic() # Returns string 'F'
k.get_scale() # Returns string 'major'

Dependencies

  • KeyedIn uses Librosa for its constant-Q transform implementation, which is required for Keyedin to work on any audio input. An installation guide for Librosa can be found here.

  • KeyedIn also uses NumPy for essential functions, so you'll need it too. Installation info for NumPy can be found here.

keyedin's People

Contributors

zwaltman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ashbt

keyedin's Issues

no setup.py

The current package doesn't seem to have a setup.py file and requires manual installation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.