[…]
One might assume that SDL should do that (and it does, with some
restrictions), but as high quality resampling is pretty much
black magic, and burns quite some CPU, IMHO it’s actually better
the way it is.
Hmm what exactly do you mean by resampling? I am not that deep into
that sound stuff. I am just porting the app to Linux for my
employer g
Converting from one sample rate to another.
The basic version is to just “stretch” or “compress” the data by
picking samples using a fractional index - the 1D version of scaling
an image with nearest pixel filtering. Problem is it sucks (at least)
as much as the graphics version…
You can use linear (a bit better), square (unusual) or cubic (pretty
good, but still fast) polynomial interpolation for better results,
but you still need a brickwall filter and/or oversampling to avoid
problems with sounds containing high frequencies.
Anyway, SDL can double or halve the sample rate a few times as needed,
but that’s it. It won’t use the “slow” fractional resampler
automatically, since that would result in output buffers with sizes
that are not powers of two, which is incompatible with some drivers.
Is this a
driver problem with my sounddevice?
Sort of. Although many cards run their converters at a fixed 48
kHz, they usually do resampling in a DSP or something. (SB
PCI512, Live!, Audigy and related cards are examples of that kind
of design.)
That’s a pretty strange card you have, if it doesn’t support 44.1
kHz at all… Maybe it’s a fixed 48 kHz card without a DSP?
If you’re using such a card with a half finished Linux driver, it
might not implement resampling in the driver as intended. Or you
just have a broken driver.
Well it’s a “nForce2 AC97 AudioController (MCP)” on a mini-ITX
board, and SuSE 8.2 supports it. But I think I will talk about it
to the system administrator, as it seems, that it is not configured
the right way…
AFAIK, the AC97 part is little more than a plain CODEC - no h/m
mixing, resampling or anything. Lots of cards use those though
(including the Live! and Audigy cards, IIRC), so it doesn’t really
say much about the complete audio chipset’s functionality.
I thought the nForce2 had accelerated 3D sound and stuff, though
(which would mean it does h/w mixing and resampling of multiple
channels) - but I could be mistaken… Or the Linux drivers just
don’t support that part yet.
Second, when I boot up my machine and try to play a song
SDL_OpenAudio() always returns with "No available audio device."
After starting XMMS (wich is based on OSS like SDL, too) and
shutting it down again, I have no problems playing the song with
my app. A driver problem, too?
Uh oh… Are you using the aRts sound daemon, by any chance?
Unless you have a multi-open (ie hardware mixing and resampling,
like Live!, Audigy etc) card, a sound daemon would steal your
only PCM output and set it as some rate - like 48 kHz. If SDL
uses the daemon for output, or uses it indirectly through some
LD_PRELOAD hack (to intercept OSS I/O), it depends on whether the
daemon does resampling or not.
Well… yes, there’s an aRts demon running (started by the KDE, I
think). But what exactly happens? I mean, XMMS blocks when my app
is running and vice versa… But why does XMMS work after bootup
ans my app doesn’t? Shouldn’t there be the same restrictions for
XMMS as for my app?
I suppose SDL is compiled without aRts support (you need some headers
and stuff for that) and XMMS uses the OSS or ALSA output plugins.
That would mean they both either bypass aRts through the driver
and/or h/w mixing (which doesn’t seem to be the case), or both XMMS
and your SDL lib hit the OSS emulation that pipes their output to
aRts.
Why XMMS can get the stuff running and your app (or SDL) cannot beats
me, though.
I just don’t use aRts, because it adds latency and causes trouble for
many apps, without really providing anything I need or want. (And
this is with an Audigy card! Seems like aRts somehow manages to kill
the multi-open + h/w mixing features… Oh, and that won’t work with
mmap() I/O anyway, so Q3A and RTCW will just block stop in the audio
initialization if aRts is running.)
//David Olofson - Programmer, Composer, Open Source Advocate
.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
— http://olofson.net — http://www.reologica.se —On Wednesday 28 January 2004 13.19, Yves Maurischat wrote: