worldveil / dejavu

Audio fingerprinting and recognition in Python
MIT License
6.41k stars 1.43k forks source link

Wrong indexes!? #156

Closed vilas27 closed 6 years ago

vilas27 commented 6 years ago

Hello,

First of all, congratulations for this work, it's very cool.

I'm analyzing your code, and I found something that does not make much sense to me. I may be misinterpreting it, but it is this, in the file fingerprint.py in the following code:

106    # extract peaks
107    amps = arr2D[detected_peaks]
108    j, i = np.where(detected_peaks)
109
110    # filter peaks
111    amps = amps.flatten()
112    peaks = zip(i, j, amps)
113    peaks_filtered = [x for x in peaks if x[2] > amp_min]  # freq, time, amp
114
115    # get indices for frequency and time
116    frequency_idx = [x[1] for x in peaks_filtered]
117    time_idx = [x[0] for x in peaks_filtered]

The vector peaks, as it is in your comment, at line 113, should have the following structure (freq, time, amp). But when you fill the frequency_idx and time_idx vectors, the indexes should be this instead:

116    frequency_idx = [x[0] for x in peaks_filtered]
117    time_idx = [x[1] for x in peaks_filtered]

Am I right or am I missing something?

Thank you, for you time!

vilas27 commented 6 years ago

The code is correct, the comment is what is wrong, it should be (time, freq, amp)