Difference between revisions of "Raspberry Pi ALSA"
From WA2IAC Wiki
(→More on the ALSA Sound Drivers and Utilities) |
(→Volume Control) |
||
Line 71: | Line 71: | ||
== Volume Control == | == Volume Control == | ||
− | The RPi built-in sound chips don’t have a “master volume” control, and as a result, you must control the volume via software. I guess the RPi views itself as a preamplifier (preamp) and volume controls would be supplied down stream. ALSA provides a software volume control using the softvol plugin. | + | The RPi built-in sound chips don’t have a “master volume” control, and as a result, you must control the volume via software. I guess the RPi views itself as a preamplifier (preamp) and volume controls would be supplied down stream. ALSA provides a software volume control using the [http://alsa.opensrc.org/Softvol softvol] plugin. |
− | The /etc/asound.conf file is a configuration files for ALSA drivers (system-wide). The main use of this configuration file is to add functionality. It allows you to create “virtual devices” that pre or post-process audio streams. Any properly written ALSA program can use these virtual devices as though they were normal devices. My RPi /etc/asound.conf file looks like this: | + | The ''/etc/asound.conf'' file is a configuration files for ALSA drivers (system-wide). The main use of this configuration file is to add functionality. It allows you to create “virtual devices” that pre or post-process audio streams. Any properly written ALSA program can use these virtual devices as though they were normal devices. My RPi ''/etc/asound.conf'' file looks like this: |
− | For most changes to /etc/asound.conf you will need to restart the sound server (ie. sudo /etc/init.d/alsa-utils restart) for the changes to take effect. | + | <pre> |
+ | pcm.mmap0 { | ||
+ | type mmap_emul; | ||
+ | slave { | ||
+ | pcm "hw:0.0"; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | pcm.!default { | ||
+ | type plug; | ||
+ | slave { | ||
+ | pcm mmap0; | ||
+ | } | ||
+ | } | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | For most changes to ''/etc/asound.conf'' you will need to restart the sound server (ie. ''sudo /etc/init.d/alsa-utils restart'') for the changes to take effect. | ||
I attempted to implement the software volume controls outline in a softvol how-to that I found, but I couldn’t get it to work. I did some additional digging, and I found a solution buried within a python script for a Adafruit project. The following works for controlling the volume (in this case, reducing the volume to 80% of maximum): | I attempted to implement the software volume controls outline in a softvol how-to that I found, but I couldn’t get it to work. I did some additional digging, and I found a solution buried within a python script for a Adafruit project. The following works for controlling the volume (in this case, reducing the volume to 80% of maximum): |