realtime-bpm-analyzer icon indicating copy to clipboard operation
realtime-bpm-analyzer copied to clipboard

Audio offset in offline analysis

Open KCFindstr opened this issue 5 months ago • 7 comments

Thanks for the great library. I am wondering if it is possible to add time offsets to each BPM candidate? A use case would be in rhythm games, the chart designer often wants to align notes with beats, so having both start offset of the first bar and BPM will make the alignment much easier and more accurate.

KCFindstr avatar Feb 03 '24 13:02 KCFindstr

Hi @KCFindstr,

I’m not sure to understand what do you need.

Could you please provide details for the use case ?

Typically, what you would expect. Please also provide a sample to implement tests.

Thanks

dlepaux avatar Feb 03 '24 14:02 dlepaux

Example: this is the auto BPM detection from a rhythm game Malody.

After setting the correct offset & BPM, it's expected that a lot of the strong beats lie on the start of each bar.

The start of each bar in seconds is calculated as $$bar_i = \frac{60}{BPM}i - offset$$

(+offset or -offset does not matter here as long as it's exposed in the API)

KCFindstr avatar Feb 03 '24 21:02 KCFindstr

@KCFindstr Ok thank you for your clarification.

It is possible to add this information in each BPM candidates.

In order to be sure while implementing the feature could you provide a sample with the expected result please ?

dlepaux avatar Feb 03 '24 23:02 dlepaux

Great, thanks for the prompt reply! I have attached an example song. song-bg.zip Expected BPM is 130 and offset is 429ms. (any offset like 429±(60000/130)*i will be correct too, and if the offset is off by ~10ms it would also be acceptable)

KCFindstr avatar Feb 03 '24 23:02 KCFindstr

@KCFindstr Thanks for those informations. I'll keep you informed when the feature will be released. I have a last question, in which context is this feature useful to you ? Are you a contributor of Malody App ?

dlepaux avatar Feb 04 '24 20:02 dlepaux

@dlepaux Nope - Malody is a commercial app and it already has a BPM detector with very good accuracy, but the algorithm is closed source. I am developing an open source lyrics editor in which displaying beat information will also be helpful, and I am looking for an open source alternative.

KCFindstr avatar Feb 04 '24 20:02 KCFindstr

@KCFindstr I've done an experimental implementation of the feature but it implies more complex issues related to the algorithm.

You might not know this, but the algorithm to compute BPM is based on amplitude thresholding. We basically look for the highest peaks and then we can compute the BPM with the intervals, etc.

To get the information we're looking for, we would need to identify each peaks, and then we would be able to compute the duration in second to reach it from the beginning of the audio. So, we would need to wait a deep refacorization of the library to get this information.

dlepaux avatar Feb 09 '24 17:02 dlepaux