killercrush / music-tempo Goto Github PK
View Code? Open in Web Editor NEWFinding out tempo of the music
Home Page: https://killercrush.github.io/music-tempo
License: MIT License
Finding out tempo of the music
Home Page: https://killercrush.github.io/music-tempo
License: MIT License
For now I'm simply adding the duration from the audiobuffer, but I think it would be an interesting property to have as part of MusicTempo.
audioContext.decodeAudioData(fileEvent.target.result)
.then(audioBuffer => resolve({
...new MusicTempo(audioBuffer.getChannelData(0)),
duration: audioBuffer.duration,
}))
.catch(reject)
Hello,
I hope you don't mind answering a nerdy question.
In the paper linked in the readme it appears that Beatroot uses mean-absolute-peaks for onset detection, whereas I see music-tempo is using spectral flux.
I wondered whether there are any other developments on Dixon's algorithm at play in this library?
Thanks so much,
Joel
This is probably similar to #5 in that the bottom line is that I got the same number of beats, and even roughly at similar places, but the end result sounded horrible. (To debug it I recreated parts of your test page code with the ticker thing.)
But in this case I finally figured that something is off with web-audio-api
on node: once I repeated things in a browser, it finally worked as it should. For reference, I'm attaching the file with the beats for both.
Also, the code I used with node -- which didn't work (adding sampleRate
makes no difference) is:
const fs = require("fs");
const MusicTempo = require("music-tempo");
const AudioContext = require("web-audio-api").AudioContext;
const calcTempo = async file => {
const data = fs.readFileSync(file);
const buff = await new Promise((res,rej) => (new AudioContext()).decodeAudioData(data, res, rej));
const buf0 = buff.getChannelData(0);
const buf1 = buff.getChannelData(buff.numberOfChannels > 1 ? 1 : 0);
const audioData = buf0.map((n0, i) => (n0 + buf1[i])/2);
const mt = new MusicTempo(audioData);
console.log(mt.tempo);
console.log(mt.beats);
}
and in a browser:
fetch($player.src)
.then(x => x.arrayBuffer())
.then(x => (new AudioContext()).decodeAudioData(x))
.then(x => {
const c1 = x.getChannelData(0), c2 = x.getChannelData(1),
c = c1.map((x,i) => (x+c2[i])/2),
mt = new MusicTempo(c);
console.log(mt.beats);
});
Maybe there's some problem with w-a-a
, but I followed your readme, so adding a warning might be good...
Hi,
I am creating a web app using Tone.js and music-tempo to get the bpm of the song. Tone is creating an audioContext that gets the sample rate from my laptop (48000Hz) and music-tempo is calculating a tempo that is always 10 bpm less than what it should be (e.g. a song at 120bpm, I'm getting a result of 110bpm). I suspect that it could be because in the examples provided the audioContext is set to 44100 instead of 48000Hz. Any help would be much appreciated.
I made a beat-aware media player using music-tempo: https://phrasier.leftium.com/
It works great on desktop, however the results are not quite right on mobile browsers. The tempo should be 119 BPM, but mobile browsers result in 107 BPM. The actual beat timings are off, too. Both mobile and desktop agree on the total number of beats, though.
I think music-tempo does a deterministic analysis of the audio data, so I'm not sure how mobile and desktop results could diverge. Does music-tempo change the number of tests or cut tests short depending on the performance of the system?
Hi i'm getting following error for few tracks.
re[_k] = hammWindow[_k] * audioData[i];
^
RangeError: Invalid string length
at Float32Array.join (native)
at Float32Array.toString (native)
in **/music-tempo/dist/node/OnsetDetection.js:116:49
can you please let me know how to fix it? thanks!
I have read the document, but I still don't know how to get echo tone, like the demo app
https://killercrush.github.io/music-tempo/example/example-advanced.html
It can get every tone note and their loudness, time and frequency.
I tried using your test page to get the BPM of the song "Say Something" by A Big World (feat. Christina Aguilera). Your test page shows that song has a BPM of 131. That BPM is way, way, too high for that song. That song actually has a BPM of about 50.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.