Re How to do Alsa configuration (asoundrc) on-the-run while an by loe13858

VIEWS: 19 PAGES: 5

									     Re: How to do Alsa configuration (asoundrc) on−the−run while an application is running?

Re: How to do Alsa configuration (asoundrc)
on−the−run while an application is running?

Source: http://linux.derkeiler.com/Newsgroups/comp.os.linux.misc/2008−06/msg00114.html



     • From: satmeet.ubhi@xxxxxxxxx
     • Date: Tue, 3 Jun 2008 04:52:47 −0700 (PDT)

On Jun 2, 10:10 pm, Dances With Crows <danceswithcr...@xxxxxxx> wrote:

       satmeet.u...@xxxxxxxxx staggered into the Black Sun and said:




               On May 30, 7:39 pm, Dances With Crows <danceswithcr...@xxxxxxx>
               wrote:

                      satmeet.u...@xxxxxxxxx staggered into the Black Sun and
                      said:

                              I am new to [ALSA] and need to know if I
                              can [control] the volume on
                              different channels dynamically or
                              on−the−fly by modifying [the] file
                              asoundrc.

                      Um, no. Adjusting volumes is done by writing to or
                      ioctl()ing
                      /dev/sound/mixer .

                              mplayer starts. [Then], I make [the]
                              following changes to the
                              asoundrc file to change the volume level on
                              the channels while the
                              application is running.

                      Yeah, apps typically read their config files only on startup.

                              Is there any way I can achieve this without
                              having to restart the
                              application?

                      The easiest (but least efficient) way to do this is to call
                      amixer
                      directly with appropriate args when you want to change the

Re: How to do Alsa configuration (asoundrc) on−the−run while an application is running?        1
     Re: How to do Alsa configuration (asoundrc) on−the−run while an application is running?
                       volume.

                                 Kindly reply.

                       If you meant "reply via e−mail", then that is Not Done,
                       because
                       conversations that start on Usenet should remain on Usenet
                       unless
                       they get off−topic.


       Did you understand that paragraph? If you did, why did you send this
       article to my e−mail address? This conversation is relevant to the
       newsgroup topic, and was started here, so it should remain here.


               But how would I be able to control the volume of individual audio
               streams?


       /dev/sound/mixer controls the channels on a particular sound device. If
       you have apps that are playing sounds, you may have to tell those apps
       to change their settings directly, rather than using the mixer. This is
       one of those times where Details Count, and you haven't provided many of
       those details.


               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.


       Whoa. That's pretty far out, most people can't even listen to 2 songs
       at once without missing substantial parts of both songs. Were these
       songs sent to different output devices or channels? Or is this some
       sort of club setup (3 rooms, each with a different audio stream
       playing)?


               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?


       Maybe. It depends on the setup. Provide exact specs. How many sound
       devices do you have? How are the speakers hooked up? How was each
       instance of the audio−playing program started? How have you configured
       ALSA?


               Does [ALSA] provide [this] functionality?

Re: How to do Alsa configuration (asoundrc) on−the−run while an application is running?        2
      Re: How to do Alsa configuration (asoundrc) on−the−run while an application is running?


        ALSA provides a set of kernel modules that drive sound cards and a
        standardized interface to those modules. Having an application send
        output to multiple devices at once is probably possible, but I don't
        know for sure how to do it and it might be app−dependent. I have one
        soundcard and 2 speakers, am not an audio tech or an audiophool, and
        don't need to record anything, so my sound experience is not as
        extensive as some. And I don't know whether the ALSA mailing list or
        the mplayer documentation is the best place for you to go next just yet.
        Ah well, answer the questions and maybe someone will know.

        −−
        The night passed like a kidney stone: painfully and with the help of
        major sedatives. −−T. Delgado, Lyttle Lytton winner, 2001
        My blog and resume:http://crow202.dyndns.org:8080/wordpress/
        Matt G|There is no Darkness in Eternity/But only Light too dim for us to see


−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Hello,
I agree that "/dev/sound/mixer controls the channels on a particular
sound device.".
1) I'll describe the problem statement and code more clearly to you
now. :−)

I have a ~/.asoundrc file as −

<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{
00
11
}

}

Re: How to do Alsa configuration (asoundrc) on−the−run while an application is running?         3
      Re: How to do Alsa configuration (asoundrc) on−the−run while an application is running?


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

</code>

I use this file by specifying the nodes( conf1 and conf2) while
starting an audio application.
(for mplayer the command is mplayer −ao alsa:device=conf1 or mplayer −
ao alsa:device=conf2)

So mplayer(1) would read the configuration (ttable) for conf1 and
would set the volume as 90% in right channel and 10% in left channel.
And similarly mplayer(2) would have 10% in right channel and 90% in
left channel.

I am able to achieve this. But when it comes to changing the settings,
say for mplayer(1) 30% in Right channel and 70% in Left channel,
without interrupting mplayer(1) I am not able to do so.

Other example of my problem can be described as−
Say,I have four speakers (4.1 channel speakers and a soundcard
supporting 4.1 channels) and a ~/.asoundrc file setup as i need. Now,
mplayer(1) plays sound in only front two speakers (front left and
front right).and mplayer(2) plays sound in rear two speakers (rear
left and rear right). While both the mplayers are running, can i swap
the speaker settings (by changing ~/.asoundrc )so that mplayer(2) now
plays in front speakers and mplayer(1) plays sound in rear speakers
(without stopping/quitting mplayer).

Is there any ALSA api that would reload the alsa settings and changes
would immediately take effect? Or any other solution.

Audio Setup − 4.1 speakers and a supported sound card(6 channel)


Re: How to do Alsa configuration (asoundrc) on−the−run while an application is running?         4
      Re: How to do Alsa configuration (asoundrc) on−the−run while an application is running?

Hope I am clear this time.

Kindly reply.

Thanks.
.




Re: How to do Alsa configuration (asoundrc) on−the−run while an application is running?         5

								
To top