LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   read & change audio volume (https://www.linuxquestions.org/questions/linux-software-2/read-and-change-audio-volume-4175538042/)

rbees 03-27-2015 03:22 PM

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.

dijetlo 03-28-2015 04:35 AM

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.


All times are GMT -5. The time now is 03:16 AM.