Like all good things, this project was born out of the pain and misery of sleep deprived engineering students. We were inspired by the human body's fascinating ability to determine the direction from which a sound came from using only two sound channels. Naturally, we wanted to see if we could artificially create such a mechanism, and if so, how close we could get it to the real thing. Having initially started with an algorithm for just two microphones, we quickly came to the realization that we could achieve more accurate results if we used a two by two array. With further development and optimization, we envision that such a product would be of particular use in defence applications by assisting in determining originating direction for gun shots in conflict zones. More advanced development could see the addition of machine learning algorithms, allowing the system to differentiate between gun shots and other noises.

The code we wrote for this event is a combination of embedded, Digital Signal Processing (DSP), and some glue logic to hold it all together.The most interesting part of the code (to us, at least) is the DSP section. It calculates the direction which sound approaches our microphone array using a collection of different DSP techniques, such as selective sampling and cross covariance. The glue part of our code was what took by far the longest because of the time we took to iron out all the interfacing bugs.

Qt was used to provide the core of the software architecture and the interfaces with external hardware. We had interfacing problems from the very beginning, when trying to read audio from the QAudioInput class. We spent nearly eight hours trying to debug an issue where the QAudioInput::read() method was reading zero bytes of data. To debug, we started with Qt's associated sample program, and slowly transformed it into our broken code, line by line, waiting for it to break. In the end, it turned out that the QIODevice (file-like object) would only allow reads in multiples of 4096 bytes. We were trying to read 3800 bytes, which rounded down to 0 as the next lower multiple of 4096. This behaviour was not described in documentation.

Another interfacing issue that consumed a lot of our time involved serial port communication with an Arduino using the QSerialPort class. Unlike writes from Python and Matlab, writes to the serial port from Qt were not being sent to the micro controller until the output buffer completely filled. The workaround for this issue was to flush the QSerialPort after every write.


Our favourite feature of the Hack is the user interface, consisting of 72 Light emitting diodes arranged in the shape of a ring and hidden under a sleek acrylic case. We’re happyy that we were able to make it very simple while conveying all the information we need very in a very clear and elegant manner.

Built With

Share this project: