dpwe / audfprint

Landmark-based audio fingerprinting
MIT License
544 stars 122 forks source link

Question about concatenate afpk files #93

Open NahuBocco opened 1 year ago

NahuBocco commented 1 year ago

Hi @dpwe , first of all, congratz for this awsome tool for python.

I have question: Supouse that i have two afpk files of A.wav and B.wav, where A and B are consecutive audio chunks in time. Then, afpk files contains

A.afpk -> audfprintpeakV00--bytes of afpk A-- B.afpk -> audfprintpeakV00--bytes of afpk B--

If i concatenate the data inside the files in this way: AB.afpk -> audfprintpeakV00--bytes of afpk A----bytes of afpk B--

This is equivalent to afpk extracted from A.wav concatenated with B.wav ?

dpwe commented 1 year ago

Sadly no, I think. Each peak is recorded as a (time index, bin index) pair, and the time indices are absolute (and maybe assumed monotonic). If you appended the wav files, B would begin at a time corresponding to the end of A, whereas B analyzed alone will begin at time zero.

You could modify the afpk format to write (delta-from-previous-time, bin), and then re-accumulate the times when reading back. Then it would probably work.

NahuBocco commented 1 year ago

Oh okay, probably ill make a function to "merge" afpks that take as arggument the offstet time between recorded files Thank you very much, I really appreciate your answer!