LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 06-09-2014, 11:03 AM   #1
charlemagne-is-my-son
Member
 
Registered: Dec 2012
Location: Shanghai
Distribution: Xubuntu, 14.04
Posts: 54

Rep: Reputation: Disabled
How to set audio input device and volume from terminal?


Ubuntu 12.04

Hi. I record with Audacity often, and I am wondering how I can avoid the hassle of opening the sound manager, selecting the mic I plug in, and setting the volume. I'd like to run an alias command which prepares all this for me.

Thx!
 
Old 06-09-2014, 12:19 PM   #2
Pearlseattle
Member
 
Registered: Aug 2007
Location: Zurich, Switzerland
Distribution: Gentoo
Posts: 985

Rep: Reputation: 118Reputation: 118
Not sure if you're referring to some specific "sound mgr" or to a frontend for the ALSA settings - if it's the second case then, concerning the volume, you can check the current volume with...
amixer -c 0 cget numid=13
...where "-c" is your soundcard number (if you have more than 1) and "numid" is the control ID that you want to check (e.g. the "Master" volume or anything else that you see in "alsamixer".
You'll get back something like...
Code:
# amixer cget numid=13
numid=13,iface=MIXER,name='Master Playback Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=127,step=0
  : values=109
  | dBscale-min=-95.25dB,step=0.75dB,mute=1
...where "values=109" is your current volume.

To modify the volume then use...
amixer -c 0 cset numid=13 50
...which lowered it in my case from 109 to 50.
 
Old 06-09-2014, 04:24 PM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,231

Rep: Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914
Code:
amixer set Master 15
 
1 members found this post helpful.
Old 06-10-2014, 12:30 PM   #4
Pearlseattle
Member
 
Registered: Aug 2007
Location: Zurich, Switzerland
Distribution: Gentoo
Posts: 985

Rep: Reputation: 118Reputation: 118
Quote:
Originally Posted by schneidz View Post
Code:
amixer set Master 15
I admit that often my approach is not the simpliest one
 
Old 06-14-2014, 01:06 AM   #5
charlemagne-is-my-son
Member
 
Registered: Dec 2012
Location: Shanghai
Distribution: Xubuntu, 14.04
Posts: 54

Original Poster
Rep: Reputation: Disabled
Specificy

Ok. I was vague in my question. Let me restate it. First, I'm running Ubuntu 12.04. I'm not sure which sound software my computer runs. Alsa? Pulseaudio? Not sure.

I use an external microphone when I record music. After plugging in the external mic, I need to go into the Settings and Sound to select the external mic instead of the Internal Microphone which is the default.

1) How can I either make it switch to that mic automatically, or write a script which will do it automatically?

Secondly, after I select the external mic, I have to adjust the amplification of the mic each time. Unamplified, the sound it picks up is rather low and unusable in my recordings.

2) How can I set the amplification automatically? This would probably be in the same script I asked about in question 1)

Please let me know if this is nonsense.

Ubuntu
 
Old 06-14-2014, 10:05 AM   #6
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,231

Rep: Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914
2)^
Quote:
Originally Posted by schneidz View Post
Code:
amixer set Master 15
not sure but does this not change the volume for you:
Code:
[schneidz@hyper stuff]$ amixer set Capture 90 rec
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch cswitch-joined penum
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 65536
  Front Left: Capture 90 [0%] [on]
  Front Right: Capture 90 [0%] [on]
?

what does the output of amixer give you ?
also arecord -l

Last edited by schneidz; 06-14-2014 at 10:14 AM.
 
Old 06-14-2014, 10:13 AM   #7
charlemagne-is-my-son
Member
 
Registered: Dec 2012
Location: Shanghai
Distribution: Xubuntu, 14.04
Posts: 54

Original Poster
Rep: Reputation: Disabled
amixer output

Code:
matt@matt-NV57H:~/Music/my-music$ amixer
Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined penum
  Playback channels: Mono
  Limits: Playback 0 - 87
  Mono: Playback 87 [100%] [0.00dB] [on]
Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch penum
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 87
  Mono:
  Front Left: Playback 87 [100%] [0.00dB] [on]
  Front Right: Playback 87 [100%] [0.00dB] [on]
Simple mixer control 'Speaker',0
  Capabilities: pvolume pswitch penum
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 87
  Mono:
  Front Left: Playback 46 [53%] [-30.75dB] [on]
  Front Right: Playback 87 [100%] [0.00dB] [on]
Simple mixer control 'PCM',0
  Capabilities: pvolume penum
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 255
  Mono:
  Front Left: Playback 255 [100%] [0.00dB]
  Front Right: Playback 255 [100%] [0.00dB]
Simple mixer control 'Mic',0
  Capabilities: pvolume pswitch penum
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Mono:
  Front Left: Playback 0 [0%] [-34.50dB] [off]
  Front Right: Playback 0 [0%] [-34.50dB] [off]
Simple mixer control 'Mic Boost',0
  Capabilities: volume penum
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 3
  Front Left: 0 [0%] [0.00dB]
  Front Right: 0 [0%] [0.00dB]
Simple mixer control 'IEC958',0
  Capabilities: pswitch pswitch-joined penum
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'Beep',0
  Capabilities: pvolume pswitch penum
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Mono:
  Front Left: Playback 0 [0%] [-34.50dB] [off]
  Front Right: Playback 0 [0%] [-34.50dB] [off]
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch penum
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 31
  Front Left: Capture 8 [26%] [-4.50dB] [on]
  Front Right: Capture 8 [26%] [-4.50dB] [on]
Simple mixer control 'Auto-Mute Mode',0
  Capabilities: enum
  Items: 'Disabled' 'Enabled'
  Item0: 'Enabled'
Simple mixer control 'Digital',0
  Capabilities: cvolume penum
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 120
  Front Left: Capture 60 [50%] [0.00dB]
  Front Right: Capture 60 [50%] [0.00dB]
Simple mixer control 'Internal Mic',0
  Capabilities: pvolume pswitch penum
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Mono:
  Front Left: Playback 0 [0%] [-34.50dB] [off]
  Front Right: Playback 0 [0%] [-34.50dB] [off]
Simple mixer control 'Internal Mic Boost',0
  Capabilities: volume penum
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 3
  Front Left: 3 [100%] [36.00dB]
  Front Right: 3 [100%] [36.00dB]
 
Old 06-14-2014, 10:27 AM   #8
charlemagne-is-my-son
Member
 
Registered: Dec 2012
Location: Shanghai
Distribution: Xubuntu, 14.04
Posts: 54

Original Poster
Rep: Reputation: Disabled
My Microphone

I ran
Code:
lsusb
to find the USB microphone I plug in and got this:

Code:
Bus 002 Device 009: ID 074d:0005 Micronas GmbH
How can I order the computer to select this mic over the internal mic?

Thanks!

Edit:

Here is the other output you asked for:

Code:
matt@matt-NV57H:~/Music/my-music$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC271X Analog [ALC271X Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: Snowball [Blue Snowball], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Last edited by charlemagne-is-my-son; 06-14-2014 at 10:29 AM.
 
Old 06-14-2014, 10:34 AM   #9
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,231

Rep: Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914
your soundcard/s have a lot of devices; not sure which refers to the 2nd mic.
what i would do to narrow things down is run:
amixer > audio-settings.bad
when the pc first boots up. then set everything up the way i like manually; then run again:
amixer > audio-settings.good
and:
diff audio-settings.bad audio-settings.good
to get a good idea of what changed ?
 
Old 06-14-2014, 10:41 AM   #10
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,231

Rep: Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914
oh since its usb it should be probed upon connection and take over the audio in/out (at least thats what i remember when i used a headset).

maybe someone smarter than me who knows how to set up udev rules will reply.

i would hax together some script daemon that would constantly check lsusb for the existence of the usb headset and run the requisite amixer commands.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set the behavior when input command exceeds terminal max columns yech Linux - General 3 03-12-2013 06:22 PM
[SOLVED] How do I set the default audio device? Stragard Linux - Software 1 09-05-2011 05:16 PM
Low volume with alsa on nVidia audio device duffydac Debian 3 03-06-2010 05:31 PM
How can I set the default audio device? Hangdog42 Slackware 7 03-24-2009 07:30 AM
Pvr 250 How to set Audio Input? Tuzinor Linux - Software 1 08-06-2004 02:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 09:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration