Recording sound using ALSA from string IN

I developed a small application that records audio using the ALSA driver into the embedded system.
Now I have a problem with choosing the device that I want to record from MIC / Line IN.
The application is configured to start at system startup, but my recorder is set to MIC by default. For my application to work, I have to go to amixer and install the recorder from MIC to Line IN, and then run my application.

You guys know a way to make this change from the application command or amixer, which will change this recorder, and I can put it in a script, run it at startup.

I said that this application works in the embedded system, and I need to configure the system before running the application.

EDIT1:
here is my amixer output:

root@freescale ~$ amixer Simple mixer control 'Headphone',0 Capabilities: volume Playback channels: Front Left - Front Right Capture channels: Front Left - Front Right Limits: 0 - 127 Front Left: 103 [81%] Front Right: 103 [81%] Simple mixer control 'Playback',0 Capabilities: volume Playback channels: Front Left - Front Right Capture channels: Front Left - Front Right Limits: 0 - 192 Front Left: 192 [100%] Front Right: 192 [100%] Simple mixer control 'Capture',0 Capabilities: cvolume Capture channels: Front Left - Front Right Limits: Capture 0 - 15 Front Left: Capture 15 [100%] Front Right: Capture 15 [100%] Simple mixer control 'Capture Vol Reduction',0 Capabilities: enum Items: 'No Change' 'Reduced by 6dB' Item0: 'No Change' Simple mixer control 'ADC Mux',0 Capabilities: enum Items: 'MIC_IN' 'LINE_IN' Item0: 'MIC_IN' Simple mixer control 'DAC Mux',0 Capabilities: enum Items: 'DAC' 'LINE_IN' Item0: 'DAC' Simple mixer control 'MIC GAIN',0 Capabilities: enum Items: '0dB' '20dB' '30dB' '40dB' Item0: '0dB' 

Thanks a lot, Gabriel

+6
source share
2 answers

I finally did it. I am using amixer with the "cset" command to do this.

 amixer -c 0 cset numid=7 1 

"- c 0" - the first sound card
"numid = 7" is a recorder that is active.
"1" is the second input ... in my case 0-MIC 1-LINEIN

 amixer info 

Gets all controls with their ex numbers:

  amixer info Card default 'mxsevk'/'mxs-evk (SGTL5000)' Mixer name : '' Components : '' Controls : 7 Simple ctrls : 7 root@freescale ~$ amixer contents numid=5,iface=MIXER,name='Headphone Volume' ; type=INTEGER,access=rw---,values=2,min=0,max=127,step=0 : values=103,103 numid=7,iface=MIXER,name='ADC Mux' ; type=ENUMERATED,access=rw---,values=1,items=2 ; Item #0 'MIC_IN' ; Item #1 'LINE_IN' : values=1 numid=3,iface=MIXER,name='Capture Vol Reduction' ; type=ENUMERATED,access=rw---,values=1,items=2 ; Item #0 'No Change' ; Item #1 'Reduced by 6dB' : values=0 numid=2,iface=MIXER,name='Capture Volume' ; type=INTEGER,access=rw---,values=2,min=0,max=15,step=0 : values=15,15 numid=4,iface=MIXER,name='Playback Volume' ; type=INTEGER,access=rw---,values=2,min=0,max=192,step=0 : values=192,192 numid=6,iface=MIXER,name='DAC Mux' ; type=ENUMERATED,access=rw---,values=1,items=2 ; Item #0 'DAC' ; Item #1 'LINE_IN' : values=0 numid=1,iface=MIXER,name='MIC GAIN' ; type=ENUMERATED,access=rw---,values=1,items=4 ; Item #0 '0dB' ; Item #1 '20dB' ; Item #2 '30dB' ; Item #3 '40dB' : values=0 
+2
source

If alsactl is available, you can customize the I / O / level values ​​to your liking and run

 alsactl -f settings.alsa store 

and vice versa,

 alsactl -f settings.alsa restore 

at startup.

0
source

Source: https://habr.com/ru/post/915404/


All Articles