Looking for noise filter code

Hi Everyone

I have been searching for days now to find a Arduino audio noise filter code.

I did find lots of noise code samples but not for Arduino IDE.

I want to read audio from ADC apply the filter algorithm and output the audio with a STM32F103C8.

Where is the Arduino DSP , FIR , IIR , Lowpass filter - library samples hiding?

Thanks.

For STM32, also look at ARM CMSIS, it has some DSP C functions as well.

Thanks

I downloaded the Git-hub filter library and the very first sample I try to compile give a error.I did install Filter.h with the Library Manager.

Where is this files?

#include <AH/Timing/MillisMicrosTimer.hpp>
#include <Filters/Notch.hpp>

The Arduino-Filters library is not available in the library manager. To install it, download the .ZIP file from GitHub and follow these instructions: https://www.arduino.cc/en/guide/libraries#toc4

If you have two libraries with "Filters.h" installed, Arduino might select the wrong one, so it's best to uninstall the other ones you might have installed.

Thanks.

The one example does compile now for a Nano but very weird does not compile for the STM32F103C8.

This is my error:

Arduino: 1.8.12 (Windows 10), Board: "Generic STM32F103C series, STM32F103CB (20k RAM. 128k Flash), STLink, 72Mhz (Normal), Smallest (default)"

In file included from C:\Users\mike\Documents\Arduino\libraries\Arduino-Filters-master\src/Filters/Notch.hpp:3:0,

                 from C:\Users\mike\AppData\Local\Temp\Rar$DIa15332.23396\FIRNotch\FIRNotch.ino:22:

C:\Users\mike\Documents\Arduino\libraries\Arduino-Filters-master\src/AH/STL/cmath:16:31: note: #pragma message: FMA math fix

 #pragma message("FMA math fix")

                               ^

C:\Users\mike\AppData\Local\Temp\Rar$DIa15332.23396\FIRNotch\FIRNotch.ino: In function 'void loop()':

FIRNotch:44:27: error: 'A0' was not declared in this scope

     auto raw = analogRead(A0);

                           ^

In file included from C:\Users\mike\Documents\Arduino\libraries\Arduino-Filters-master\src/Filters/Notch.hpp:4:0,

                 from C:\Users\mike\AppData\Local\Temp\Rar$DIa15332.23396\FIRNotch\FIRNotch.ino:22:

C:\Users\mike\Documents\Arduino\libraries\Arduino-Filters-master\src/Filters/FIRFilter.hpp: In instantiation of 'FIRFilter<N, T>::FIRFilter(const AH::Array<T, N>&) [with unsigned char N = 3u; T = float]':

C:\Users\mike\Documents\Arduino\libraries\Arduino-Filters-master\src/Filters/Notch.hpp:34:6:   required from 'FIRFilter<3u, T> simpleNotchFIR(double) [with T = float]'

C:\Users\mike\AppData\Local\Temp\Rar$DIa15332.23396\FIRNotch\FIRNotch.ino:39:34:   required from here

C:\Users\mike\Documents\Arduino\libraries\Arduino-Filters-master\src/Filters/FIRFilter.hpp:32:52: warning: missing initializer for member 'AH::Array<float, 3u>::data' [-Wmissing-field-initializers]

     FIRFilter(const AH::Array<T, N> &coefficients) {

                                                    ^

exit status 1
'A0' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

It looks like your board doesn't define the A0 pin number. Which STM32 core are you using?

Not sure what you mean by "CORE" but I use the STM32F103C8 M3 Arm Cortex generic "Bluepill" board.

Beside the A0 warnings there is also a lot of other errors.

You should have installed a third-party core in the Arduino IDE boards manager to be able to compile for the STM32.
I'm not an STM32 expert, but IIRC, there are basically two of these cores: one newer, official core from STMicroelectronics, and one developed by the community. The latter uses an ancient toolchain, so I highly recommend using the official STM one: GitHub - stm32duino/Arduino_Core_STM32: STM32 core support for Arduino

I just tried the Butterworth example and it compiles without issues for the STM32F103C8 using the official core.

1 Like

Wow...wow...wow Thanks.
If the Carma button was still on this new web page I will press it a 1000 times.
Now compiling without errors for the STM32F103C.

Glad to hear it works now!

It looks like you can install ARM CMSIS as a module: GitHub - stm32duino/ArduinoModule-CMSIS: CMSIS module for Arduino IDE

They have specific Filtering Functions
I'm not sure if the F103C8 has any SIMD or DSP instructions, but you might be able to squeeze a tiny bit of extra performance out of the (hand-?) optimized CMSIS filtering functions compared to the Arduino-Filters library. CMSIS also has fixed-point integer-math filters.

Now I got a lot of info to play with.

The new core from github does not work on my ST LINK V2 programmer, the other core I used had the STlink programmer selectable in the ide.

I think the ST-Link should be supported: Upload methods · stm32duino/wiki Wiki · GitHub

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.