Saturday, November 19, 2005

Bloody noise

Right. Sound.

Sound was never a major feature of Linux when I started out with it more than 10 years ago. MP3s hadn't been invented back then, the only thing I really needed sound for was Doom.

But things have changed, so when I came back to it a few years ago, I was glad to find Alsa had been created. Of course, it still presented some problems, but overall, sound worked.

The main problem that people complained of was that Alsa only lets you play one thing at a time. This was, in my book, an advantage.

The people who complained, you see, where the Windowsy people who switched over to KDE or Gnome and, as on Windows, had a DE which plays noises for the most mundane reasons - like starting up, shutting down, and clicking on something.

I hate this "background chatter" intensely. In my book, sound should be played when it's asked for, and at no other time. If I'm not watching a movie, playing music, or talking via Skype, then my speakers should be silent.

The people who complained about Alsa's one-track approach were the ones who'd get a system beep go off as they started their media player, and find that the media player wouldn't work, or who'd play an MP3 and then get an error message when their email tried to beep at them. This, they found, was annoying.

I agree. That's why I shut all the damn things off. I don't even let my terminal beep at me when it's got a problem: I don't want my music to have system-error-muzak mingled with it.

So I saw no problem with Alsa only doing one thing at a time. Mostly. Very, very occasionally, I'd get some interference that was annoying, like a sound from a browser Flash dohickey going off just as I was starting up XMMS; or shutting down XMMS improperly so it stayed holding onto the sound /devs even tho it was gone.

Small niggles, but niggles. So when I found that Alsa can do multiple sounds at once, I decided to give it a go.

I created a file, .alsafile, in my home dir, and put the following contents into it:
pcm.dmixer {
type dmix
ipc_key 1024
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
}

This bit of code enabled Alsa to "mix" sounds: The reason a default Alsa only does one sound is that the player grabs the /dev nodes for sound, and don't let anything else use them. By using dmix, you create an intermediary: Dmix grabs the sound devices, and everything else grabs dmix. Multiple sounds at once now work fine.

So I was happy, and everything worked fine. Until Skype. Skype didn't work, constantly complaining that it couldn't find either arts or esd - the Gnome & KDE sound mixers. Annoyed, I shrugged & installed esd. Then told everything to use esd, and once again I had working multiple sound, only via a different mixer.

And all was well, until Skype stopped working recently. Re-installing it, I found it didn't need esd at all. But it was all set up & working, so I left it.

Until today, when suddenly XMMS wasn't playing any sound. No erros, it thought it was playing. But it wasn't. So I switched it back to Alsa, and it played fine. Esd has just become more trouble than it's worth: I wipe it out, recompile mplayer without esd support, change Gaim's settings to use Alsa, and I'm back to square one.

Except the Sound Scope GKrellM plugin no longer works: I can't see my sound output on a graphical display.

*sob*

Fortunately, good old gentoo forums come to the rescue yet again: "amixer get Capture" shows all well, but "amixer get Mix" doesn't: capture is switched off. "amixer set Mix cap" fixes this, and suddenly, GKrellMSS is working.

Except the stereo monitor seems to think everything is only going out via one speaker: "Girls just want to have fun" has a great stereo bit at the start, and
GKrellMSS's twin monitors show a constant sound from just one speaker.

So that's still broken. But everything else works fine.

Perseverance is, I'm told, a wonderful trait. . .

0 Comments:

Post a Comment

<< Home