This repository contains an AudioMoth firmware adaptation to calculate the Sound Pressure Level (SPL). This is based on the 1.3.0 version of AudioMoth firmware (published on AudioMoth-Project and AudioMoth-Firmware-Basic). We include the SPL library (src/spl.c
and inc/spl.h
) that implement all the functions related to the SPL estimation.
The main modifications of the src/main.c
file of AudioMoth-Firmware-Basic are in the filter function, where we add the SPL functions calls.
We estimate the SPL using the audio signal recorded by the AudioMoth. We calculate the LAeq,T in the time basis, , defined by the record duration configured in AudioMoth. Therefore, for each wav file recorded in AudioMoth, a SPL value is calculated and saved into a log file in the SD card. Thus, if
is the signal recorded by AudioMoth, we estimate the SPL by the mean energy:
where is the number of samples in the time
, and
is the A-weighted signal. Also, as the AudioMoth microphone does not have a flat frequency response, it is necessary to apply a filter to compensate its response. Therefore before we calculate
, we apply the filter compensation. The next diagram illustrates the process flow.
In order to compensate the microphone frequency response and to apply the A-weighting to the signal, we implement different Infinite Impulse Response (IIR) filters. When the filter order is too high, we split it into parts (first or second order filters). Each of this parts is implemented by the Direct-Form-II (DF-II) realization. We base our implementation in the result of the faust filter library.
In order to have an almost flat microphone frequency response, we implement an IIR filter that compensates the response in the low frequencies. In the near future, we are going to improve this compensation. See Mic_compensation_filter notebook for more details about filter design process.
Note that unlike other methods based on the frequency domain, we apply the weighting on the time-domain of the signal. See A_weighting_filter notebook for more details.
Flash the bin/AudioMoth-Firmware-SPL.bin
file following the instructions from the OpenAcoustic team.
To edit this firmware, clone this repository and follow the instructions from the AudioMoth wiki.
This repository is organized as follows:
AudioMoth-Firmware-SPL/
|
|- src/ _______________________________ # Firmware source files
| |- main.c __________________________ # Main program (edited from AudioMoth firmware 1.3.0)
| |- AudiMoth.c ______________________ # AudioMoth library
| |- spl.c ___________________________ # SPL library
|
|- inc/ _______________________________ # Firmware header files
| |- AudiMoth.h ______________________ # AudioMoth header
| |- spl.h ___________________________ # SPL library header
|
|- bin/
| |- AudioMoth-Firmware-SPL.bin ______ # Compiled firmware ready to AudioMoth
|
|- notebooks/ _________________________ # Jupyter noteboks
| |- A_weighting_filter.ipynb ________ # Filter design process of A_weighting filter
| |- Mic_compensation_filter.ipynb ___ # Filter design process of compensation filter
Other folders are libraries includes in the AudioMoth original firmware.
We use the same license (MIT) that AudioMoth-Project, Copyright (c) 2017 OpenAcousticDevices. Files src/spl.c
and inc/spl.h
and the modifications of src/main.c
have Copyright (c) 2020 Pablo Zinemanas.