Giter Club home page Giter Club logo

akkorder's Introduction

Akkorder

Akkorder is a Typescript port of the C++ implementation of the chord recognition algorithm first described in the conference paper:

  • "Real-Time Chord Recognition For Live Performance", A. M. Stark and M. D. Plumbley. In Proceedings of the 2009 International Computer Music Conference (ICMC 2009), Montreal, Canada, 16-21 August 2009."

And expanded upon in Adam Stark's PhD Thesis:

  • "Musicians and Machines: Bridging the Semantic Gap in Live Performance", A. M. Stark, PhD Thesis, Queen Mary, University of London, 2011.

The original implementation can be found here.

Note: This port is not meant to be efficient, i was just in need of a chord detection algorithm that could be used in the browser.

Usage - Custom API

The detectChords function is not a part of the original library, it was added to to the port for my specific needs. The function performs the chord detection algorithm on the array containing the sound data. The frame size will be equal to the sampling frequency.The number of chords returned will be approximately equal to the number of seconds in the audio track.

import { detectChords } from "akkorder";

let audioBuffer = ...; //Get audio buffer from a source

let chords = detectChords(audioBuffer);
//Do something with chords
chords.map((chord) => {
    console.log(chord);
});

Usage - Original API

These are the instructions ported from the original repo.

Chromagram Estimation

1 - Import the Chromagram class

import { Chromagram } from "akkorder";

2 - Instantiate the algorithm, specifying the audio frame size and sample rate:

let frameSize = 512;
let sampleRate = 44100;

c = new Chromagram(frameSize,sampleRate); 

3 - In the processing loop, fill an array with one frame of audio samples and process it:

let frame = new Array(frameSize); 
// !
// do something here to fill the frame with audio samples
// !
//and then call:

c.processAudioFrame (frame);

4 - Getting The Chromagram

// The algorithm requires a fair bit of audio to calculate the chromagram, 
// so calculating it at every audio frame of (for example) 512 samples may be unnecessary (and take up lots of CPU cycles).
// After calling `processAudioFrame()` (see step 3), simply call:
if (c.isReady()){
    let chroma = c.getChromagram();
    // do something with the chromagram here
}

Setting Parameters

You can set a number of parameters for the algorithm. These include:

  • The audio frame size:
c.setInputAudioFrameSize(512);
  • The sampling frequency:
c.setSamplingFrequency(44100);
  • The interval at which the chromagram is calculated (specified in audio samples at the sampling frequency that the algorithm has been initialised with - the default is 8192):
c.setChromaCalculationInterval(8192);

Chord Detection

1 - Import the ChordDetector class

import { ChordDetector } from "akkorder";

2 - Instantiate the ChordDetector:

let chordDetector = new ChordDetector();

3 - Fill an array of length 12 with chromagram values (perhaps estimated from audio, using the Chromagram class) and call the detectChord method of ChordDetector class:

let chroma = new Array(12);
// !
// fill with chromagram values here
// !

// Then call the detectChord method
chordDetector.detectChord (chroma);

4 - You can then get the root note, chord quality (major, minor, etc) and any other intervals via:

chordDetector.rootNote
chordDetector.quality
chordDetector.intervals

akkorder's People

Contributors

stackswithans avatar

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.