Skip to contentSkip to conversation

software mixing in alsa

DISCUSSION Karel Kulhavy 11 participants 25 messages May 17, 2005 – May 19, 2005

lore
Share & tools
lore
#2 lore raw
Quoted 8 lines · Jan Spitalnik

Dne út 17. května 2005 11:56 Karel Kulhavy napsal(a):

Quoted 6 lines

Hello

http://www.math.tu-berlin.de/~sbartels/alsa/driver/driver.html says "For example, there is currently ongoing work to allow mixing multiple inputs to the pcm devices."

Quoted 4 lines

Hi,

yes, ALSA can mix multiple inputs with its dmix plugin.
http://alsa.opensrc.org/index.php?page=DmixPlugin

Thanks for your reply. I have proceeded according to this "Dmix Howto", however it doesn't work. I have proceeded successfully up to the command "aoss mpg123 some.mp3". When I run this, mp3 is played very fast, in about 1-2 seconds (normal pitch, but skipping very fast forward).

mpg123 Version 0.59s-r9 (2000/Oct/27)
aoss doesn't have --version option
alsaplayer 0.99.76

The document doesn't contain any contact where to send bugreports that the course described actually doesn't work.

Any other idea how to make Skype & XMMS run at the same time on Linux?

CL<

#3 lore raw
Quoted 19 lines · Karel Kulhavy
Quoted 8 lines · Jan Spitalnik

Dne út 17. května 2005 11:56 Karel Kulhavy napsal(a):

Quoted 6 lines

Hello

http://www.math.tu-berlin.de/~sbartels/alsa/driver/driver.html says "For example, there is currently ongoing work to allow mixing multiple inputs to the pcm devices."

Quoted 4 lines

Hi,

yes, ALSA can mix multiple inputs with its dmix plugin.
http://alsa.opensrc.org/index.php?page=DmixPlugin

Thanks for your reply. I have proceeded according to this "Dmix Howto", however it doesn't work. I have proceeded successfully up to the command "aoss mpg123 some.mp3". When I run this, mp3 is played very fast, in about 1-2 seconds (normal pitch, but skipping very fast forward).

Quoted 8 lines

mpg123 Version 0.59s-r9 (2000/Oct/27)
aoss doesn't have --version option
alsaplayer 0.99.76

The document doesn't contain any contact where to send bugreports that the course described actually doesn't work.

Any other idea how to make Skype & XMMS run at the same time on Linux?

Yes, get the Skype developers to add proper ALSA support. If Doom 3 could do it, so can they.

mpg123 is an open source application so there's no excuse for it not to support ALSA in 2005.

Finally, these questions are all OT for LKML. Try alsa-user at lists.sf.net and alsa-devel at lists.sf.net. Also there's a bug reporting system, linked from http://www.alsa-project.org.

Lee

#4 lore raw
Quoted 2 lines · Lee Revell

Finally, these questions are all OT for LKML. Try alsa-user at lists.sf.net and alsa-devel at lists.sf.net. Also there's a bug

ALSA is a part of Linux kernel, right? This is linux-kernel. Why is it OT here? Doesn't make sense for me.

CL<

Quoted 1 line

Lee

#5 lore raw
Quoted 7 lines · Karel Kulhavy
Quoted 2 lines · Lee Revell

Finally, these questions are all OT for LKML. Try alsa-user at lists.sf.net and alsa-devel at lists.sf.net. Also there's a bug

ALSA is a part of Linux kernel, right? This is linux-kernel. Why is it OT here? Doesn't make sense for me.

Well, sort of. The parts of ALSA you are interested in (software mixing and volume control) are implemented in userspace. They live in alsa-lib.

You should at least cc: alsa-devel (non-subscribers can post) when posting ALSA related questions to LKML.

Lee

#6 lore raw
In reply to Karel Kulhavy
Quoted 7 lines · Karel Kulhavy
Quoted 2 lines · Lee Revell

Finally, these questions are all OT for LKML. Try alsa-user at lists.sf.net and alsa-devel at lists.sf.net. Also there's a bug

ALSA is a part of Linux kernel, right? This is linux-kernel. Why is it OT here? Doesn't make sense for me.

I was hoping somebody would explain how to get 'dmix' plugin working in the kernel - then I could get rid of esd ;) (Note that running something in userspace that accepts connections, runs dmix on them, and then creates one thing spewing to /dev/pcm isn't a solution - I've already *got* esd, warts and all)

#7 lore raw
Quoted 6 lines · On Tue, 2005-05-17 at 16:27 -0400, [email protected] wrote:
Quoted 5 lines · Karel Kulhavy
Quoted 2 lines · Lee Revell

Finally, these questions are all OT for LKML. Try alsa-user at lists.sf.net and alsa-devel at lists.sf.net. Also there's a bug

Quoted 7 lines
Quoted 2 lines

ALSA is a part of Linux kernel, right? This is linux-kernel. Why is it OT here? Doesn't make sense for me.

I was hoping somebody would explain how to get 'dmix' plugin working in the kernel - then I could get rid of esd ;) (Note that running something in userspace that accepts connections, runs dmix on them, and then creates one thing spewing to /dev/pcm isn't a solution - I've already *got* esd, warts and all)

I don't understand your message very well. The dmix plugin is part of alsa-lib, which is part of userspace. From the application's point of view, it does not matter whether the mixing happens in kernel or not. ALSA follows the philosophy of doing as little as possible in the kernel, and since mixing and volume control work fine in userspace, that's where they live.

Lee

#8 lore raw

On Tue, May 17, 2005 at 04:36:30PM -0400, Lee Revell wrote:

[...]

Quoted 5 lines

alsa-lib, which is part of userspace. From the application's point of view, it does not matter whether the mixing happens in kernel or not. ALSA follows the philosophy of doing as little as possible in the kernel, and since mixing and volume control work fine in userspace, that's where they live.

Mixing is IMHO action that should be in kernel because

1) needs realtime scheduling to keep latency down
2) needs tight cooperation with the hardware to prevent dropouts on underruns
3) Is a trivial linear algorithm involving memory blocks and linear arithmetic, no complicated computations that are difficult to check for BugFree(TM) so shouldn't present a great risk on kernel stability
4) Fits into the kernel philosophy. Kernel is a program meant to provide time-sharing access to limited hardware resource. Sound card is a limited hardware resource.
5) From the knowledge of the exact hardware, the mixing routine in kernel can know maximum allowable levels etc. to prevent clipping.

CL<

#9 lore raw
Quoted 10 lines · Karel Kulhavy

On Tue, May 17, 2005 at 04:36:30PM -0400, Lee Revell wrote:

[...]

Quoted 5 lines

alsa-lib, which is part of userspace. From the application's point of view, it does not matter whether the mixing happens in kernel or not. ALSA follows the philosophy of doing as little as possible in the kernel, and since mixing and volume control work fine in userspace, that's where they live.

Quoted 3 lines

Mixing is IMHO action that should be in kernel because

1) needs realtime scheduling to keep latency down

With a realtime scheduler and properly written drivers (no "schedule" gaps) you'll reach same results. For x86 we use special instructions like xchg and locking-free algorithm in dmix, so the latency is SAME for all concurent apps with minimal overhead..

Quoted 2 lines

2) needs tight cooperation with the hardware to prevent dropouts on underruns

Yes, but having the code which computes something in interrupt is not sane.

Quoted 4 lines

3) Is a trivial linear algorithm involving memory blocks and linear arithmetic, no complicated computations that are difficult to check for BugFree(TM) so shouldn't present a great risk on kernel stability

You need to write complete new virtual layer or use a new special driver which connect to real soundcard. Thats a lot of new code - it's better to do it safely in the user space.

Quoted 3 lines

4) Fits into the kernel philosophy. Kernel is a program meant to provide time-sharing access to limited hardware resource. Sound card is a limited hardware resource.

Why X drivers aren't in kernel, too? Because they're big and kernel should drive the real bottom of hardware (interrupts, DMA, memory mapping), but abstraction (which sound mixing _IS_) should be implemented in the user space. Otherwise we will end up with a huge kernel implementing nearly everything...

Quoted 2 lines

5) From the knowledge of the exact hardware, the mixing routine in kernel can know maximum allowable levels etc. to prevent clipping.

You can obtain all necessary info in the userspace as well.

We should definitely fix the dmix bugs. Or, if you want, you might buy an accelerated soundcard which supports multiple streams in hardware.

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SUSE Labs

#10 lore raw
Quoted 12 lines · Jaroslav Kysela
Quoted 10 lines · Karel Kulhavy

On Tue, May 17, 2005 at 04:36:30PM -0400, Lee Revell wrote:

[...]

Quoted 5 lines

alsa-lib, which is part of userspace. From the application's point of view, it does not matter whether the mixing happens in kernel or not. ALSA follows the philosophy of doing as little as possible in the kernel, and since mixing and volume control work fine in userspace, that's where they live.

Quoted 8 lines
Quoted 3 lines

Mixing is IMHO action that should be in kernel because

1) needs realtime scheduling to keep latency down

With a realtime scheduler and properly written drivers (no "schedule" gaps) you'll reach same results. For x86 we use special instructions like xchg and locking-free algorithm in dmix, so the latency is SAME for all concurent apps with minimal overhead..

Also doing it in userspace lets us use SSE/MMX.

Lee

#11 lore raw
In reply to [email protected]
Quoted 4 lines · On Tue, May 17, 2005 at 04:27:44PM -0400, [email protected] wrote:

I was hoping somebody would explain how to get 'dmix' plugin working in the kernel - then I could get rid of esd ;) (Note that running something in userspace that accepts connections, runs dmix on them, and then creates one thing spewing to /dev/pcm isn't a solution - I've already *got* esd, warts and all)

In all honesty - don't bother. esd does the job better, faster, more flexibly, and without the hassle.

I have spent many hours attempting to get a usable dmix setup working and I just don't think its possible (at least not with my hardware).

I use esd for all "consumer" level audio apps, and jackd for all professional audio apps. This is by far the simplest way to manage audio - I wouldn't waste your time with dmix. After all, what could you do with dmix that you can't do with esd??

Signature · 8 lines
Ross Vandegrift
[email protected]

"The good Christian should beware of mathematicians, and all those who
make empty prophecies. The danger already exists that the mathematicians
have made a covenant with the devil to darken the spirit and to confine
man in the bonds of Hell."
	--St. Augustine, De Genesi ad Litteram, Book II, xviii, 37
#12 lore raw
Quoted 10 lines · On Wed, 2005-05-18 at 02:30 -0400, [email protected] wrote:
Quoted 4 lines · On Tue, May 17, 2005 at 04:27:44PM -0400, [email protected] wrote:

I was hoping somebody would explain how to get 'dmix' plugin working in the kernel - then I could get rid of esd ;) (Note that running something in userspace that accepts connections, runs dmix on them, and then creates one thing spewing to /dev/pcm isn't a solution - I've already *got* esd, warts and all)

In all honesty - don't bother. esd does the job better, faster, more flexibly, and without the hassle.

This problem is fixed with the upcoming ALSA 1.0.9 release - dmix will "just work". It's been a big area of development lately.

Lee

#13 lore raw
In reply to [email protected]
Quoted 9 lines · On Wed, May 18, 2005 at 02:30:14AM -0400, [email protected] wrote:
Quoted 4 lines · On Tue, May 17, 2005 at 04:27:44PM -0400, [email protected] wrote:

I was hoping somebody would explain how to get 'dmix' plugin working in the kernel - then I could get rid of esd ;) (Note that running something in userspace that accepts connections, runs dmix on them, and then creates one thing spewing to /dev/pcm isn't a solution - I've already *got* esd, warts and all)

In all honesty - don't bother. esd does the job better, faster, more flexibly, and without the hassle.

Is there some generic in-kernel support for mixing? I couldn't make any of the userspace programs work.

I tried esd and it does the same as without esd - only one app gets to the sound and the other waits. The only difference was only (horrible) increase in sound latency.

Installed esd in gentoo by emerge, then added into the startiup scripts, /etc/init.d/esd start, switched xmms over to esd and skype on start said "using esd".

I would like to just run two sound programs concurrently. (Linux is a time-sharing operating system, right?) I am not interested in a delay line sound effect.

I also tried artsd and jack, but didn't succeed too.

CL<

#14 lore raw
In reply to [email protected]

On 18 May 2005, [email protected] uttered the following:

Quoted 3 lines

I use esd for all "consumer" level audio apps, and jackd for all professional audio apps. This is by far the simplest way to manage audio

In my experience, polypaudio replaces esd with something both simpler and more powerful. (Oh, and without esd's *horrible* stutter, interruption, mis-authentication, and code cleanliness problems.)

(For the professional stuff there is no replacement for JACK, I agree.)

Signature · 2 lines
`End users are just test loads for verifying that the system works, kind of
 like resistors in an electrical circuit.' - Kaz Kylheku in c.o.l.d.s
#15 lore raw
In reply to [email protected]

At Tue, 17 May 2005 16:27:44 -0400,

Quoted 4 lines · [email protected] wrote:
Quoted 2 lines · Karel Kulhavy

Lee Revell wrote:

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Finally, these questions are all OT for LKML. Try alsa-user at lists.sf.net and alsa-devel at lists.sf.net. Also there's a bug

ALSA is a part of Linux kernel, right? This is linux-kernel. Why is it OT here? Doesn't make sense for me.

I was hoping somebody would explain how to get 'dmix' plugin working in the kernel - then I could get rid of esd ;)

esd is working fine together with dmix. You should try the latest versions (of esd and alsa-lib). The old version of esd might have a bug.

arts had a problem, but got fixed in the recent version of alsa-lib.

Takashi

#16 lore raw
Quoted 5 lines · Takashi Iwai

esd is working fine together with dmix. You should try the latest versions (of esd and alsa-lib). The old version of esd might have a bug.

I'd beg to differ. I have to apply the patch made by you to avoid getting a lot of distortions with esound and dmix:

http://bugzilla.gnome.org/show_bug.cgi?id=140803

Checking in the cvs, this still hasn't been commited.

Rgds
Pierre

#17 lore raw
Quoted 7 lines · Pierre Ossman
Quoted 5 lines · Takashi Iwai

esd is working fine together with dmix. You should try the latest versions (of esd and alsa-lib). The old version of esd might have a bug.

Quoted 6 lines

I'd beg to differ. I have to apply the patch made by you to avoid getting a lot of distortions with esound and dmix:

http://bugzilla.gnome.org/show_bug.cgi?id=140803

Checking in the cvs, this still hasn't been commited.

You really need to bug the Gnome developers about it. Takashi-san posted the patch in January, and the bug is still listed as NEW.

Lee

#18 lore raw
In reply to Pierre Ossman
Quoted 6 lines · Pierre Ossman

I'd beg to differ. I have to apply the patch made by you to avoid getting a lot of distortions with esound and dmix:

http://bugzilla.gnome.org/show_bug.cgi?id=140803

Checking in the cvs, this still hasn't been commited.

I owe Takashi a beer for creating the patch, and Pierre for bringing it to my attention - it solves the issue I was seeing on Fedora Core where alsa 1.0.9rc2 was hosing up esd.

#19 lore raw
In reply to Karel Kulhavy

Hi!

Quoted 5 lines
Quoted 2 lines

Finally, these questions are all OT for LKML. Try alsa-user at lists.sf.net and alsa-devel at lists.sf.net. Also there's a bug

ALSA is a part of Linux kernel, right? This is linux-kernel. Why is it OT here? Doesn't make sense for me.

You should use most specific list available. That's what they are for. And it seems to me half of your problems is in userspace, so it is indeed off-topic here.
Pavel

#20 lore raw
In reply to Lee Revell
Quoted 2 lines · Lee Revell

mpg123 is an open source application so there's no excuse for it not to support ALSA in 2005.

Its COPYING file says:
This software may be distributed freely, provided that it is distributed in its entirety, without modifications, ...
This doesn't look like an open source license at all. That's why Debian puts mpg123 in non-free.

Karel, you may want to try mpg321 instead. It already has ALSA support.

Michal

#21 lore raw
Quoted 11 lines · Michal Schmidt
Quoted 2 lines · Lee Revell

mpg123 is an open source application so there's no excuse for it not to support ALSA in 2005.

Its COPYING file says:
This software may be distributed freely, provided that it is distributed in its entirety, without modifications, ...
This doesn't look like an open source license at all. That's why Debian puts mpg123 in non-free.

Karel, you may want to try mpg321 instead. It already has ALSA support.

Tried with the same result: fast forward.

CL<

Quoted 2 lines

Michal

#22 lore raw
Quoted 11 lines · Karel Kulhavy
Quoted 10 lines · Michal Schmidt
Quoted 2 lines · Lee Revell

mpg123 is an open source application so there's no excuse for it not to support ALSA in 2005.

Its COPYING file says:
This software may be distributed freely, provided that it is distributed in its entirety, without modifications, ...
This doesn't look like an open source license at all. That's why Debian puts mpg123 in non-free.

Quoted 4 lines
Quoted 1 line

Karel, you may want to try mpg321 instead. It already has ALSA support.

Tried with the same result: fast forward.

Then the problem is probably with your ALSA configuration, or (less likely) an ALSA bug. I suspect your MP3s are 44100 KHz and they are being played at 48000 KHz. Please try ALSA CVS, there have been many improvements since the version in the kernel. If the problem persists, report it on the alsa-user list.

Lee

#23 lore raw
Quoted 12 lines · Lee Revell
Quoted 11 lines · Karel Kulhavy
Quoted 10 lines · Michal Schmidt
Quoted 2 lines · Lee Revell

mpg123 is an open source application so there's no excuse for it not to support ALSA in 2005.

Its COPYING file says:
This software may be distributed freely, provided that it is distributed in its entirety, without modifications, ...
This doesn't look like an open source license at all. That's why Debian puts mpg123 in non-free.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Karel, you may want to try mpg321 instead. It already has ALSA support.

Tried with the same result: fast forward.

Then the problem is probably with your ALSA configuration, or (less likely) an ALSA bug. I suspect your MP3s are 44100 KHz and they are being played at 48000 KHz.

OK, I found this bug report that describes the same problem:

https://bugtrack.alsa-project.org/alsa-bug/view.php?id=1098

The short answer is that you need to have mpg321 use the "plug:dmix" device.

Lee

#24 lore raw

At Tue, 17 May 2005 19:32:22 -0400,

Quoted 19 lines · Lee Revell
Quoted 17 lines · Lee Revell
Quoted 15 lines · Karel Kulhavy
Quoted 11 lines · Michal Schmidt
Quoted 2 lines · Lee Revell

mpg123 is an open source application so there's no excuse for it not to support ALSA in 2005.

Its COPYING file says:
This software may be distributed freely, provided that it is distributed in its entirety, without modifications, ...
This doesn't look like an open source license at all. That's why Debian puts mpg123 in non-free.

Karel, you may want to try mpg321 instead. It already has ALSA support.

Tried with the same result: fast forward.

Quoted 7 lines
Quoted 3 lines

Then the problem is probably with your ALSA configuration, or (less likely) an ALSA bug. I suspect your MP3s are 44100 KHz and they are being played at 48000 KHz.

OK, I found this bug report that describes the same problem:

https://bugtrack.alsa-project.org/alsa-bug/view.php?id=1098

This sounds similar, but I guess it's different.

Quoted 2 lines

The short answer is that you need to have mpg321 use the "plug:dmix" device.

The recent libao opens "default" PCM. So, dmix should work without any changes when you install ALSA 1.0.9(rc3).

Takashi