Pages

Monday, March 18, 2013

sound and fury

I needed a good winter car at some point and decided that an old Miata would be perfect. If you are only now questioning my sanity then you haven't been reading carefully. I bought a car that was  straight and intact after more than 15 years and nearly 200000 miles. The only thing that didn't work properly was the radio.

Everything on the radio worked except the volume knob. The shaft encoder is dirty or broken or otherwise useless. I spent a couple of hours pressing on the knob this way and that while spinning it. I was eventually able to coax the volume up to about halfway and jam a cassette to minijack adapter in the deck and call it a day. I play music from my phone and control the volume from there.

This arrangement worked perfectly for more than a year. It unravelled when I left the lights on and drained the battery. The radio lost its volume setting and I just can't be bothered to fix it. I pulled the
radio from the car and failed to fix the knob in the five minutes I allotted for the process.

From there, decisions came in rapid succession. I decided that I would replace the stereo, that there were no sufficiently modest and handsome units available new, and that any replacement OEM stereo would probably have the same problem as my original. I decided, therefore, that I should build a stereo.

This is an unlikely conclusion. I have essentially no interest in stereos. I have no spare time. I have no special mechanical aptitute that makes me a builder of attractive things. Small packages started arriving in the mail before I could come to my senses.

The first of these packages was a wiring harness compatible with the factory wiring in my car. $5.02. The second was a small circuit board that supported an audio amplifier built out of the TDA7850 audio amplifier IC from STMicro. I paid about $22 to an ebay vendor.

I connected these together over the weekend and plugged them into the car and my phone. It worked perfectly and may yet be the high point of the experience. Not bad for $27.

The next part to arrive was a wretched little box that is designed to frame a nano-ITX motherboard and a lilliput touch screen together in a double DIN sized box. I have no interest in car computers but I needed an enclosure for my ad-hoc radio. The amplifier board and wiring harness will be mounted in this box.

My user interface requirements are modest. I need a power switch and maybe a knob. I ordered neither. Instead, I ordered an HDMI touch screen and a Raspberry Pi computer. I think I did this because I doubted my ability to build a decent knob. Jonny Ive and I must have that in common.

I actually added the Raspberry Pi because I would like the stereo to function as a Bluetooth A2DP sink and I guessed that it would be a simple matter of programming to make this work with the Raspberry Pi.

What I have found is quite the opposite. If I cross my fingers, I may find a collection of nasty scripts that let me get this working for a particular phone. Most of these stories depend on happy interactions between BlueZ, PulseAudio, and ALSA. These interactions seem unlikely. Each of these pieces is a complete disaster.  The complexity of ALSA might suggest that audio processing is very important to the Linux community. The opposite is true. The kernel interface to ALSA survives with so much complexity and so little documentation because audio is unimportant. 

Go look at the feature list for ALSA. It's advanced. It has thread-safe device drivers. It supports full-duplex operation. It promised to deliver latencies that rival the very best hydraulic actuators. All it asks in return is for you to embrace a hideously complicated programming model and an obnoxious user space library. If we programmed Ethernet this way then I would probably still be using terminal sessions through a dial-up modem.




No comments:

Post a Comment