npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

chord-recognition

v1.0.7

Published

based on Akkorder project and 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 o

Downloads

29

Readme

Chord recognition

based on Akkorder project and 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