The realization of the algorithms proposed has been implemented on a Raspberry Pi3 through the script python3. Even if at first sight this might seem the less suitable hardware for this task, it’s worth trying it because of the cheap cost, the portability and the compatibility with a high language level like Python. Due to all these advantages we have tried this first path, finding some a big latency issue due to the GIL and to the operating system. To increase the performances, we suggest to employ a microprocessor able to read low level programs written in C or C++. An important and obvious thing to say is that the simulations are always ideal and it shouldn’t be so surprising to find different results dealing with real and practical situations. 

Zero Algorithm on clipping

Like already discussed in the homepage, the clipping algorithm hushes the audio coming from the external microphone as soon as a shot event is revealed (meaning that we are over a certain trigger level that is computed on past audio samples). This concept has been implemented through a circular buffer containing the chronology of n samples. To estimate the threshold we simply compute the average of the slots.


From the graph you can see that in the point P1 there is a complete cancellation of the gunshot. Please notice that the dynamic threshold algorithm has some issues and in fact at the point P2 a gunshot “escapes” and passes through the speakers. This is because we have a long series of shots that causes the decrease of the trigger level.

At last, we have chosen to plot the graph of the Power Spectral Density (PSD) just to have a more intuitive idea of the attenuation coming from this type of algorithm. Even if the communication could be a little bit annoying, we guess that this solution associated with a proper autoregressive model is the best solution to be implemented because it’s cheap and smart at the same time.

Old Data Algorithm on clipping

This time we have chosen to use past samples to attenuate the “hole effect” that is created by the previous algorithm. In this way the communication should be clearer.

The main issue is that you must make a sort of trade off between the trigger level and the number m of old samples, otherwise we would obtain a disturbing eco effect when a gunshot is superposed to the voice.

Compression Algorithm on clipping

Here instead we find the compression of the sound when it overcomes a fixed threshold.

The main advantage is for sure the simplicity. On the other hand we don’t remove any gunshot and for this reason this is not the right choice to be done in our project.


During this course we have learnt to work in a team on a research topic that is commonly studied by lots of companies in these days. Analysing the papers online we have now a large scenario in front of us and were able to provide solutions. The results obtained were executed on a computer and not on a stand-alone device due to the complexity of the algorithms and the limited time.

If you read papers online you will find lots of different opinions, even opposite one another and so another important thing to emphasize is that we were able to find a sort of harmony among different theories making our own personal idea.


In conclusion, we would like to thank Dr Riccardo Bernardini who has given us this important opportunity to understand how to work on a problem starting from zero.