Arduino
Arduino
LAB 3 :
Audio filtering on Arduino
o capture the samples in real time, it is recommended to start with a sketch called
PDMSerialPlotter located at the following path: File
→ Examples → PDM → PDMSerialPlotter
This code is very simple to analyze and all it does is capture the already encoded
samples from the microphone and print them through the serial port. The Arduino
application allows us to see these values numerically (Tools → Serial Monitor) or
graphically (Tools → Serial Plotter).
If we upload this example, open the graphic monitor and speak into the
microphone, we can visualize the sound waves (figure 1).
float coef_lp[13] =
{660,470,-1980,-3830,504,10027,15214,10027,504,-3830,-1980,470
,660};
fir_lp.setFilterCoeffs(coef_lp);
Once the filter has been created, to apply it to a sample, it is done with the method
processReading.
fir_lp.processReading(data[i])
http://t-filter.engineerjs.com
Pregunta: Why do we have to limit the frequency band we want to eliminate and
not say that we want to filter out all frequencies from 4kHz onwards?
Specifying a stop band allows for more precise control over the filtering process,
ensuring that only the intended frequencies are attenuated while preserving the desired
signal characteristics and avoiding potential side effects.
Once the characteristics of the FIR filter have been entered and the design has
been applied, we can copy the coefficient values. It is important that the format of
these coefficients be a 16-bit integer.
The program must print the two values on the same line: the sampled value and the
filtered value (see the example code called multiple_filters). In this way, we can
have the result of the two superimposed signals as shown below:
PASO 4. COMPROBACIÓN
In Figure 2 it cannot be verified that the filtering algorithm is being applied correctly,
because our voice is not high enough and the established filtering ranges (> 4Khz)
are not applied. In order to verify that our algorithm is correct, we can use a tone
generation application that exists for free in mobile phone markets. Tone Generator
or Frequency Sound Generator are two Android applications that can be useful
(figure 3).
If we execute frequency tones < 2Khz and frequency tones > 4Khz and bring them
closer to the Arduino Nano device, we can see how in the second signal, the tones
are filtered.
Figure 3. Application Tone Generator