What pre-processing step is applied to raw audio samples by edge impulse?

My objective was to check if the amplitude of audio recording via Edge Impulse is same as the one captured via Arduino’s Serial.Monitor.

Approach.
I used an Arduino Nano 33 BLE Sense and used the PDMSerialPlotter sketch to record a 1Hz Sine tone. I then connected the same microcontroller to Edge Impulse (EI) and used EI dashboard to record the same 1Hz Sine tone. The results are below.

I can hear the 1Hz tone, but the raw audio collected from Arduino’s Serial monitor is a bit noisy, but the one connected from EI is clean.

Question
As we can see that the amplitude differs between both the mode of data collection. I want to know what preprocessing step is applied via EI that we don’t see the non-uniformity in the amplitude?

1 Like

Hi @rishi, we don’t do any post-processing on the raw audio on the Arduino, but we do set the gain, maybe that makes a difference?

See our code here: https://github.com/edgeimpulse/firmware-arduino-nano-33-ble-sense/blob/e380fbfd20e560cf9bac721b4008d062fdff05a8/src/sensors/ei_microphone.cpp#L325

1 Like

Thanks @janjongboom, indeed the amplitude got fixed after I changed the gain to 127. But I discovered a new problem now (which I was ignoring previously) .

I recorded a 10 second sample, from both EI and Arduio PDM serial plotter at 16KHz sampling rate. But, the data from Arduino Serial Monitor only has samples till about 2 seconds as shown in the graph below. Is this due to low data rate (9600 bps) of the serial monitor? If that is the case, can anyone suggest me pointers on how do I change the serial data rate to accoodate 16000 samples per second?

I’m sorry, I know its a Arduino specific question. But I thought, I could get some help here :slight_smile:
Thanks!!

I’m not entirely sure, but:

If that is the case, can anyone suggest me pointers on how do I change the serial data rate to accoodate 16000 samples per second?

So this is really hard over serial! 16000 samples x 6 bytes (because the value is a string between -32768 and 32767 and then a separator) = 768,000 bits per second. That’s much faster than typical serial supports. Could be that it sends data less often in the default configuration to accommodate for that (and thus you only have 1/5 of the data). In our firmware we cache on device, and then send it over to mitigate this.

2 Likes