0
$\begingroup$

It is necessary to extract the harmonic signal from the audio spectrum. That is, from the spectrum of 20 ... 20,000 Hz it is necessary to select only a signal with a frequency of 1,000 Hz, and suppress the rest. You need to do this on a microcontroller. As I understand it, you need to take the Fourier transform from the audio signal and multiply the result by a certain window function.

Maybe you can just estimate the frequency of zero crossing? Can it be easier to convolve a signal with some other signal? The resources of the microcontroller are quite limited, in fact, I do not need the entire spectrum, I need one harmonic component of it. And do all this in real time ...

$\endgroup$
2
$\begingroup$

You don't have to perform a full FFT. Take the definition of DFT:

$$X[k] = \sum_{n=0}^{N-1}x[n]e^{-j\frac{2\pi}{N}kn}$$

What you need is one element of the sequence $X[k]$. For example, suppose the sampling rate is $f_s$, and the signal has a length of $N$, so the frequency resolution is $\Delta f=f_s/N$, and $k$ corresponding to 1000 Hz equals to $1000/\Delta f + 1$. Just do DFT at that discrete frequency $k$.

On the other hand, if you want to convolve your signal with something, use sinusoidal wave of 1000 Hz. We know that a convolution in the time domain equals a multiplication in the frequency domain. The Fourier transform of sine wave is delta function at the specific frequency. So convolving with sine wave can extract the harmonic component.

$\endgroup$
1
$\begingroup$

Typically, you use microcontrollers to process signals when you need to do it real-time. When you process a pre-recorded signal, like an audio file, you filter waveforms of these recordings in applications that you run on computers like desktops: you can process a recording "in the bulk", putting the entire length of the recording into an input array, or partition the recording into segments and calculate a periodogram. Usually, the computer provides a computing power sufficient to perform the Fourier transform and let the user/developer do not care about a painstaking implementation of "zero crossing" (which, most probably, cannot give you the reliable estimate of frequency anyhow).

While one can (and does) implement a processing like periodogram computation with microcontrollers, the staple way to select a frequency component (in real-time systems) is to apply digital filters: you can filter out high frequencies with a low-pass filter, low frequencies with a high-pass filter; for other tasks, you may need a band-pass filter, etc.

The harsh realities of mathematics make the task of filtering exactly 1000Hz wave from a real-time signal impossible; your best bet for the MCU implementation is a narrow-band bandpass filter with a quality factor as high as possible, this filter action being opposite to a notch filter operation.

As you correctly guess, one can do frequency "extraction" with limited computing power resources: the digital filter of a finite impulse response kind does not need to perform operation on the entire duration of the sound to be analyzed and can do it without the Fourier transform. Beware that, in a practical implementation, one need to know: the less sample count of the convoluted samples results in the wider range of filtered frequencies, so your FIR filter must be of a sufficient order. You are also on the right track when suggesting "to convolve a signal with some other signal" for your "extraction" operation: the math of filter operation is related to convolution math.

After all, you must decide what do you want from this (real-time?) "frequency separation" operation. Applying a narrow pass-band filter to a stream, you produce a near-1000Khz wave with an envelope amplitude proportional to a share of the 1000-KHz component in the frequency spectrum of the original sound stream at any given moment. Why? Otherwise, you may want to apply a notch filter and suppress the filtered frequency, which is great when you want to filter out a possible 50/60Hz hum from the imperfect power supply, but hardly ever makes sense with an arbitrary frequency. For an application like frequency equalizer, you need not a notch filter, but a bank of band-pass filters with controlled gains. Summing up, you need first to work out the application where you're going to use this "frequency-separation" technique, and only thereafter design the implementation, choosing between a digital filter, a Fourier transform analyzer, or whatever else.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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