I have just finished exhibiting a sound installation in an exhibition at Chelsea College of Arts. You can find pictures and videos here. Click read more to find out how I made it.
I made my own amp that was hooked up to a raspberry pi. The raspberry pi was also hooked up to a sensor which measured how far away objects were. A soundtrack of Richard Feynman talking about his work on the atomic bomb was playing, which would become more distorted the closer people were to the installation.
I followed this excellent tutorial to make the amp. The core of it is the lm386 “operational amplifier”. Op-amps take two inputs. One is a signal of a certain shape at a low voltage, and the other is a constant current at a higher voltage. They output a signal with the shape of the lower voltage input, but amplified to the higher voltage!
It’s quite simple to hook up the lm386 to do this, but the results are very noisy and distorted. Audio circuitry is very sensitive to the electromagnetic interference given of by all electrical components. To mitigate this, you need to make liberal use of capacitors to smooth out the signal.
I wanted the circuit I made to be exposed and to be messy with lots of wires hanging everywhere. When I came to transfer the circuit from the breadboard to the veroboard, I intentionally made all of the wires really long, and the components distributed over different boards to create a chaotic look. Unfortunately, it turned out that the longer the wires in an audio circuit, the more interference you get and it sounded awful (way more distortion than I intended). I remade the whole thing, and it still didn’t sound amazing, but I didn’t really have to make a professional sounding amplifier and it was good enough for my purposes.
I scavenged speakers from various different appliances, and mounted the whole thing on a crudely made frame of wood and perspex. In terms of craftsmanship it was abysmal, but I think it worked quite well with the quality of the audio as it became more distorted. I wanted the whole thing to seem like it was barely being held together, so it helped that this was literally true.
I used an ultrasonic sensor to measure distance. These are super easy to use and are accurate with a quick response. They are a form of sonar. You send a signal to its trigger pin, and listen for a signal on its echo pin. The length of the time between the two tells you how far away the nearest object is (after a bit of maths). You MUST implement a voltage divider between the echo pin and the RPI because it outputs 5V.
I programmed this in Python, which is relatively new to me. There’s a lot less intricacy to it than C++ which made the process quicker, but I missed the amount of control you have over memory. It was sometimes difficult to pass variables around and (I never thought I would say this) I missed pointers.
I started using the “pyaudio” library but it doesn’t work well on raspberry pi. I opted instead to use the “python alsa audio” library which worked perfectly. This uses PCM audio, which gives your direct access to the waveform. Interestingly this is passed around as a string of characters, with the ASCII value of a character representing the level of the waveform at that point in time. To create distortion, it was just a case of converting this to a number, increasing it, and then turning it back into a char.
If anyone wants to see the code I wrote for it, please let me know.
Again, go here to see videos of it in action: