GithubHelp home page GithubHelp logo

killercrush / music-tempo Goto Github PK

View Code? Open in Web Editor NEW
119.0 7.0 17.0 2.03 MB

Finding out tempo of the music

Home Page: https://killercrush.github.io/music-tempo

License: MIT License

HTML 7.58% JavaScript 92.42%
music tempo bpm beat beatroot rhythm

music-tempo's People

Contributors

killercrush avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

music-tempo's Issues

[Suggestion] Expose the AudioBuffer duration

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)

Differences between music-tempo and Beatroot

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

Bad beats

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...

Tone.js and music-tempo: bpm detection mismatch

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.

Different (inaccurate) results on mobile vs desktop.

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?

RangeError: Invalid string length

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!

This doesn't work (BPM is incorrect)

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.

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.