Code Monkey home page Code Monkey logo

justkeydding's Introduction

For v2.0.0 of justkeydding, I am planning to move entirely to Python. The main advantage is that I will be able to use the deepchroma features from madmom, which seem to deliver better results than NNLS-Chroma. Another feature in mind (WIP) is the annotation of a MusicXML|krn|MIDI file in symbolic. The code should be able to deliver an aligned-and-annotated file back (local keys as lyrics, global key annotated somewhere in the metadata) as well as the individual features. This will be released as a python package in PyPI (pip). Expected release is May 2020. Development of that new direction is happening in the pythononly branch, if you are interested in checking that code.

justkeydding

Audio and Symbolic Key Detection algorithm based on nnls-chroma and a Hidden Markov Model.

About the project

This project is the extension of a previous symbolic key detection algorithm. The original algorithm required a sequence of pitch-classes that can be easily obtained from a symbolic music file. The old project has now been integrated in this repository to deal with both, symbolic and audio files. In the audio version, the pitch-classes are obtained from chromagrams. At this moment, the algorithm supports midi, wav, and csv input files. The supported csv consist of a chromagram file as given by the Sonic Annotator program using the nnls-chroma Vamp plugin developed by Matthias Mauch and Chris Cannam.

During 2019, a few experiments showed that different key profiles worked for different types of music and different datasets, therefore, I started using the predictions from different key profiles with a meta-classifier algorithm that figured out keys better than individual key profiles did. This was also a way to train the model, as the original HMM model did not require any training from the data (and nevertheless had a good performance in MIREX ;), it was assumed that the key profiles provided the training aspect of pitch-class distributions in all keys. The current version of the model uses the ensemble method, it is slower, but hopefully, way more accurate.

Building from source

Vagrantfile

So far, this project has only been compiled and run in a virtualized Linux environment, more specifically, a Vagrant box of Ubuntu-18.04 x64. Compilation and execution in a native environment of that OS should be straighforward. I provide a simple Vagrantfile that launches the corresponding Vagrant box and installs the necessary packages to the system. We assume that Vagrant will be used to compile the project.

Cloning the repo

The project has submodules, so cloning recursively (adding the --recursive flag) is recommended:

git clone https://github.com/napulen/justkeydding.git --recursive
cd justkeydding

Launching the Vagrant box

Inside the repository, we can launch the Vagrant box

vagrant up

This takes a while, it will download the Ubuntu image (if you don't have it), spawn the vm, and compile the code. Once it finishes, the virtual machine should be running, we can then log to it

vagrant ssh

Running full algorithm

Inside the virtual machine, the repository's folder has been mounted as a shared folder in /vagrant. Go there.

cd /vagrant

Run the full algorithm (including the meta-classifier) with

./justkeydding <input_file> <output_file>

The output_file is where the key is going to be stored.

Running individual HMM

If you are interested in running the individual HMM, that is the binary located at bin/justkeydding. This program supports a few optional arguments, but in its most basic usage, it only requires an input midi|audio|chromagram_csv file as a command line argument.

bin/justkeydding <audio_filename>.wav

Acknowledgments

Thanks to Claire Arthur for providing a dataset for testing the performance of this algorithm.

justkeydding's People

Contributors

napulen avatar

Stargazers

Baby King avatar Matt avatar Fabian C. Moss avatar Paul H. avatar Robert Hodgson avatar  avatar Steven Cobb avatar Synchromatic avatar Bertrand Ndobegang Atemkeng avatar  avatar  avatar Priyatna Harun avatar  avatar Chris Ladd avatar Emily Hopkins avatar

Watchers

 avatar Claire Arthur avatar  avatar

justkeydding's Issues

Add the "annotate file" functionality

  • Add an additional arg to the cli, --annotate
  • This option should return the same input file, except that it has annotations at every slice
  • For audio inputs, either ignore or figure out something

Onset detection before chroma in audio

Use the onset detection processors in madmom to reduce the number of audio frames whose chromagrams will be analyzed. This will likely improve the speed and accuracy of the audio key estimation.

Normalize imports to main package

Some imports are relative, but they should all be with respect to the main package name (justkeydding). This is going to be important when doing a pip package.

Move hmm data structures from the main script

These guys

states = (
    'C', 'Db', 'D', 'Eb', 'E', 'F', 'F#', 'G', 'Ab', 'A', 'Bb', 'B',
    'c', 'c#', 'd', 'eb', 'e', 'f', 'f#', 'g', 'ab', 'a', 'bb', 'b',
)

enharmonics = {
    'Db': 'C#', 'Eb': 'D#', 'F#': 'Gb', 'Ab': 'G#', 'Bb': 'A#',
    'c#': 'db', 'eb': 'd#', 'f#': 'gb', 'ab': 'g#', 'bb': 'a#',
}

start_p = {
    'C': 1.0/24.0, 'Db': 1.0/24.0, 'D': 1.0/24.0, 'Eb': 1.0/24.0,
    'E': 1.0/24.0, 'F': 1.0/24.0, 'F#': 1.0/24.0, 'G': 1.0/24.0,
    'Ab': 1.0/24.0, 'A': 1.0/24.0, 'Bb': 1.0/24.0, 'B': 1.0/24.0,
    'c': 1.0/24.0, 'c#': 1.0/24.0, 'd': 1.0/24.0, 'eb': 1.0/24.0,
    'e': 1.0/24.0, 'f': 1.0/24.0, 'f#': 1.0/24.0, 'g': 1.0/24.0,
    'ab': 1.0/24.0, 'a': 1.0/24.0, 'bb': 1.0/24.0, 'b': 1.0/24.0,
}

Would fit better in the parameters module, or somewhere else.

Add dependencies to setup.py

The code requires madmom, mido, and music21 (among other packages).

These dependencies should be stated in the pypi package.

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.