How to get rid of clipping in audio?

Hi. I’m recording breathing sound using the Arduino Nano 33 BLE Sense via Edge Impulse. For some samples, I think there is a clipping in the audio stream. For the image below, clipping seems to be in the negative direction. Is that correct?

image

  1. How do I infer the clipping in positive (>32767) and negative (<32768)? What does it mean?
  2. How do I get rid of the clipping? Shall I reduce the software gain of the microphone?

Hi @rishi,

  1. The minimum range required by C is actually -32768 through 32767, because it has to cater for two’s complement, ones’ complement and sign/magnitude encoding for negative numbers, all of which the C standard allows.
  2. Yes I think you can play with the microphone parameters to make sure your signal fits into [-32768 ; 32767]

Regards,

Louis

@rishi I think this might be because of the gain we set? You can update the PDM.setGain functions in https://github.com/edgeimpulse/firmware-arduino-nano-33-ble-sense/blob/0c67ed6196dd64b139580bb07dabc4a8aa043e89/src/sensors/ei_microphone.cpp and then rebuild the firmware (instructions are in that repo).