Dreambox: making noise

      No Comments on Dreambox: making noise

For the past few weeks I’ve been lulling myself to sleep with the help of headband-mounted headphones and my iPhone. Now I’m building a bedside device that will play my carefully curated playlist of dream-inducing ambient music at the touch of a button.

Unlike the Dream Machine I built for my More Significant Other,  which was based on the fabulous Teensy board, I’ve decided to go with a Raspberry Pi. It’s hard to say why – other than that I have something of an addiction to these loverly little computers. Mind you, there’s still going to be a Teensy in there. More on that anon.

The music will always be played through headphones (which is ironic given that the enclosure I’m using – the case from a crappy radio/cassette player – comes ready fitted with a speaker; I haven’t yet worked out what to do with that). You can just plug headphones into the provided jack on the Raspberry Pi, but the sound is pretty poor. It’s got better as the Raspberry Pi has evolved, but it still falls below my already low standards.

So I figured a DAC was in order. I’ve already used one of these on our Dawnclock. And I’m using the exact same model on my HMV1960 project. With the Dreambox, though, I’ve opted to go a slightly different direction.

The previous DAC I used plugs into one of the USB ports. And there’s nothing wrong with that other than that it means there’s another board to somehow secure to the enclosure. For this project, I decided I’d prefer a DAC that attaches directly to the RPi as a hat.

After an hour or so of reading reviews I plumped for the IQaudIO Pi-DAC+. Reviewers praise its simplicity of setup and quality of audio – and it turns out they’re right on both counts. The company provides an online PDF, usefully illustrated, to guide you through the small amount of configuration you need to do (at least on a Raspbian setup).

The device comes ready to push on to the RPi’s GPIO pins. But before I did that, I soldered on a bunch of headers. First I added a double row of headers to bring out the RPi’s GPIO pins. And then I soldered headers to pretty much every other via I could find on the board, just in case.

One set of connections I knew I was going to need is the three-pin input for an encoder to control the board’s audio volume. IQaudIO provides driver code that needs to be running in the background for this to work, but it’s a very simple way of controlling the volume without resorting to code.

The small amount of playing around I’ve found time for so far has confirmed that the sound quality is, indeed, excellent.

I’m using amixer to set the volume programatically and mplayer to play the songs. For the Dawnclock I developed a small library of Python code to do this kind of thing. But when I tried to run it, I found there was a problem getting amixer to play nice. It turned out the problem was with the ‘simple control’ the code was trying to access. Let me explain.

With the other DAC is used, setting the volume would require issuing a command something like this:

amixer -q sset PCM 50%

On the Dreambox, this threw up the error:

amixer: Unable to find simple control 'PCM',0

Issuing the command ‘amixer scontrols’ produced the following result:

Simple mixer control 'DSP Program',0
Simple mixer control 'Analogue',0
Simple mixer control 'Analogue Playback Boost',0
Simple mixer control 'Auto Mute',0
Simple mixer control 'Auto Mute Mono',0
Simple mixer control 'Auto Mute Time Left',0
Simple mixer control 'Auto Mute Time Right',0
Simple mixer control 'Clock Missing Period',0
Simple mixer control 'Deemphasis',0
Simple mixer control 'Digital',0
Simple mixer control 'Max Overclock DAC',0
Simple mixer control 'Max Overclock DSP',0
Simple mixer control 'Max Overclock PLL',0
Simple mixer control 'Volume Ramp Down Emergency Rate',0
Simple mixer control 'Volume Ramp Down Emergency Step',0
Simple mixer control 'Volume Ramp Down Rate',0
Simple mixer control 'Volume Ramp Down Step',0
Simple mixer control 'Volume Ramp Up Rate',0
Simple mixer control 'Volume Ramp Up Step',0

As you can see, ‘PCM’ is nowhere to be seen. Replacing the ‘PCM’ with ‘Digital’ did the trick and now I can set the volume from my Python code.

In a future post I’ll tell you what I plan to do with the Teensy… yes, that’s a Teensy teaser.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.