Close

Finally, some music

A project log for Spotify Box Lite

A device that can stream Spotify

peroPero 12/13/2021 at 22:110 Comments

I'm using this project in a combination with my previous project, the HiFi Audio Amplifier, for my home music system. Unfortunately, I didn't manage to get anything more than noise and hum out of my speakers. 

With hope that all is okay with my hardware, drivers, and the device tree, I needed a way to easily configure my codec properties, until something happens. To make a sound comes out, or, really anything, that noise was unbearable. How can I change the codec settings, like the volume, filtering, mixing etc. if Linux by default doesn't let you play with the registers once they're used by kernel? 

Well, there comes a programming interface to configure some pieces of code in the kernel, dedicated specifically to the sound cards, called ALSA. It allows you to play any sound file, using the program called aplay, or to mix the output channels, using the program called amixer. 

The amixer lets you change all of the user options implemented in the TLV320AIC codec, like various sound levels, mux control, AGC and so on. The block diagram of the codec comes really helpful in understanding what to configure:


For example, to get an output from the high power outputs of the codec (HPLOUT and HPROUT) I need to route the two DACs (L and R) to their respective outputs. For that I would need to look closer into the settings like HP, HP DAC, Left HP Mixer DACL1, Right HP Mixer DACL1 and similar. My basic settings were

amixer is very versatile, but crazy hard to work with. It is a command line program, based on set/get procedure. You need one PocketBeagle ssh session  to play a sound file in a loop, and another session to fiddle with the amixer. I spent an immense amount of time configuring the sound card this way, until I learned there is a much more user friendly, graphic program called alsamixer, where I can configure all of it, using only up and down arrows.

In the end, I managed to get some music playing, but not on my amplifier, where I wanted it. Only when I plugged my headphones in, I got the crisp clear sound coming out. 

Discussions