Every time you make something, you run into problems in places you least expect them, and my arcade machine is, sadly, no exception. I expected the graphics without X11 and the performance of the game to be huge problems, but it all just worked. Something I didn’t expect to be problematic however, was the sound, but oh, have I been wrong. So to save you the troubles of finding all this out yourself, this is a guide to get SDL2_mixer running on your pi.

# Choosing an amp and speakers

I personally ordered a 2x120W class D amplifier and 10 0,5W speakers from AliExpress. Of course, this 120W amp was useless, so I looked for one with a bit less power, and didn’t find one on AliExpress. (Also the amp from AliExpress came smashed, so I got a refund).

After looking a bit further, I deviated from my path of ordering everything cheaply from China and found this 3,7W amplifier on AdaFruit. This amplifier cost about the same as the one I got from AliExpress, but then came the shipping costs, and come they did, as they were €30, which was a bit much (do you know how much stuff you could buy for that in China? And they have free shipping, even for something that costs €0.56!) So after even more googling, I found a Dutch webshop which also sells a lot of AdaFruit components, the price for the AdaFruit amp was the same, but the shipping costs about 15 times lower. So I got it, and two days later I had it at home (quite a bit faster than the 2-4 weeks I’m used to), so to anyone in the Netherlands who needs AdaFruit components for a good price, I can highly reccomend hobbyelectronica.nl

### So, how many speakers can we connect?

From the specifications of the MAX98306 we know it can drive 2 x 3,7W speakers with an 3Ω impedance. The speakers we have require 0,5W and have an impedance of 8Ω We put the speakers in parallel, and the maximum number of speakers is easily calculatable with the parallel impedance rule: $\frac{1}{Z} = \frac{1}{Z_1} + \frac{1}{Z_2} + \cdots + \frac{1}{Z_n}$, and the knowledge the impedance cannot be lower than 3Ω, which leaves us with 2 speakers on either side. As power in parallel is additive, the power draw on both sides is 1W, safely under the maximum of 3,7W the amplifier is able to provide.

# Soldering and connecting

The MAX98306 doesn’t come fully soldered, so you’ll have to solder the pin headers and connectors yourself. My speakers also didn’t have wires to connect them, so I also had to solder those myself. Besides the speakers and the amplifier, you’ll also need a 3,5mm stereo jack plug and some wires.

After soldering everything, it’s important you connect the amplifier right, as this is not as straightforward as you’d like it to be on the jack side. For this, please refer to the table below and the diagram to the right. The amplifier requires a 5V power supply, which can be provided from the Raspberry’s 5V and GND pins, although I highly disrecommend that.

3,5 mm Jack Amplifier
Right R+
Left R- and L+
Ground L-

In my next post, I’ll cover how to get the audio working on the software side, and how to build and use the SDL2_mixer library