Alsamixer is one of the Linux audio architecture ALSA tools used to configure the various parameters of audio.
Alsamixer is based on the graphical interface under the text, can be through the keyboard keys, left and right keys, etc., it is convenient to set the required volume, switch switches (switches) and so on, is In the Ubuntu12.04 system configuration interface, the operation is very simple, here is the use of Ubuntu12.04 line-in function (to achieve stereo function):
Sound playback output channel settings:
Sound input device Channel settings:
The author tests the line-in function of Ubuntu12.04, so select the audio input channel as line.
Amixer, is the alsamixer text mode, that is, command line mode, you need to use the form of amixer command to configure the various options of your sound card, so to speak, you may directly modify the Linux kernel audio driver source to meet your needs, such as the choice of audio input channel is the mic input, or line input, you need to modify the WM9714 register to decide, and amixer can modify the audio chip register value from the application layer, decided to use MIC input or line input. This greatly simplifies the difficulty of code modification, after all, it is easier than directly modifying the Linux Kernel Alsa.
For the use of amixer, you first need to understand what parameters you want to set, and then it is possible to understand, how to configure the corresponding value, overall, relative to Alsamixer, is a bit cumbersome, the following brief introduction of its specific usage:
1. Take a look at what commands the amixer supports, and what the features are about
# 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 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 Abstraction level (None or Basic)
-S,--stdin & nbsp; 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 &nbs p; set contents for one mixer simple control
Sget sid Get contents for one mixer simple control
controls Show all controls for given card
contents Show contents of all controls for given card
Cset CID p& nbsp; Set control contents for one control
Cget cid Get control contents for one control
2. Take a look at your current audio system (different audio drivers correspond to different content and operating interfaces) that provide the interfaces you use to operate
about how many interfaces the driver has provided can be manipulated, with commands:
Amixer contents
To view, for example:
[[Email protected]]#./amixer controls
Numid=49,iface=mixer,name= ' headphone MIXER Aux Playback Volume '
Numid=43,iface=mixer,name= ' headphone MIXER Beep Playback Volume '
Numid=32,iface=mixer,name= ' headphone Playback ZC Switch '
Numid=4,iface=mixer,name= ' Headphone Playback Switch '
Numid=3,iface=mixer,name= ' Headphone Playback Volume '
Numid=6,iface=mixer,name= ' PCM Playback Volume '
Numid=5,iface=mixer,name= ' line in Volume '
Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
And for all the configured values, you can print through amixer contents :
[[email protected]]#./amixer contents
numid=49,iface=mixer,name= ' headphone MIXER Aux Playback Volume '
; TYPE=INTEGER,ACCESS=RW---R--, values=1,min=0,max=7,step=0
: values=5
| dbscale-min=-15.00db, Step=3.00db,mute=0
numid=43,iface=mixer,name= ' headphone MIXER Beep Playback Volume '
Type=integer, ACCESS=RW---R--, values=1,min=0,max=7,step=0
: values=5
| dbscale-min=-15.00db,step=3.00db,mute =0
numid=32,iface=mixer,name= ' headphone Playback ZC Switch '
TYPE=BOOLEAN,ACCESS=RW------, values=2
: Values=off,off
> ...
3. Figure out how to set a parameter
Summed up is that the first to use the Get series command to understand what interfaces, and then go with the set series of commands, to set the corresponding values you want to set.
If you want to set a setting, such as the volume of the line-in input above, ' linein Volume ', which is displayed in the controls:
Numid=5,iface=mixer,name= ' line in Volume '
So, you can look at the current value first:
[[email protected]]#./amixer cget numid=5,iface=mixer,name= ' line in Volume '
Numid=5,iface=mixer, Name= ' line in Volume '
TYPE=INTEGER,ACCESS=RW---R--, values=2,min=0,max=31,step=0
: values=23,23
| dbscale-min=-34.50db,step=1.50db,mute=0
shows a maximum volume of 31, assuming you want to set to 25, then use CSET to set:
# amixer cset numid=5,iface=mixer,name= ' line in Volume '
[Email protected]]#. /amixer Cset numid=5,iface=mixer,name= ' line in Volume ' 25
Numid=5,iface=mixer,name= ' line in Volume '
; TYPE=INTEGER,ACCESS=RW---R--, values=2,min=0,max=31,step=0
: values=25,25
| Dbscale-min=-34.50db,step=1.50db,mute=0
[Hint]:
The Cget/cset series commands as 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 series of commands, to achieve simple parameter settings, generally use Scontrols, scontents can meet your needs.
Scontrols Show All mixer 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
The same approach, such as:
[[email protected]]#./amixer scontrols
Simple mixer control ' headphone ', 0
Simple mixer control ' headphone mixer Aux ', 0
Simple mixer control ' headphone mixer Beep ', 0
Simple mixer control ' Hea Dphone Playback ZC ', 0
Simple mixer control ' Tone ', 0
-Simple mixer control ' Tone cut-off ', 0
Simple mixer control ' B The 0
Simple mixer control ' bass control ', 0
-mixer control ' bass cut-off ', 0
Simple mixer control ' PCM ', 0< Br>simple mixer control ' Sidetone Mux ', 0
simple mixer control ' line in ', 0-----------(here is the parameter that sets the volume of the Line-in, Same as above set line-in volume function)
Simple mixer control ' Mic 1 ', 0
Simple mixer control ' mic 1 preamp ', 0
Simple mixer C Ontrol ' Mic 2 ', 0
Simple mixer control ' mic 2 preamp ', 0
Simple mixer control ' mic A Source ', 0
Simple mixer control ' Mic B Source ', 0
。。。
Simple mixer control ' left Capture source ', 0 (this is very important, the audio source input is selected)
Simple mixer control ' right Capture source ', 0 (choice of audio source input)
。。。
Similarly,amixer scontents, you can see all the current values, specifically not listed here.
In addition, go to view or configure with Sget, for example:
[[Email protected]]#./amixer Sget ' left Capture Source ', 0
Simple mixer control ' left Capture Source ', 0
Capabilities:enum
Items: ' Mic 1 ' mic 2 "line" Mono in "headphone" ' Speaker ' mono out ' en '
ITEM0: ' Mic 1 '
If you want to modify the corresponding settings, use Amixer sset, the specific usage is:
Amixer sset SID (Control string) P (one of the supported values)
Where Sid, is the string above simple mixer control, such as ' left Capture Source ' and set to it,
[[Email protected]]#./amixer Sset ' left Capture Source ', 0 line
Simple mixer control ' left Capture Source ', 0
Capabilities:enum
Items: ' Mic 1 ' mic 2 "line" Mono in "headphone" ' Speaker ' mono out ' en '
ITEM0: ' Line '
Then set the right channel input source to line-in:
[[email protected]]#./amixer Sset ' right Capture Source ', 0 line
simple Mixer control ' right capture Source ', 0
Capabilities:enum
Items: ' Mic 1 ' mic 2 ' line ' mono in ' headphone ' Speaker ' mono out ' Zh '
This allows your device to record with the line-in function.
Execute command:
[[Email protected]]#./arecord-f cd-c 1-t wav my-file.wav
Recording WAVE ' My-file.wav ': Signed-bit Little Endian, rate 44100 Hz, Mono
Start line-in Recording, the-C 1 for Mono, and 2 for stereo use.
To play the sound file you just recorded:
. [[Email Protected]]#./aplay my-file.wav
Playing WAVE ' my-file.wav ': Signed-bit Little Endian, rate 44100 Hz, Mono
The use of alsamixer in the audio subsystem