Saving RaspberryPi sound configuration

One of the things that’s been bothering me with the Raspberry Pi, even though I’m managing it through Puppet, is the sound configuration.

Sometimes the sound is x% lower for no obvious reason, othertimes it goes through HDMI when I wanted it through the 3.5mm jack. Then I have to go figure out how to set it back all over again.

Turns out, the settings are loaded from a file, located at

/var/lib/alsa/asound.state

This means, that by changing some settings and saving again, it’s possible to see which parameters were modified, and then use this to create a template for use in Puppet.

To save the state:

alsactl store

For example, to change the output between auto/analog/hdmi, one would use the following command:

sudo amixer cset numid=3 1

which isn’t very explicit.

In the file, this will change the number corresponding to “value”:

control.3 {
	iface MIXER
	name 'PCM Playback Route'
	value 1
	comment {
		access 'read write'
		type INTEGER
		count 1
		range '0 - 2'
	}
}

On a Raspberry Pi, 0=auto; 1=analog; 2=HDMI.

To modify the output volume, you can set the “Value” in the first control to it’s highest value in the range:

control.1 {
	iface MIXER
	name 'PCM Playback Volume'
	value 400
	comment {
		access 'read write'
		type INTEGER
		count 1
		range '-10239 - 400'
		dbmin -9999999
		dbmax 400
		dbvalue.0 400
	}
}
This entry was posted in Linux, Raspberry Pi, Software and tagged , , , , , . Bookmark the permalink.

Leave a Reply

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