LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-27-2015, 03:22 PM   #1
rbees
Member
 
Registered: Mar 2004
Location: northern michigan usa
Distribution: Debian Squeeze, Whezzy, Jessie
Posts: 921

Rep: Reputation: 46
read & change audio volume


Ladies & Gents,

I have two audio streams that I use on a regular basis. Switching back and forth between these streams is somewhat automated via a bash script. But the volume of one stream is higher than the other and so there is a need to manually adjust the volume when switching between them.

My goal is to fully automate this. With that in mind I was wondering if there was a way that the in-comming stream volume could be determined before any local processing was done or during processing so that the volume could be adjusted via alsamixer(?) to an appropriate level.

Note that one of the streams is some what unstable where the volume is concerned. Sometimes there is mostly silence, at others it is quite loud.

Yes I know that with a little time, testing and effort, the required volumes can be determined and hard-coded into the script. I would rather avoid that if possible as later I want to offer the user a choice of streams. I don't have the time to test each one, and then my levels may not be the greatest for someone else.

I have looked at ffmpg and sox briefly but not enough to know if they will do what i want with a live stream.

So far google has no revealed a coarse of action.

Thanks.
 
Old 03-28-2015, 04:35 AM   #2
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
Code:
bash-4.3$ amixer get Master Playback
Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 31
  Mono: Playback 30 [97] [-1.50dB] [on]

bash-4.3$ amixer set Master Playback 10
Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 31
  Mono: Playback 10 [32] [-31.50dB] [on]
[/quote]
or, if you want to suppress the helpful output...
[quote]
bash-4.3$ amixer set Master Playback 20 1>> /dev/null

bash-4.3$ amixer get Master Playback                 
Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 31
  Mono: Playback 20 [65] [-16.50dB] [on]
Quote:
Sometimes there is mostly silence, at others it is quite loud.
Probably the most effective automation implementation I can think of is just have it cycle up and down between your minimum (+10, maybe) and max until it gets a keystroke and then exit the volume manipulation function.

Hope that's what you're looking for.

Last edited by dijetlo; 03-28-2015 at 12:04 PM. Reason: Didn't actually answer your question
 
  


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
Enable Volume bar popup on volume change in XFCE 4 thebombzen Linux - Software 0 03-30-2012 04:05 PM
Problem with maximum audio volume + volume control threshold mensch Debian 6 10-10-2008 10:48 AM
Cannot change volume for USB Audio card lpwevers Linux - Hardware 4 10-10-2008 07:40 AM
Keyboard volume knob configuration-cannot change volume. Ariox Ubuntu 1 03-22-2007 02:06 PM
How to change volume/audio settings using the command line? brynjarh Linux - Newbie 3 07-08-2004 10:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:42 AM.

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
Open Source Consulting | Domain Registration