killercrush / music-tempo

Finding out tempo of the music
https://killercrush.github.io/music-tempo
MIT License
123 stars 16 forks source link

Tone.js and music-tempo: bpm detection mismatch #12

Open jumeca opened 10 months ago

jumeca commented 10 months ago

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.

killercrush commented 10 months ago

Hello, you should set sampleRate of AudioContext to match sampleRate of your audio file

jumeca commented 10 months ago

Thanks! I managed to fix it by passing the hopsize based on the sample rate of the audio context

SoplicaIndustries commented 1 month ago

Thanks! I managed to fix it by passing the hopsize based on the sample rate of the audio context

Hi, how exectly did you calculate the hopsize? Could you provide an equation?