Talk:HOWTO ALSA Complete (includes dmix)

From Gentoo Linux Wiki

Jump to: navigation, search

Contents

[edit] About real HOWTO

this is a great bunch of misc tidbits - someone should massage it into a real HowTo. Start by saying why you need dmix and how it differs from alsamixer.

ALSA already have all info, we (contributors) just put it together for gentoo, and i hope it will grow in terms of hardware specificity. Due to it constant changes i do not see any needs to convert it to the real old fashion HOWTO. Right now, on wiki, anybody who have an idea, can update it right away, compare to a hassel with real HOWTO, but if you want to, you are always welcome :.D'mitri

is it necessarily true that you need non-kernel alsa? I use dmix with alsa-in-kernel, seems to work fine - AlecZorab

No, that part is completely wrong as it is because they forgot to mention that this is for kernel 2.4 only. If you read to the end of that section it says something like "now that was for kernel 2.4, if you're on kernel 2.6 do...". Most users would expect something that important a little earlier then 3 pages into the document.

[edit] Article update

I update the article with a note in the Introduction.
Any ideas are welcome.
Thank you for appreciation.
ΩD'mitri 13:04, 17 Nov 2004 (GMT)


[edit] Music Player Daemon

Could someone add a section on configuring mpd for dmix?

Done

[edit] Consolidate ~/.asoundrc 's to a single file

I'm not sure if anyone really understands this, but all of the chipsets interface with alsa the same. We don't need all of these examples so much as we need one that integrates the comments from all of the others. If someone would like me to do this, I don't mind, but I don't want to edit a huge section of the page (about half the page is sample asoundrc's).

Email: pagerc@gmail.com

[edit] Correction for intel8x0/nforce2 .asoundrc

(Wiki first-timer so sorry if this should be on the front page) What I changed to get sound in Firefox (Flash) to work: (Firefox freezes up upon sound otherwise)

########
# AOSS #
########
# OSS dsp0 device
pcm.dsp0 {
     type plug
#    slave.pcm "duplex" #### DOESN'T WORK
     slave.pcm "dmix" #### WORKS
}

Someone please confirm this besides me... I tried hw:0,0 and that works fine all by itself (XMMS complains something else is using the soundcard while Firefox is doing audio). From my testing, THAT is what gets it working for me.

arkaine@cox.net


[edit] Refactoring

I've cleaned up this HOWTO, which should be less messy now.

It is basically split into: ALSA setup; Apps config; Hardware config.

[edit] alsa-lib not needed for 2.6?

This is mentioned twice, but it sounds to me like it should be *alsa-driver* is not needed for 2.6.

I'm on 2.6 and when I emerged alsa-oss, it depends upon alsa-libs.

== /etc/conf.d/alsasound seems to have changed :

bash-2.05b# cat /etc/conf.d/alsasound

  1. SAVE_ON_STOP:
  2. Do you want to save changes made to your mixer volumes when alsasound
  3. stops?
  4. no - Do not save state
  5. yes - Save state

SAVE_ON_STOP="yes" bash-2.05b#

running equery depends alsa-lib gives following output on my system

linux-box root # equery depends alsa-lib [ Searching for packages depending on alsa-lib... ] gnome-base/control-center-2.8.2 kde-base/arts-1.3.2-r1 kde-base/kdemultimedia-3.3.2 kde-base/arts-3.4.0 kde-base/kdelibs-3.3.2-r9 media-libs/libao-0.8.5 media-libs/openal-20040817 media-libs/libsdl-1.2.8-r1 media-libs/libmikmod-3.1.11-r1 media-libs/xine-lib-1.0-r2 media-plugins/xmms-alsa-1.2.10 media-plugins/gst-plugins-alsa-0.8.8 media-sound/esound-0.2.34 media-sound/alsa-utils-1.0.8 media-sound/beep-media-player-0.9.7-r4 media-video/avifile-0.7.41.20041001-r1 media-video/mplayer-1.0_pre6-r4

so I assume alsa-lib is BADLY needed and what the author means is really alsa-driver that can be safely displayed. BTW, I uninstalled alsa-lib and Alsa immediately gave up. I needed to reinstall it in order to get sound working again.

[edit] Everything works well but still little discomfort

Thank you for the article, I was going to find out how to get sound mexied with Linux and at last I managed to tune everything (almost), but still experience some discomfort with that. I use kernel 2.6, external alsa-deivers, snd-intel8x0 driver on the Intel Corp. 82801DB/DBL/DBM chipset. Here are my problems:

  1. If I drag a window with the mouse during having xmms running or mplayer, both - doesn't metter (I heven't tried anything else) all the sound stops and it resumes only after I release the window (by the way if this window is xmms one then the sound is ok despite the sound source). In addition, if I have the commands typed:
    alsaplayer -o alsa -d plug:dmix some.mp3
    or
    aoss mpg321 some.mp3
    again, all the sound is ok if I drag any of the windows. First I thought it was a problem of my win manager but after tests with these commands I'm not sure of that. Do I have to put option like NON-BLOCKING in the .asoundrc or something like that??? Might it be so that alsa api is used incorrectly by mplayer or xmms plugins?
  2. ANSWER: I'm gonna take a guess that you're using fluxbox and should set "session.opaqueMove: false" in ~/.fluxbox/init. Let us know if that helps
  3. ANSWER-addition-info: I using gentoo:2.6.10 on amd64 running enlightenment 0.16.7.2. I've had this problem with xmms freezing (playback stops) when I moved any window (not sure it included the xmms 'window' itself). I've just got the Alsa:dmix solution in place (xmms-1.2.10-r13; xmms-alsa-1.2.10; alsa-embedded-vanilla-sources-2.6.10; with alsa-lib-1.0.8) - and still the problem - alsaplayer is not affected. The above reply-answer; made me check; and I discovered that any 'Move&Resize Setting' other than 'Opaque' exhibited the problem - strange, but true.
  4. RE:ANSWER: Yes, you're right, but it's set to false and doesn't work.
  5. FIXED: I installed native kernel alsa driver and the problem disappeared.
  6. If I have mplayer and xmms running simultaneously then I tune volume in the xmms, it's independent on the mlayer's, but if do so in the mplayer then it changes volume of the xmms' as well (it changes pcm value that can be seen via the alsamixer).
  7. Before I set up dmix I'd read a few articles about Linux sound system, I've personally tried esound and jack. First one is qute drugged, the second I couldn't adjust properly (problems with mplayer - I have sound but no movie running itself, I couldn't start jackstart, only jackd, as I know jackstart is correct way to have jack working). I'm still confused - what is the best way to have sound mixed, should I play more with jack because it's "a low-latency audio server", why all the deamons are needed if there is the lowermost dmix capability???
  8. ANSWER: jack is a sound mixer, if you intend to mix audio like you would with a mixer, you should use jack. If you're just trying to get multiple applications to play sound at the same time, and your soundcard doesn't support native hardware mixing, you want to enable dmix.

I needn't have set up external drivers as I'm a 2.6 kernel user but read about that too late, should I try internal ones to solve any of the problems???
Thank you.

12:21, 27 Mar 2005 (GMT)

[edit] This is a PITA

We really need to get some way of doing this in a reasonable manner for the end user.

I consider myself reasonably advanced, and following this HOWTO gives me a headache just looking at it. How in the world can I convince my less savvy friends leave windows if they can't play MP3s and get system sounds at the same time without doing this?

This is the problem with the sound-system today, what would work best (in my head atm atleast) would be support for mixing on kernel-level so the end-user doesnt need to play with configs just to get a basic soundsystem, then configs/userspace-tools for tweaking.

I didn't find it that hard to follow, just potentially confusing if you don't read the whole thing before starting. It should be reorganized. I'd do it myself but, considering how busy I am, someone else will probably have done it by the time I come back. --StephanSokolow 20:57, 5 Apr 2005 (GMT)

[edit] System-wide configuration

I should point out that all of this can be done using system-wide configuration files. For example, /etc/asound.conf instead of ~/.asoundrc

That's what I did when I put Gentoo on my brother's dual-boot system and it works very well.

My experience was that I couldn't get my mixing to work right unless I set it in the /etc/asound.conf file with the following dmixer device:

File: /etc/asoundrc.conf
pcm.dmixer { 
    type dmix 
    ipc_key 1024
    ipc_key_add_uid false
    ipc_perm 0666			# mixing for all users
    slave { 
        pcm "hw:0,0" 
        period_time 0 
        period_size 1024 
        buffer_size 8192
        rate 44100
    }
    bindings { 
        0 0 
        1 1 
    } 
} 

pcm.dsp0 { 
    type plug 
    slave.pcm "dmixer" 
} 

pcm.!default { 
    type plug 
    slave.pcm "dmixer" 
} 

pcm.default { 
   type plug 
   slave.pcm "dmixer" 
} 

ctl.mixer0 { 
    type hw 
    card 0 
}

Note that this was because I am starting the Music Player Daemon (MPD) from init scripts and it is running as the "MPD" user. This configuration allows all users to share the dmix device. In case you want to know, this is on a nforce3 board.

[edit] Misc. Corrections and Observations

mmap mode works fine for xmms, I didn't need to use any of the special tweaks for mplayer, and I didn't need any of the via82xx tweaks either. The system in question uses Asus A7V8X-X on-board audio.

[edit] qpkg deprecated

"qpkg is now deprecated and has been removed from gentoolkit. It has been supplanted with equery." - Portage for RPM Users

I was going to fix the page myself but I've realized that I don't know how to translate the commands.

Alright, I've added the following paragraph to the article, feel free to correct it: Please note that qpkg has become deprecated and been replaced by equery. If after emerging gentoolkit gpkg still is not installed, try the following:

# equery -i list *alsa*
[ Searching for package '*alsa*' in all categories among: ]
 * installed packages
[I--] [  ] media-libs/alsa-lib-1.0.8 (0)
[I--] [  ] media-plugins/xmms-alsa-1.2.10 (0)
[I--] [  ] media-plugins/gst-plugins-alsa-0.8.7-r1 (0.8)
[I--] [  ] media-sound/alsa-headers-1.0.8 (0)
it's ok, but equery list alsa is sufficient. Dunno what -i stands for, but '*'s are surely not neccessary. -- ph
(-i = search installed packages, it's default) -- digits

[edit] Alsa and multiple soundcards?

There are two things that I can't find any good documentation on, and they are

- Use two soundcards, both play the same sound

- Use two soundcards as if they where one with a lot more speakers

85.167.53.16 13:04, 13 August 2006 (UTC): Found http://alsa.opensrc.org/TwoCardsAsOne that explains how to do this. The example given explains how to gain more channels, but by adjusting the routing table like this: pcm.ttable {

  type route;
  slave.pcm "multi";
  ttable.0.0 1;
  ttable.1.1 1;
  ttable.0.2 1;
  ttable.1.3 1;
}

you get the multi-device to play the same sound on both cards.

Also of interest is http://quicktoots.linuxaudio.org/toots/el-cheapo/ on how to record using multiple soundcards with a slight hardware modification.

[edit] GStreamer setup w/o gnome-media

I'm not using gnome, but I like to setup gstreamer to use the dmix device. What do I need to write down in which xml file of ~/.gestreamer-*/?

[edit] Difficult howto

Though I consider myself a geek, and have a Gentoo system fully running, I can't seem to understand this HOWTO. Someone with the proper knowledge about ALSA/OSS/dmix should write a new howto with step-by-step-waltthrough for newbies (and me). Maybe splitting this page up into more pages would help?

[edit] DMIX in 1.09

doesn't seem like the article is correct. DMIX is definately not enabled on my computer by default in alsa 1.09b.

[edit] NEW ALSA SIMPLE AND UPDATE TO MY ASOUNDRC

Wanted to point out I'm creating an ALSA simple for those that don't understand all this non-sense. Also, it seems firefox and flash have a problem with AOSS compat when the ctl.mixer0 is used. Just fyi.

[edit] Severely rewritten

I completely rewrote a good portion of this HOWTO while still keeping most of the information that was previously there. Check it out and throw me some feedback. I'm also going to see about changing the name of the HOWTO to Setting Up ALSA or HOWTO ALSA since this incorporates both setting up alsa AND setting up dmix. I think calling it ALSA sound mixer aka dmix is misleading for this document. I'll change the name in a week's time if nobody objects.

nice howto isn't it mpg123 instead of mpg321, with me that's the only one that exists?????????

pjv

[edit] some more typo's

the part for xmms says to use "dmixer", but it only works with "dmix" at my pc (maybe is related to not using an .asoundrc) also i need to DISABLE the multi-thread mode checkbox (above the mmap checkbox) otherwise i just get : ALSA lib pcm_dmix.c:819:(snd_pcm_dmix_open) unable to open slave

i haven't changed all this in the wiki yet, waiting for confirmation

tip: you could make a clearer gnome section, not everyone knows which drivers/libs are used by gnome, for instance gstreamer

greetz, pjv

[edit] Softlinking

Under the Firefox section, it referred to changing the Firefox softlink. I changed it to symlink for clarity (symlink is the correct term). It was confusing me and some other people initially.

[edit] 5.1 fix Emu10k1

if you have an analog 5.1 setup, you need to mute Analog/Digital Output Jack

[edit] sequencer

I don't understand how the sequenser can work. In Linux Kernel Configuration: Kernel Configuration (2.6.15 Example) the Sequencer Support is not checked, so it will not be compiled in the kernel.

A good thing to do would be to advise power users as musicians at they will need the Virtual MIDI soundcard in Generic devices.--Dominique 71 10:52, 18 March 2006 (GMT)

[edit] Timidity and Arts

Timidity can be used as an software synthesizer. Even better, it can be launched during init in server mode. This results in a software midi player. The command

> pmidi -l

lists the synthesizer ports available, e.g. 128:0. Then

> pmidi -p 128:0 some.mid

plays the midi file. However, when Arts is running at the same time, ALSA claims the sound device, and pmidi remains silent.

And vice-versa, when a midi file is playing, Arts cannot play a sound file simultaneously.

The desired behaviour is that Timidity puts it sound into the dmix device, and simultaneously Arts too.

The solution is to tell ALSA to use the dmix device instead of output. The following adaption of the duplex device in the .asoundrc may be helpful

file: .asoundrc

# Set default sound card
# Useful so that all settings can be changed to a differen card here.
pcm.snd_card {
    type hw
    card 0
    device 0
}

# Allow mixing of multiple output streams to this device
pcm.output {
    type dmix
    ipc_key 1024
    ipc_perm 0660 # Sound for everybody in your group!
    slave.pcm "snd_card"

    slave {
         # This stuff provides some fixes for latency issues.
         # buffer_size should be set for your audio chipset.
         period_time 0
         period_size 1024
         buffer_size 8192
    }

    bindings {
         0 0
         1 1
    }
}

# Allow reading from the default device.
# Also known as record or capture.
pcm.input {
    type dsnoop
    ipc_key 2048
    ipc_key_add_uid yes
    slave.pcm "snd_card"

## Possible artsd full duplex fix:
    slave {
         period_time 0
         period_size 1024
         buffer_size 8192
         rate 48000
    }

    bindings {
         0 0
         1 1
    }
}

# This is what we want as our default device
# a fully duplex (read/write) audio device.
#
# The "output" device seems to block all other sound requests
# of other users, e.g. the Timidity server started at boot time
# The "dmix" device works
pcm.duplex {
    type asym
#     playback.pcm "output" 
    playback.pcm "dmix"
    capture.pcm "input"
}

###################
# CONVERSION PLUG #
###################
# Setting the default pcm device allows the conversion
# rate to be selected on the fly.
# duplex mode allows any alsa enabled app to read/write
# to the dmix plug (Fixes a problem with wine).
pcm.!default {
    type plug
    slave.pcm "duplex"
}

# Apparently this is wrong (breaks mplayer for me opening the
# device)
#ctl.!default {
#     type plug
#     slave.pcm "snd_card"
#}

########
# AOSS #
########
# OSS dsp0 device (OSS needs only output support, duplex will 
# break some stuff)
pcm.dsp0 {
    type plug
    slave.pcm "output"
}

# OSS control for dsp0 (needed?...this might not be useful)
ctl.dsp0 {
    type plug
    slave.pcm "snd_card"
}

# OSS control for dsp0 (default old OSS is mixer0)
ctl.mixer0 {
    type plug
    slave.pcm "snd_card"
}

[edit] Does not meet quality standards

This HOWTO has lots of good information, but needs to be restructured and reworded so that a it is more clear. If it was on wikipedia it would have a big flag: Does not meet quality standards.

[edit] Atomization?

Perhaps split it to many small articles. Any other ideas? :.Dmitri 04:08, 4 June 2006 (UTC)

[edit] Firefox

This section is now uncomprehendable with strikethroughs and no proper explanation any more!!. FIX THIS Changing the last line of /usr/bin/firefox to "exec aoss ..." doesn't work. It complains with:

/usr/bin/firefox: line 10: exec: aoss: not found

Nevermind, it was because I didn't have alsa-oss emerged.

1 dirty solution:

  1. exec /usr/libexec/mozilla-launcher "$@"

aoss /usr/libexec/mozilla-launcher "$@"

[edit] poor quality

Yeah, I've been trying to keep this HOWTO in check, however, I don't personally use dmix, so all I can do is assume that the information contained is correct and try to keep it structured. I have been able to keep the Installing ALSA section very organized, but the dmix section needs to be reworked entirely by someone with knowledge on every aspect of it. Please, someone just sit down and give us a bit of your knowledge! :)

As far as merging this article with ALSA, I don't think that fits. ALSA is just a definition of it, then it gives seperate links to HOWTO articles.

--JBDubbs Jason Weisberger

[edit] Kernel 2.6.16

When you say at it is a problem with a 2.6.16 kernel, do you know exactly which problem it is? I am doing a new fresh 2006.1 install on a free partiton, and I have 2 identical 2.6.16-rt29 kernels. The other relevant pacakges as udev, hotplug, coldplug, alsa-driver are the same and the configuration is the same.

It work like a charm with my old 2006.0 gcc3.4.5 install, but with the new 2006.1 gcc4.1.1, udev load the snd_usb_audio before alsasound, so the order of my sound cards get skrewed. I solved this by adding the snd_usb_audio module in /etc/hotplug/blacklist so It will not be loaded by udev but by alsasound in the expected order. --Dominique 71 15:11, 6 September 2006 (UTC)

[edit] Microphone recording

In alsamixer, press F4 to see the Capture view. Raise the microphone capture level appropriately. It took me several days to figure this one out... including reading dozens of misleading/outdated/overly complicated posts everywhere. Had I known it was this simple...

[edit] Userspace firmware loading support

I have been installing Gentoo again the past few days and have been doing ALSA today. I ran across a problem while emerging alsa-driver that I thought could be documented on the Wiki. For emu10k1 cards (Creative), alsa-driver-1.0.14* won't emerge unless this option is enabled in the kernel:

Device Drivers -> Generic Driver Options -> Userspace firmware loading support

This information was found on the Bugzilla.

[edit] Buggy IRQ

Some sound cards interrupts so much

[edit] Wiki structure

[23/08/2007] I definitely think it is too long with too much varied information in one place. HOWTO_ALSA should provide only what is essential for everyone to configure ALSA: additional issues such as dmix, multiple cards and specific applications should have their own page with links to them from the main HOWTO_ALSA.

However, since gentoo.org's ALSA guide is pretty good, I'm not sure that duplicating that work would be time well spent. Perhaps concentrating on specific issues like dmix and the 2.4 kernel would be better?


[edit] GAIM -> pidgin

Gaim has changed its name a while ago.