Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Painless sound mixing using ALSA
View unanswered posts
View posts from last 24 hours

Goto page 1, 2, 3, 4  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
yaneurabeya
Veteran
Veteran


Joined: 13 May 2004
Posts: 1754
Location: Seattle

PostPosted: Sat Apr 30, 2005 10:50 pm    Post subject: Painless sound mixing using ALSA Reply with quote

This Doc is only meant to supplement the preexisting ALSA guide offered by the Gentoo folks.

Just thought I might want to add to the existing information about sound mixing using alsa. Here's what you need to do in order to use sound mixing in ALSA (note the length of the documentation as opposed to other threads).

First off, in place of ~x86 or ~amd64 I inserted ~arch just to ensure that the guide is more general. So insert whatever ~arch you feel your PC falls under.

Another note: supposedly ALSA full software soundmixing has been enabled by default as of alsa-driver-1.0.9_rc2, so in the future this package may become stable in portage and as such will not require the ~arch unstable keyword in /etc/portage/package.keywords.

For those with ALSA support compiled into the kernel (and are not running a kernel version greater than 2.6.11):

First off, you must get rid of any preexisting ALSA modules in your kernel.

Remove ALSA settings in your kernel:
Code:
cd /usr/src/linux; make menuconfig


(from the menuconfig screen)
Code:

Device Drivers --->
    Sound  --->
        Advanced Linux Sound Architecture  ---> #once you have this highlighted, press 'N' to remove all support from your kernel.
        Choose Exit.
    Choose Exit.
Choose Exit and save config.


Backup your config so you don't have to redo from scratch after mrproper's finished:
Code:
cp /usr/src/linux/.config /wherever/you/want/bk.cfg


Make mrproper in order to get rid of any preexisting ALSA junk in your kernel:
Code:
cd /usr/src/linux; make mrproper


Use your favorite kernel compile method (I use my personal kernel compile script since I don't like genkernel's bloat, but to each his or her own since there are varying people with varying setups out there...).

Code:
#!/bin/bash
#

version='gentoo-2.6.11-r6' #insert your actual kernel version in here though; see uname -r for more details or use your own custom name here.

cd /usr/src/linux; make menuconfig; make; make bzImage modules modules_install;
rm -f /boot/System.map*; cp System.map /boot/System.map-${version}; cp arch/i386/boot/bzImage /boot/${version};


Once the menuconfig screen comes up, choose "Load an Alternate Configuration File" and load bk.cfg from wherever you saved it to. Exit menuconfig and choose yes to save your config.

Simple install method or for those who no longer have ALSA compiled into their kernel (also applies to those who removed ALSA support from their kernel in the previous steps):

Add the following lines to /etc/portage/package.keywords:
Code:
media-sound/alsa-driver ~arch
media-sound/alsa-headers ~arch
media-sound/alsa-tools ~arch
media-libs/alsa-lib ~arch


Note: Also, make sure to delete any preexisting /etc/asound.conf and ~/.asoundrc files as they will only serve to confuse ALSA or will prevent it from mixing properly (unless you know what the heck you're doing :)).

Then the line you've all been waiting for...
Code:
emerge alsa-driver && emerge --oneshot alsa-tools alsa-lib


Reboot your PC and you should be done :).

If after rebooting your pc you get issues about not being able to resolve certain kernel modules, you need to run either make mrproper or make clean, or do not use --no-mrproper or the --no-clean flags with genkernel.


Last edited by yaneurabeya on Sun May 22, 2005 2:10 am; edited 7 times in total
Back to top
View user's profile Send private message
codergeek42
Bodhisattva
Bodhisattva


Joined: 05 Apr 2004
Posts: 5142
Location: Anaheim, CA (USA)

PostPosted: Sun May 01, 2005 12:34 am    Post subject: Reply with quote

It should be noted that the in-kernel ALSA drivers are version 1.0.9-rc2 for Linux 2.6.12-rc3 (and I think 2.6.12-rc2 also uses it). This is availanle with the ~arch masked sys-kernel/vanilla-sources ebuild. You should also be using version 1.0.9-rc2 of the userspace utilities (alsa-lib and alsa-tools, maybe alsa-firmware if your card requires it) :)
_________________
~~ Peter: Programmer, Mathematician, STEM & Free Software Advocate, Enlightened Agent, Transhumanist, Fedora contributor
Who am I? :: EFF & FSF
Back to top
View user's profile Send private message
yaneurabeya
Veteran
Veteran


Joined: 13 May 2004
Posts: 1754
Location: Seattle

PostPosted: Sun May 01, 2005 12:36 am    Post subject: Reply with quote

True, but it's not required... oh well... I'll add those refs.
Back to top
View user's profile Send private message
gnychis
Veteran
Veteran


Joined: 23 Mar 2005
Posts: 1004
Location: Pittsburgh, PA

PostPosted: Sun May 01, 2005 8:34 am    Post subject: Reply with quote

Thanks for the guide!

and your response to my post :)

Don't forget to mention putting ALSA_CARDS="your-card" into your /etc/make.conf

and one other bug... you have in your code "media-lib/alsa-lib", it should be "media-libs/alsa-lib" :)
Back to top
View user's profile Send private message
gnychis
Veteran
Veteran


Joined: 23 Mar 2005
Posts: 1004
Location: Pittsburgh, PA

PostPosted: Sun May 01, 2005 8:55 am    Post subject: Reply with quote

okay, so i did exactly what you said, and i have:
Code:

root@monster hedpe # emerge --pretend alsa-driver alsa-utils alsa-lib alsa-headers

These are the packages that I would merge, in order:

Calculating dependencies ...done!
[ebuild   R   ] media-sound/alsa-driver-1.0.9_rc2 
[ebuild   R   ] media-sound/alsa-utils-1.0.8 
[ebuild   R   ] media-libs/alsa-lib-1.0.9_rc2-r1 
[ebuild   R   ] media-sound/alsa-headers-1.0.9_rc2 


But when I try to open two sound streams at once with aoss, or by running xmms and aoss... or running xmms with gaim, the sound is not mixing, one plays its sound, and the others sound doesn't come out until the other one stops. If i try two aoss's i get "Can't open /dev/dsp"

what should my ~/.asoundrc file look like? right now it is:
Code:

pcm.intel8x0 {
  type hw
  card 0
}

ctl.intel8x0 {
  type hw
  card 0
}


Alsa, when I boot my system, when it runs /etc/init.d/alsasound, i get an error like "Could not find custom ALSA settings... loading all modules"
I don't understand it, I had this problem before I took modules out of my kernel build.

Thanks!
George
Back to top
View user's profile Send private message
Cintra
Advocate
Advocate


Joined: 03 Apr 2004
Posts: 2111
Location: Norway

PostPosted: Sun May 01, 2005 10:50 am    Post subject: Reply with quote

codergeek42 wrote:
It should be noted that the in-kernel ALSA drivers are version 1.0.9-rc2 for Linux 2.6.12-rc3 (and I think 2.6.12-rc2 also uses it). This is availanle with the ~arch masked sys-kernel/vanilla-sources ebuild. You should also be using version 1.0.9-rc2 of the userspace utilities (alsa-lib and alsa-tools, maybe alsa-firmware if your card requires it) :)

Are you using the 1.0.9-rc2 versions of alsa-lib & -headers with alsa built-in to vanilla-sources-2.6.12-rc3 without the 'arts consuming 100% cpu' problem?
mvh
_________________
"I am not bound to please thee with my answers" W.S.
Back to top
View user's profile Send private message
codergeek42
Bodhisattva
Bodhisattva


Joined: 05 Apr 2004
Posts: 5142
Location: Anaheim, CA (USA)

PostPosted: Sun May 01, 2005 1:38 pm    Post subject: Reply with quote

Cintra wrote:
Are you using the 1.0.9-rc2 versions of alsa-lib & -headers with alsa built-in to vanilla-sources-2.6.12-rc3 without the 'arts consuming 100% cpu' problem?
Yes, I am. Except I don't use arts. But I can play music in Rhtyhmbox and still have sounds from zflag and gaim all at once with ALSA's software mixing.
_________________
~~ Peter: Programmer, Mathematician, STEM & Free Software Advocate, Enlightened Agent, Transhumanist, Fedora contributor
Who am I? :: EFF & FSF
Back to top
View user's profile Send private message
BlindSpy
Apprentice
Apprentice


Joined: 20 Mar 2004
Posts: 263

PostPosted: Sun May 01, 2005 7:28 pm    Post subject: Reply with quote

Cintra wrote:
codergeek42 wrote:
It should be noted that the in-kernel ALSA drivers are version 1.0.9-rc2 for Linux 2.6.12-rc3 (and I think 2.6.12-rc2 also uses it). This is availanle with the ~arch masked sys-kernel/vanilla-sources ebuild. You should also be using version 1.0.9-rc2 of the userspace utilities (alsa-lib and alsa-tools, maybe alsa-firmware if your card requires it) :)

Are you using the 1.0.9-rc2 versions of alsa-lib & -headers with alsa built-in to vanilla-sources-2.6.12-rc3 without the 'arts consuming 100% cpu' problem?
mvh


wouldn't using alsa software mixing make using arts pointless?
_________________
Symlinks to:
xorg.conf
Back to top
View user's profile Send private message
codergeek42
Bodhisattva
Bodhisattva


Joined: 05 Apr 2004
Posts: 5142
Location: Anaheim, CA (USA)

PostPosted: Sun May 01, 2005 7:42 pm    Post subject: Reply with quote

BlindSpy wrote:
wouldn't using alsa software mixing make using arts pointless?
Exactly. 8)
_________________
~~ Peter: Programmer, Mathematician, STEM & Free Software Advocate, Enlightened Agent, Transhumanist, Fedora contributor
Who am I? :: EFF & FSF
Back to top
View user's profile Send private message
yaneurabeya
Veteran
Veteran


Joined: 13 May 2004
Posts: 1754
Location: Seattle

PostPosted: Mon May 02, 2005 1:20 am    Post subject: Reply with quote

Remove your .asoundrc file and nuke your /etc/asound.conf file. By default you don't need any settings I believe other than the /etc/modules.d/alsa settings (or at least that's all I needed)... The .asoundrc will just confuse ALSA, so toss the old settings.

Now, I'm not sure if soundcards that don't have full hardware mixing will allow mixing still with this new ALSA extension (notes the angry Nvidia chipset users out there 0_0).
Back to top
View user's profile Send private message
codergeek42
Bodhisattva
Bodhisattva


Joined: 05 Apr 2004
Posts: 5142
Location: Anaheim, CA (USA)

PostPosted: Mon May 02, 2005 1:38 am    Post subject: Reply with quote

yaneurabeya wrote:
Now, I'm not sure if soundcards that don't have full hardware mixing will allow mixing still with this new ALSA extension (notes the angry Nvidia chipset users out there 0_0).
I think most cards now do. My onboad card (a VIA 82C686A/B rev50 with ICE1232 as reported in my dmesg using the via82xx ALSA driver) does not support native hardware mixing but ALSA mixes things for me automagically.
_________________
~~ Peter: Programmer, Mathematician, STEM & Free Software Advocate, Enlightened Agent, Transhumanist, Fedora contributor
Who am I? :: EFF & FSF
Back to top
View user's profile Send private message
gnychis
Veteran
Veteran


Joined: 23 Mar 2005
Posts: 1004
Location: Pittsburgh, PA

PostPosted: Mon May 02, 2005 3:48 am    Post subject: Reply with quote

my intel sound chipset is the same chipset that is used on the nvidia nforce motherboards, does this mean i am crap out of luck?

Does alsa-utils also have to be emerged? The gentoo guide says it is mandatory, but you do not mention it.

Thanks!
George
Back to top
View user's profile Send private message
gnychis
Veteran
Veteran


Joined: 23 Mar 2005
Posts: 1004
Location: Pittsburgh, PA

PostPosted: Mon May 02, 2005 4:09 am    Post subject: Reply with quote

update!

Okay, i took my .asoundrc file and everything, and now when i try to start two audio streams i get:

Code:

hedpe@monster rap mix $ aoss mpg321 nelly\ -\ country\ grammer.mp3
ALSA lib pcm_dmix.c:725:(snd_pcm_dmix_open) unable to open slave
No default libao driver available.


One stream works, but I get that error trying to open a second stream... ideas?
Back to top
View user's profile Send private message
Crazor
Tux's lil' helper
Tux's lil' helper


Joined: 23 Apr 2003
Posts: 131

PostPosted: Mon May 02, 2005 9:04 am    Post subject: Reply with quote

I followed this great tip and got it working, kinda..

when I listen to music with xmms via the alsa output plugin, I can hear gaim sounds (which is set to auto-detect my sound settings).
TeamSpeak does not work, even when I try aoss.. It used to work to some degree (i.e. when not using another oss app like cedega) with dmix before, but I'd like to stick with the method from this tip because I always hated the hard-to-setup dmix thingie...
so any chance to get oss apps using alsa mixing?

I will try recompiling all alsa related things just to make sure aoss etc. all use the new software mixing.
Back to top
View user's profile Send private message
oneeyedelf1
Tux's lil' helper
Tux's lil' helper


Joined: 04 Feb 2004
Posts: 124

PostPosted: Mon May 02, 2005 6:24 pm    Post subject: Re: Painless sound mixing using ALSA Reply with quote

yaneurabeya wrote:

Reboot your PC and you should be done :).


naw just reboot your alsa
Code:
/etc/init.d/alsasound restart


Also im still getting pops using alsa, how does one go about fixing that?
Back to top
View user's profile Send private message
chetan13
Tux's lil' helper
Tux's lil' helper


Joined: 02 Jul 2003
Posts: 125
Location: chennai,india

PostPosted: Mon May 02, 2005 6:58 pm    Post subject: Reply with quote

this works... thanks a lot for the tip. i never could succesfully set up software mixing previously.

For the record, this is a intel d865 motherboard. i think the sound card has strings like AD1985, AC'97 in it(don't remember what they mean). The driver was compiled into the kernel(2.6.12-rc3). the alsa-lib and alsa-headers packages are both 1.0.9-rc2.

once again, thanks for the tip.

chetan
Back to top
View user's profile Send private message
irondog
l33t
l33t


Joined: 07 Jul 2003
Posts: 715
Location: Voor mijn TV. Achter mijn pc.

PostPosted: Tue May 10, 2005 8:43 am    Post subject: Reply with quote

So, programs don't need to be aware of dmix anymore? Any program opening the soundcard now uses software mixing by default?

That would be great!!!

I'll be waiting for 2.6.12 to be released before trying it. But I really like this stuff.
_________________
Alle dingen moeten onzin zijn.
Back to top
View user's profile Send private message
irondog
l33t
l33t


Joined: 07 Jul 2003
Posts: 715
Location: Voor mijn TV. Achter mijn pc.

PostPosted: Tue May 10, 2005 10:37 am    Post subject: Reply with quote

Couldn't wait and it's fucking great!!!

After I installed 2.6.12-rc4 it didn't work. I added this to /etc/portage/package.keywords:
Code:
media-sound/alsa-headers ~x86
media-libs/alsa-lib ~x86


Reinstall alsa
Code:
emerge --oneshot alsa-headers alsa-lib


Now it plays simultaniously without being aware it's software mixing:
Code:
aplay /usr/kde/3.3/share/sounds/KDE_Startup_new.wav & aplay /usr/kde/3.3/share/sounds/KDE_Window_Open.wav &


Goodbye ARTS, ESD and dmix!

update: doesn't work on programs that use the OSS emulation layer.
_________________
Alle dingen moeten onzin zijn.
Back to top
View user's profile Send private message
alinv
Guru
Guru


Joined: 19 Nov 2002
Posts: 395
Location: Bucharest

PostPosted: Tue May 10, 2005 11:33 am    Post subject: Reply with quote

Nice work!

BTW, I had to remove :device=dmixer from mplayer.conf to get it working with the new setup.
_________________
Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better.
S.B.
Back to top
View user's profile Send private message
yaneurabeya
Veteran
Veteran


Joined: 13 May 2004
Posts: 1754
Location: Seattle

PostPosted: Wed May 11, 2005 5:38 am    Post subject: Re: Painless sound mixing using ALSA Reply with quote

oneeyedelf1 wrote:
yaneurabeya wrote:

Reboot your PC and you should be done :).


naw just reboot your alsa
Code:
/etc/init.d/alsasound restart


Also im still getting pops using alsa, how does one go about fixing that?


Uhm, just making sure that anything odd doesn't occur with old kernel alsa modules, etc. I'm not really a big fan of restarting because most of the time you can do stuff without restarting in Linux, but I do get leary when it involves the kernel directly or indirectly.

Sure, np about the tip. I just threw it together on the fly because I thought it was an important find. Can't really comment much though as I'm busy with school lately.

Take care and I'm sure that someone will help you if you have issues ;). PM me if you have anything important to add.
Back to top
View user's profile Send private message
allex87
Apprentice
Apprentice


Joined: 02 Aug 2003
Posts: 154
Location: Ontario, Canada

PostPosted: Wed May 11, 2005 10:56 am    Post subject: Reply with quote

Does this work on NVidia NForce2 on-board soundcards? They use the intel-8x0 driver.


Alex.
Back to top
View user's profile Send private message
michaelg
n00b
n00b


Joined: 11 Jul 2004
Posts: 16

PostPosted: Wed May 11, 2005 11:26 pm    Post subject: Reply with quote

allex87 wrote:
Does this work on NVidia NForce2 on-board soundcards? They use the intel-8x0 driver.


Alex.



Looks like it doesn't.

I followed the tip, but while running XMMS and then
Code:
[michaelg@beastier ~] ->mpg123 ./pobeda/stages_data/stage13/honyak_kormlenie-nemtsev_57313.mp3
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2 and 3.
Version 0.59s-r9 (2000/Oct/27). Written and copyrights by Michael Hipp.
Uses code from various people. See 'README' for more!
THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!
Can't open /dev/dsp!
Back to top
View user's profile Send private message
allex87
Apprentice
Apprentice


Joined: 02 Aug 2003
Posts: 154
Location: Ontario, Canada

PostPosted: Wed May 11, 2005 11:50 pm    Post subject: Reply with quote

Well, the /dev/dsp is for OSS. Try setting the output driver to ALSA, not OSS. I'll try it right now.

Alex.
Back to top
View user's profile Send private message
allex87
Apprentice
Apprentice


Joined: 02 Aug 2003
Posts: 154
Location: Ontario, Canada

PostPosted: Thu May 12, 2005 12:43 am    Post subject: Reply with quote

NICE, it works :)

Using nitro-sources-2.6.12-rc4 which can be found in Unsupported Software.

Works great, as in I was able to play a song with rhythmbox and a wave file with aplay.



Alex.
Back to top
View user's profile Send private message
alinv
Guru
Guru


Joined: 19 Nov 2002
Posts: 395
Location: Bucharest

PostPosted: Thu May 12, 2005 8:40 am    Post subject: Reply with quote

I couldn't get arts working in a consistent way, so I gave up using it. Amarok is using gstreamer for output and kde notifications are handled by aplay. But now I have to kill kde by hand when restarting or shutting down the computer. Never had this problem with dmix :(
_________________
Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better.
S.B.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum