All Projects → killercrush → music-tempo

killercrush / music-tempo

Licence: MIT license
Finding out tempo of the music

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to music-tempo

vamp-aubio-plugins
aubio plugins for Vamp
Stars: ✭ 38 (-61.62%)
Mutual labels:  beat, tempo
pd-aubio
aubio external for PureData
Stars: ✭ 20 (-79.8%)
Mutual labels:  beat, tempo
libfmp
libfmp - Python package for teaching and learning Fundamentals of Music Processing (FMP)
Stars: ✭ 71 (-28.28%)
Mutual labels:  beat, tempo
canon-generator
Create and visualize temporal canons a'la Conlon Nancarrow
Stars: ✭ 31 (-68.69%)
Mutual labels:  rhythm, tempo
tutorial
Tutorial on Tempo, Beat and Downbeat estimation
Stars: ✭ 44 (-55.56%)
Mutual labels:  beat, tempo
drum-machine-patterns
Transcription of the book 200 Drum machine patterns by René-Pierre Bardet
Stars: ✭ 49 (-50.51%)
Mutual labels:  rhythm
micronaut-camunda-external-client
This open source project allows you to easily integrate Camunda's External Task Clients into Micronaut projects: simply add a dependency in your Micronaut project
Stars: ✭ 19 (-80.81%)
Mutual labels:  bpm
RhythmHeavenMania
(WIP) Fully playable, open source recreation of every Rhythm Heaven minigame with a built in level editor.
Stars: ✭ 45 (-54.55%)
Mutual labels:  rhythm
Flor
a workflow engine
Stars: ✭ 190 (+91.92%)
Mutual labels:  bpm
Simod
Simod is a tool for automated BPS model discovery
Stars: ✭ 24 (-75.76%)
Mutual labels:  bpm
activiti-examples
Alfresco Process Services powered by Activiti Examples.
Stars: ✭ 58 (-41.41%)
Mutual labels:  bpm
Osu
rhythm is just a *click* away!
Stars: ✭ 8,573 (+8559.6%)
Mutual labels:  rhythm
clap-detection
Simple clap rhythm detection on Raspberry Pi using Csound and Python. Toy example.
Stars: ✭ 29 (-70.71%)
Mutual labels:  rhythm
activiti-examples
This repository contains Activiti 7.x Examples
Stars: ✭ 367 (+270.71%)
Mutual labels:  bpm
HitNotes
Rhythm-based mobile game
Stars: ✭ 24 (-75.76%)
Mutual labels:  rhythm
tempo-cnn
Framework for estimating temporal properties of music tracks.
Stars: ✭ 62 (-37.37%)
Mutual labels:  tempo
MIDI-MUG
Play music game with MIDI keyboard!
Stars: ✭ 14 (-85.86%)
Mutual labels:  rhythm
awesome-camunda
a curated list of awesome Camunda BPM projects, libraries, tools, documentations, forum posts, etc.
Stars: ✭ 93 (-6.06%)
Mutual labels:  bpm
total-serialism
Toolbox full of Algorithmic Composition methods
Stars: ✭ 74 (-25.25%)
Mutual labels:  rhythm
DeepECG
Using deep learning to detect Atrial fibrillation
Stars: ✭ 25 (-74.75%)
Mutual labels:  rhythm

Description

Javascript-library for finding out tempo (BPM) of a song and beat tracking. It uses an algorithm "Beatroot" authored by Simon Dixon

Example App

Docs

Instalation

In a browser

<script src="music-tempo.min.js"></script>

Using npm:

$ npm i --save music-tempo

Usage

Pass to the constructor MusicTempo the buffer that contains data in the following format: non-interleaved IEEE754 32-bit linear PCM with a nominal range between -1 and +1, that is, 32bits floating point buffer, with each samples between -1.0 and 1.0. This format is used in the AudioBuffer interface of Web Audio API. The object returned by the constructor contain properties tempo - tempo value in beats per minute and beats - array with beat times in seconds.

Browser

var context = new AudioContext({ sampleRate: 44100 });
var fileInput = document.getElementById("fileInput");

fileInput.onchange = function () {
  var files = fileInput.files;

  if (files.length == 0) return;
  var reader = new FileReader();

  reader.onload = function(fileEvent) {
    context.decodeAudioData(fileEvent.target.result, calcTempo);
  }

  reader.readAsArrayBuffer(files[0]);
}
var calcTempo = function (buffer) {
  var audioData = [];
  // Take the average of the two channels
  if (buffer.numberOfChannels == 2) {
    var channel1Data = buffer.getChannelData(0);
    var channel2Data = buffer.getChannelData(1);
    var length = channel1Data.length;
    for (var i = 0; i < length; i++) {
      audioData[i] = (channel1Data[i] + channel2Data[i]) / 2;
    }
  } else {
    audioData = buffer.getChannelData(0);
  }
  var mt = new MusicTempo(audioData);

  console.log(mt.tempo);
  console.log(mt.beats);
}

Node.js

In Node.js environment can be used node-web-audio-api library

var AudioContext = require("web-audio-api").AudioContext;
var MusicTempo = require("music-tempo");
var fs = require("fs");

var calcTempo = function (buffer) {
  var audioData = [];
  // Take the average of the two channels
  if (buffer.numberOfChannels == 2) {
    var channel1Data = buffer.getChannelData(0);
    var channel2Data = buffer.getChannelData(1);
    var length = channel1Data.length;
    for (var i = 0; i < length; i++) {
      audioData[i] = (channel1Data[i] + channel2Data[i]) / 2;
    }
  } else {
    audioData = buffer.getChannelData(0);
  }
  var mt = new MusicTempo(audioData);

  console.log(mt.tempo);
  console.log(mt.beats);
}

var data = fs.readFileSync("songname.mp3");

var context = new AudioContext();
context.decodeAudioData(data, calcTempo);

Optional parameters

You can pass object with parameters as second argument to the constructor:

var p = { expiryTime: 30, maxBeatInterval: 1.5 };
var mt = new MusicTempo(audioData, p);

Most useful are maxBeatInterval/minBeatInterval and expiryTime. First two used for setting up maximum and minimum BPM. Default value for maxBeatInterval is 1 which means that minimum BPM is 60 (60 / 1 = 60). Default value for minBeatInterval is 0.3 which means that maximum BPM is 200 (60 / 0.3 = 200). Be careful, the more value of maximum BPM, the more probability of 2x-BPM errors (e.g. if max BPM = 210 and real tempo of a song 102 BPM, in the end you can get 204 BPM). expiryTime can be used if audio file have periods of silence or almost silence and because of that beat tracking is failing. Other parameters are listed in documentation.

Other

Tests

Requires mocha and chai

$ npm test

Documentation

Requires esdoc

$ esdoc

Build

Requires gulp and babel. Other dependencies can be found in package.json

$ gulp build

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].