LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to do Alsa configuration (asoundrc) on-the-run while an application is running? (https://www.linuxquestions.org/questions/linux-general-1/how-to-do-alsa-configuration-asoundrc-on-the-run-while-an-application-is-running-645771/)

satmeet 05-30-2008 02:18 AM

How to do Alsa configuration (asoundrc) on-the-run while an application is running?
 
Hi,
I am new to alsa and need to know if i can contorl the volume on different channels dynamically or on-the-fly by modifying file asoundrc.
We have written the following lines of code-

Code:

pcm.mycard {
    type hw
    card 0
    device 0
}

pcm.dshare {
  type dmix
  ipc_key 2048
  slave{
        pcm mycard
        rate 44100
        period_time 1024
        buffer_size 8192
        channels 2
        }
    bindings{
        0 0
        1 1
      }
}

pcm.conf1 {
        type plug
        slave{
          pcm "dshare"
          channels 2
        }
        ttable.0.0 0.9
        ttable.1.1 0.1
}

This does the volume control statically (one time) the application (mplayer) starts using this device mentioned as 'conf1'. Now, i make following changes to the asoundrc file to

change the volume level on the channels while the application is running.

Code:

        ttable.0.0 0.1
        ttable.1.1 0.9


But the changes do not reflect. I need to restart the application for the changes to take effect.

Is there any way i can achieve this without having to restart the application?
Kindly reply.

shadowsnipes 05-30-2008 09:48 PM

try using amixer

satmeet 06-02-2008 12:07 AM

Thanks for your reply but..
 
We can use amixer for the purpose but how would i be able to control the volume of individual audio streams?
For example-
I have three songs being played by three instances of mplayer at the same time and i want to listen to the three different songs on three different channels/speakers. Or song1 with 90% volume in speaker1 and 10% in speaker2. and song2 with 33% in speaker1 and 33% in speaker2 and rest in speaker3. and so on...

Is it possible?
Does alsa API's provide such a functionality?

Please reply.

Thanks.

shadowsnipes 06-02-2008 09:18 AM

I think you just need to specify the channels you want to change when you use amixer.

Quote:

Originally Posted by man amixer
set or sset <SCONTROL> <PARAMETER> ...
Sets the simple mixer control contents. The parameter can be the
volume either as a percentage from 0% to 100% with % suffix, a
dB gain with dB suffix (like -12.5dB), or an exact hardware
value. The dB gain can be used only for the mixer elements with
available dB information. When plus(+) or minus(-) letter is
appended after volume value, the volume is incremented or decre-
mented from the current value, respectively.

The parameters cap, nocap, mute, unmute, toggle are used to
change capture (recording) and muting for the group specified.

The optional modifiers can be put as extra parameters to specify
the stream direction or channels to apply. The modifiers play-
back and capture specify the stream, and the modifiers front,
rear, center, woofer are used to specify channels to be changed.


A simple mixer control must be specified. Only one device can be
controlled at a time.

Try using the scontrols arg to see what channels you can manipulate. Please see the full man page for amixer for some examples and more details on usage.

Alternatively, if you have more than one soundcard you can split the jobs among them and control them separately.


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