Alsamixer is one of the Alsa tools in the Linux audio architecture ALSA. It is used to configure various audio parameters.
Alsamixer is based on the graphic interface under the text. You can easily set the desired volume, switch a switch, and perform other operations through the upper and lower keys of the keyboard, left and right keys, etc.
Amixer is the text mode of alsamixer, that is, the command line mode. You need to configure the options of your sound card in the form of amixer commands.
To use amixer, you must first understand the parameters you want to set before you can understand how to configure the corresponding values. In general, compared with alsamixer, it is a bit cumbersome. The following describes the specific usage:
1. First, let's take a look at what commands are supported by amixer and what functions are available.
#Amixer -- Help
Usage: amixer <Options> [command]
Available options:
-H, -- help this help
-C, -- card n select the card
-D, -- Device N select the device, default 'default'
-D, -- debug mode
-N, -- nocheck do not perform range checking
-V, -- version print version of this program
-Q, -- quiet Be quiet
-I, -- inactive show also inactive controls
-A, -- Abstract l select distinct action level (none or basic)
-S, -- stdin read and execute commands from stdin sequentially
Available commands:
Scontrols show all mixer simple controls
Scontents show contents of all mixer simple controls (default command)
Sset Sid p set contents for one mixer simple control
Sget Sid get contents for one mixer simple control
ControlsShow all controls for given card
ContentsShow contents of all controls for given card
Cset CID p set control contents for one control
Cget CID get control contents for one control
2. Check that your audio system (different audio drivers correspond to different content and operation interfaces) provides interfaces for you to operate.
You can run the following command to determine the number of interfaces provided in the driver:
Amixer Contents
View, such:
#Amixer controls
Numid = 3, iface = mixer, name = 'master mode switch'
Numid = 29, iface = mixer, name = 'master MUX'
Numid = 4, iface = mixer, name = 'master quality switch'
Numid = 2, iface = mixer, name = 'master switch'
Numid = 1, iface = mixer, name = 'master volume'
Numid = 7, iface = mixer, name = 'PCM mode switch'
Numid = 6, iface = mixer, name = 'PCM switch'
Numid = 5, iface = mixer, name = 'PCM volume'
Numid = 21, iface = mixer, name = 'line input switch'
Numid = 16, iface = mixer, name = 'line mode switch'
Numid = 27, iface = mixer, name = 'line MUX'
.....
Numid = 9, iface = mixer, name = 'mic switch'
Numid = 8, iface = mixer, name = 'mic volume'
Numid = 19, iface = mixer, name = 'adc mode switch'
Numid = 28, iface = mixer, name = 'adc MUX'
........
Check which configuration parameters are supported by your Linux kernel. As shown above, there are more than 20 parameters available for you to configure.
For all of the configuration values of course, you can view them through this:
#Amixer Contents
Numid = 3, iface = mixer, name = 'master mode switch'
; Type = enumerated, access = RW ------, values = 1, items = 2
; Item #0 'common buffer off'
; Item #1 'common buffer on'
: Values = 0
..........
Numid = 5, iface = mixer, name = 'PCM volume'
; Type = integer, access = RW --- r --, values = 2, min = 0, max = 27, step = 0
: Values = 27,27
| Dbscale-min =-40.50db, step = 1.50db, mute = 0
Numid = 24, iface = mixer, name = 'mixer ADC mix switch'
; Type = Boolean, access = RW ------, values = 1
: Values = off
Numid = 26, iface = mixer, name = 'mixer DAC mix switch'
; Type = Boolean, access = RW ------, values = 1
: Values = on
Numid = 25, iface = mixer, name = 'mixer line mix switch'
; Type = Boolean, access = RW ------, values = 1
: Values = on
Numid = 23, iface = mixer, name = 'mixer mic mix switch'
; Type = Boolean, access = RW ------, values = 1
: Values = on
3. Understand how to set a parameter
To sum up, you must first use get commands to understand the interfaces, and then use the set commands to set the values you want to set.
If you want to set a certain volume, for example, to set the volume of the Master, Master volume, that is, the value displayed in controls:
Numid = 5, iface = mixer, name = 'PCM volume'
Then, you can first look at the current value:
#Amixer cget numid = 5, iface = mixer, name = 'PCM volume'
Numid = 5, iface = mixer, name = 'PCM volume'
; Type = integer, access = RW --- r --, values = 2, min = 0, max = 27, step = 0
: Values = 27,27
| Dbscale-min =-40.50db, step = 1.50db, mute = 0
The maximum value is 27. If you want to set it to 25, use cset to set it:
#Amixer cset numid = 5, iface = mixer, name = 'PCM volume '25
Numid = 5, iface = mixer, name = 'PCM volume'
; Type = integer, access = RW --- r --, values = 2, min = 0, max = 27, step = 0
: Values = 25, 25
| Dbscale-min =-40.50db, step = 1.50db, mute = 0
For example, disable the 'mic supply switch:
#Amixer cset numid = 12, iface = mixer, name = 'mic supply Switch 'off
Numid = 12, iface = mixer, name = 'mic supply Switch'
; Type = enumerated, access = RW ------, values = 1, items = 2
; Item #0 'on'
; Item #1 'off'
: Values = 1
The usage is summarized as follows:
A parameter output in amixer cget controls
The specific value of a parameter output in amixer cset controls (for example, 0, 1, on, off, etc)
Tip]
The cget/cset commands described above:
Controls show all controls for given card
Contents show contents of all controls for given card
Cset CID p set control contents for one control
Cget CID get control contents for one control
Similarly, there is another set of sget/sset commands:
Scontrols show all mixer simple controls
Scontents show contents of all mixer simple controls (default command)
Sset Sid p set contents for one mixer simple control
Sget Sid get contents for one mixer simple control
This is also the same practice, for example:
Check which options can be controlled:
#Amixer scontrols
Simple mixer control 'master', 0
Simple mixer control 'master mode', 0
Simple mixer control 'master MUX ', 0
Simple mixer control 'master quality', 0
...
Likewise,Amixer scontentsTo view all the current values, which are not listed here.
In addition, to view or configure sget, for example:
#Amixer sget 'microphone input', 0
Simple mixer control 'microphone input', 0
Capabilities: pswitch-joined
Playback channels: Mono
Mono: playback [off]
If you want to modify the corresponding settings, use amixer sset. The specific usage is as follows:
Amixer sset Sid (control string) P (A value supported)
The SID is the string following the simple mixer control above, such as 'master MUX ', 0
The setting is to first check which values are provided for you:
#Amixer sget 'master MUX ', 0
Simple mixer control 'master MUX ', 0
Capabilities: Enum
Items: 'sum''dac ''line ''mic'
Item0: 'dac'
For example, you can set it to line:
#Amixer sset 'master MUX ', 0 line
Simple mixer control 'master MUX ', 0
Capabilities: Enum
Items: 'sum''dac ''line ''mic'
Item0: 'line'