?

Log in

No account? Create an account
Audio APIs for Linux - “Nightwatch” [entries|archive|friends|userinfo]
"Praxeology rests on the fundamental axiom that human beings engage in conscious actions toward chosen blah blah blah blah blah teh market!"

[ website | Pictures and Stuff ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Audio APIs for Linux [Dec. 5th, 2007|11:20 pm]
“Nightwatch”
[Tags|]
[Current Mood |hungryhungry]

Some observations on Linux desktop audio APIs.


  • ALSA is a nice driver framework. ALSA sucks as a high-level audio API. Stop coding your general desktop use app in it. It is hard to configure and finicky, and most apps that claim to support it (e.g. ZSNES) don't actually support it very well.

  • OSS is great if you are living in the days when a Sound Blaster 16 was a high-level audio card. Unfortunately, these days we need more than one program to be able to play sound at one time. More often than not, ESounD or aRts will be hogging /dev/dsp, resulting in incredibly confusing error messages to the end user. If your app (I'm looking at you, Praat and VMware) still uses OSS, please do us all a favor and upgrade.

  • ESounD is GNOME only and basically works, but for real time apps it is slooooooow.

  • aRts is KDE only, and since Ubuntu is the way things are increasingly going, it's more likely than not not installed on your users' machines.



What does that leave? It's an option that is all too often forgotten:

  • SDL. SDL is simple and it has a remarkable tendency to just work. There are bindings to every language in existence, it's a mature codebase, and it embodies the Unix design philosophy well. Plus, if you write in SDL, you're portable to Windows and Mac OS X too!


I write this after fiddling with audio setting after audio setting in various programs, trying to get them to all work properly together, but to no avail. Then I set all the programs' audio output to SDL, and every single program worked.

If you're writing a Linux audio program, do your users a favor and use SDL by default.
LinkReply

Comments:
[User Picture]From: ralesk
2007-12-06 08:52 am (UTC)
OSS does have multiplexing — if the sound card does too. Not particularly sure how automatic it is (I see people mentioning horrible things like “oh, you should just point your software towards /dev/dsp1 if dsp0 is locked”).

Same problem really as with ALSA: if the sound card doesn’t (which is like 99% of today’s cards as no person bothers buying a sound card anymore), you’re screwed, because inevitably someone will hog the card somehow. dmix has a tendency to save the world, but sometimes not. FreeBSD does some similar things to their OSS, and it too tends to work most of the time (not enough experience with it due to PC-BSD being full of fail and aids with my network cards).

ALSA seems to have severe quality issues, especially when it comes to cards only supporting a certain resolution and ALSA or software set to another. It’ll convert, but it’ll also sound like arse (probably there’s no decent interpolation being done, because that’s “too much CPU” or some bullshit like that).


Another thing that sounds great is the PortAudio libraries. Too bad they’re ridiculously slow at getting V19 out.
(Reply) (Thread)
[User Picture]From: ralesk
2007-12-06 06:36 pm (UTC)
Also. faRts is installed on my Kubuntu o_O Will be finally left to die as KDE 4 rolls out.
(Reply) (Thread)
[User Picture]From: night_watch
2007-12-06 07:31 pm (UTC)
Yeah, I forgot to mention that aRts is deprecated anyhow.

I think SDL is an example of the "all software problems can be solved by adding an additional layer of indirection" principle at work. :D
(Reply) (Parent) (Thread)
[User Picture]From: ralesk
2007-12-06 09:04 pm (UTC)
That’s typically what sound servers tried to do, but all failed at it in an epic manner.

SDL is surprisingly decent, at least there seem to be a few software written on it that happen to be really good. Schism Tracker for example.
(Reply) (Parent) (Thread)