I have a system where I cross correlate recorded audio signals with several smaller generated signals to extract feature vectors that later I use in a kNN matching. The system works the way I want it but I feel like I am doing things inefficiently and repetitively. I was hoping to get a simplification of what I am doing.

Let's say I have a recorded audio signal $S_k$ at a certain time. I am calculating the feature vector as:

$$ F_{ki} = \max\left(\left\lvert S_k \circledast H_i\right\rvert\right), \quad i \in {1,\ldots,N} $$

where $\circledast$ represents cross correlation, and the signals $H_{1..N}$ are just sinusoidal signals of the form $H_i = \sin(2\pi f_it)$ where $f_1$ is 18 kHz, $f_2$ 18.1 kHz, $f_3$ 18.2 kHz ... etc. every signal has a single fixed frequency value and my bandwidth is between 18 kHz and 22 kHz. The $H_i$ signal is 1/10 the length of $S_K$

My whole intention is trying to see which frequency values are strong and to what level by considering discrete frequency values like 18.1 kHz, 18.2 kHz etc.

I feel like I am doing some things unnecessarily. Given that cross correlation involves doing fft of both sides and inverse fft after their complex multiplication. I think I can just take the fft of the audio signal and finish the feature extraction there. But I don't know how to get as good relevant feature vector with lower dimension as the cross correlation would give me.


1 Answer 1


Your notations is not entirely clear, but it looks to me that you are simply calculating the magnitude of the Fourier Transform (FT) of $s_k(t)$ at $f_i$. The cross correlation of a signal with a sine wave is a sine wave at the same frequency with the magnitude of the signal's FT.

Let's assume we have a singnal $s_k(t) \leftrightarrow S_k(\omega)$ and a complex sine $h_i(t) = e^{-j\omega_i t }$.

The cross correlation is

$$ r_{sh}(t) = \int s(\tau) \cdot h(t+\tau) d\tau = \int s(\tau) \cdot e^{-j\omega_i (t +\tau) } d\tau = \int s(\tau) \cdot e^{-j\omega_i \tau } \cdot e^{-j\omega_i t} d\tau = $$ $$ e^{-j\omega_i t} \cdot \int s(\tau) \cdot e^{-j\omega_i \tau } d\tau = e^{-j\omega_i t} \cdot S_k(\omega_i) $$

Note that the last integral in the last equation is simply the Fourier Transform. Since $|e^{-j\omega_i t}| = 1$ we simply get

$$ \max(|r_{s_kh_i}(t)|) = |S_k(\omega_i)| $$

There are probably some details that need to be nailed down (sine vs complex sine, boundary effects, spectral smearing, linear vs circular cross correlation), but that could be a very efficient approach.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.