19def computeFingerprint(x, f_s):
27 x = ToolPreprocAudio(x)
31 x, t_x = ToolResample(x, fs_target, f_s)
37 afWindow = ToolComputeHann(iBlockLength)
40 [X, f, tf] = computeSpectrogram(x, f_s, afWindow, iBlockLength, iHopLength)
49 SubFingerprint = np.diff(np.diff(E, 1, axis=0), 1, axis=1)
50 tf = tf[:-1] + iHopLength / (2 * fs_target)
53 SubFingerprint[SubFingerprint < 0] = 0
54 SubFingerprint[SubFingerprint > 0] = 1
56 return SubFingerprint, tf
67 f_band_bounds = f_min * np.exp(np.log(f_max / f_min) * range(iNumBands+1) / iNumBands)
68 f_fft = np.arange(iFftLength / 2 + 1) / iFftLength * f_s
69 H = np.zeros([iNumBands, iFftLength // 2 + 1])
70 idx = np.zeros([len(f_band_bounds), 2]).astype(int)
73 for k
in range(len(f_band_bounds)-1):
74 idx[k, 0] = np.ceil(ToolFreq2Bin(f_band_bounds[k], iFftLength, f_s)).astype(int)
75 idx[k, 1] = np.floor(ToolFreq2Bin(f_band_bounds[k+1], iFftLength, f_s)).astype(int)
76 H[k, idx[k, 0]:idx[k, 1] + 1] = 1