Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: ALSA sample rate conversion (Read 120438 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

ALSA sample rate conversion

Reply #25
We started out with a simple comparing of samplerate and samplerate_order. Out of the 5 he sent me, I got 5 correct. Was pretty simple considering that samplerate_order is pretty bad. We just did this one to make sure my ears were working.

Indeed - samplerate_order is truly awful. samplerate_linear is much better, but still not much good.
Comparing samplerate and samplerate_best managed to embarrass me though. Out of 10, I got 1 right, 2 wrong, and 7 unsure. And honestly, I think the one I got right was a guess.
This one is very easy with udial.wav, and possible the chenoa sample with headphones(search for them if you don't have them). I failed with everything else though.
Can anyone give link to good test sample for checking resampling quality? I know about dial.wav but maybe better test sample exists?
You could try chenoa (search for it) - that's always treated me well for resampling tests. As far as I remember, the Live 24 can't resample in hardware at all, it's been a while since I read the specs but the lack of the EMU10k processor suggests that it lacks this capability.

ALSA sample rate conversion

Reply #26
Well, I just did a quick test of udial, before I get around to ABXng with it. Man, playing that through hw is havoc with my SB Live!, there's a weird sweeping noise that starts after the third tone. And, I'm getting the same sound with the default device as well. Using samplerate_linear and dmix the sound is quite a bit different, more smoother I guess.

... OK, samplerate_order sounds exactly the same as hw, just the weird noise is a tiny bit louder.

And, I can tell right away that samplerate sounds better on udial than samplerate_best. samplerate_best has some added freqs on the last four tones. Same with samplerate_medium. What I find odd is that the default device is supposed to use dmix, or so that's what the ALSA docs have been saying. But clearly by the sounds of it, it's just be an alias to hw. Maybe the ALSA setup under Gentoo is different, not sure...
"It's the panties fault! The panties made me a pervert!"

ALSA sample rate conversion

Reply #27
And, I can tell right away that samplerate sounds better on udial than samplerate_best. samplerate_best has some added freqs on the last four tones. Same with samplerate_medium. What I find odd is that the default device is supposed to use dmix, or so that's what the ALSA docs have been saying. But clearly by the sounds of it, it's just be an alias to hw. Maybe the ALSA setup under Gentoo is different, not sure...
default definately goes through dmix on my machine (Ubuntu 6.06), but it is possible that Gentoo is different. To me, udial sounds best on samplerate_medium - but it is a very artificial sample so i'm not too worried about optimising that one.

ALSA sample rate conversion

Reply #28
Now I also have tested different samplerate_* modes (not on my home Live! 24bit, but on work's integrated  VIA 8235 with VT1616i). Sound from direct hw:0 output and dmix with samplerate_linear are the same. samplerate_order just terrible  but samplerate (SRC_SINC_FASTEST) gives best, clear sound. medium and best variants give sound worse then samplerate but more better linear.
Strange sample! It makes fast to best and best to non best!

ALSA sample rate conversion

Reply #29
Sorry guys for this Off-topic, but does have anyone an idea (or has tested) the same on windows? Does it have the same low-quality mixer or converter? If yes, what are the possibilities to make it better?

If this is dependent on the hardware you use, I am mostly interested in the HDA built-in audio chips in notebooks (for example SoundMAX AD1986A)

ALSA sample rate conversion

Reply #30
default definately goes through dmix on my machine (Ubuntu 6.06), but it is possible that Gentoo is different. To me, udial sounds best on samplerate_medium - but it is a very artificial sample so i'm not too worried about optimising that one.


Well, looking at the confs in /usr/share/alsa/cards, EMU10K1.conf does not use dmix for default. Almost all the other card's conf uses dmix, but the emu10k1 doesn't. I even checked the ALSA CVS, no dmix for the emu10k1. So, because of this, ALSA just uses plughw instead for default. So I guess only certain cards have been updated to use dmix. Even the conf for my on-board sound, VIA8237, doesn't use dmix as default.

Aha! According to http://alsa.opensrc.org/index.php?page=DmixPlugin:
NOTE: For ALSA 1.0.9rc2 and higher you don't need to setup dmix. Dmix is enabled as default for soundcards which don't support hw mixing.

Thats why dmix isn't enabled for my SB Live! 5.1, it supports hardware mixing.
"It's the panties fault! The panties made me a pervert!"

ALSA sample rate conversion

Reply #31
As I know at least Live! 24bit on windows has the same problem with resampling and recommended way for sound/music playback is using software resample plugins for the player, but this solution is not system wide and will not work for every other applications.
So now ALSA with rate plugin gives better way to solve resampling issue then player based solutions for windows. It's nice.

ALSA sample rate conversion

Reply #32
Well, looking at the confs in /usr/share/alsa/cards, EMU10K1.conf does not use dmix for default. Almost all the other card's conf uses dmix, but the emu10k1 doesn't. I even checked the ALSA CVS, no dmix for the emu10k1. So, because of this, ALSA just uses plughw instead for default. So I guess only certain cards have been updated to use dmix. Even the conf for my on-board sound, VIA8237, doesn't use dmix as default.
According to the docs, dmix is enabled by default for cvards that don't support hardware mixing. Emu10k1 cards do - so they default to plughw.

ALSA sample rate conversion

Reply #33
Sorry guys for this Off-topic, but does have anyone an idea (or has tested) the same on windows? Does it have the same low-quality mixer or converter? If yes, what are the possibilities to make it better?

If this is dependent on the hardware you use, I am mostly interested in the HDA built-in audio chips in notebooks (for example SoundMAX AD1986A)

The resampling problem is very usual with low cost soundcards also in Windows. My solution in Windows has been foobar2000 with resampler. There are few quite good resamplers for foobar2000 and the default PPHS resampler is quite good. You can test your audio hardware resampling with it. Use the problem sample mentioned earlier in this thread and test the resampler 48 kHz on and off. Check which setting sounds best with your hardware.

ALSA sample rate conversion

Reply #34
Today I had a quick try to compile alsa-lib 1.0.11 from ubuntu repository at my amd64 box but got strange errors and at the end got strange package. aplay <sample.wav> gives me errors about absence of dmix, etc. But it's no problem, I'll try later.
The good thing I got was the interesting behavior. When I play udial.wav directly to card with 'aplay -D hw:1 udial.wav' it gave me warning about "requested 44100 Hz, got 48000 Hz" and played absolutely clear but a bit higher and quicker. So it just played 44.1kHz sample at frequency 48kHz w/o any resampling at all.
As conclusion: ALSA hardware driver (from kernel) doesn't resample anything, it is work for ALSA library. And resampling works only with correct config for given soundcard.

ALSA sample rate conversion

Reply #35
As conclusion: ALSA hardware driver (from kernel) doesn't resample anything, it is work for ALSA library. And resampling works only with correct config for given soundcard.
Indeed it doesn't. The hw devices are completely raw - they don't do any SRC, they don't change the bit depth and they seem to be fairly low latency. It's like kernel streaming for Linux.

ALSA sample rate conversion

Reply #36
After successful upgrade of alsa{-driver,lib,util,plugins} on my amd64 box I checked different samlerate variants on Live! 24bit and there is no difference between "samplerate", "samplerate_medium" and "samplerate_best" with udial.wav - it sounds perfect anyway.

So "samplerate" is a winner for me!  Minimal CPU usage with a good quality.

BTW: alsa 1.0.12 released recently.

ALSA sample rate conversion

Reply #37
The resampling problem is very usual with low cost soundcards also in Windows. My solution in Windows has been foobar2000 with resampler. There are few quite good resamplers for foobar2000 and the default PPHS resampler is quite good. You can test your audio hardware resampling with it. Use the problem sample mentioned earlier in this thread and test the resampler 48 kHz on and off. Check which setting sounds best with your hardware.


Checked udial.ape with my KOSS Porta Pro & SoundMAX AD1986A. No EQ, no SRS, just the sound & the PPHS resampler on and off. I could not hear ABSOLUTELY any difference. If I enabled ultra mode, i could hear some pops, but not otherwise. Does that mean, that windows' mixer (or my hardware mixer - if it exists at all) does a good job?
I could not find the chenoa sample though.

ALSA sample rate conversion

Reply #38
Maybe your card support 44100 Hz natively and no resampling ever needed for it?

ALSA sample rate conversion

Reply #39
This is what the data sheet says:
Front DAC PCM Rate Register [15:0] (Sample Rate):
Function:
The sampling [24bit] frequency range is from 7 kHz (0x01B58) to 48 kHz (0xBB80) in 1 Hz increments. If 0 is written to VRA, then the
sample rates are reset to 48 kHz.

+ there is a doule-rate DAC for 96kHz. This probably means that iGold was right.
Further reading revealed that it had a hardware equalizer, analogue 5.1 downmixing to 2 channels, and several analogue summars for mixing inputs.

So if its DAC can handle any sample rate, the question arises, what would happen, if I used two different audio players, one at 44.1kHz and the other at 48kHz. It this case DirectSound would have to do the resampling, correct?

Update:
It's now clear.
The Windows mixer has also several levels of quality. It is accessble under: Control Panel/Sound Devices/Speaker Settings/Advanced/Performance.
I could clearly hear the problem with the lowest quality evel, but the mid and highest was already artefact-free with udial. Which also means that my sound card does NOT support 44.kHz by default, only with resampling.

The good news is, that I could not spot any increased CPU activity with the highest resampling quality level. This was the case regardless of the hardware acceleration level.


ALSA sample rate conversion

Reply #41
http://www.kikeg.arrakis.es/lowpass/Chenoa_16KHz.ape

A similar one:

http://www.kikeg.arrakis.es/lowpass/Androgyny_16KHz.ape

They are Monkey's Audio, so I think you'll need Windows to decode them, sorry.

udial.wav is a more extreme case, it should expose flaws more easily. But beware of listening to it at high levels, it can fry your tweeters and even your power amp.

ALSA sample rate conversion

Reply #42
Sorry guys for this Off-topic, but does have anyone an idea (or has tested) the same on windows? Does it have the same low-quality mixer or converter? If yes, what are the possibilities to make it better?

If this is dependent on the hardware you use, I am mostly interested in the HDA built-in audio chips in notebooks (for example SoundMAX AD1986A)


kmixer, which is part of windows, is generally known for doing a terrible job with audio. There are several solutions for playback which often involve either the creation of virtual asio devices or as-is the case with foobar2000 kernel streaming (which bypasses kmixer altogether).

Of course, if you're doing this with anything other than some form of digital-out to a dac you're unlikely to notice the difference because the electromagnetics inside a pc case seriously degrade the quality of any analog in/out. Similarly so if you're listening to audio on laptop speakers.

~Chad

ALSA sample rate conversion

Reply #43
kmixer doesn't do that bad at the default setting of best quality of sample rate conversion.

See kmixer resampling measurements at http://www.kikeg.arrakis.es/measurements/

Edit: as to the need of outboard DACs for noise free audio, see the analog measurements. They are performed with and unexpensive, non-balanced internal card. Balanced internal soundcards usually offer even better noise performance. One of the best soundcards I know of (if not the best), the Lynx Two, is internal.

ALSA sample rate conversion

Reply #44
See kmixer resampling measurements at http://www.kikeg.arrakis.es/measurements/
Kmixer does pretty well, and the CPU load is fairly low, too. Does anybody know what algorithm is used?

Edit: as to the need of outboard DACs for noise free audio, see the analog measurements. They are performed with and unexpensive, non-balanced internal card. Balanced internal soundcards usually offer even better noise performance. One of the best soundcards I know of (if not the best), the Lynx Two, is internal.
Sound card designs have come a long way - they perform amazingly well in what is a fairly harsh environment with loads of noise and pretty ugly power. It constantly amazes me how well good cards (like the Lynx Two) do in such a bad environment.

ALSA sample rate conversion

Reply #45
I tried to build kasound on Ubuntu Edgy and it asks for "KDE headers". Which package contains those? Or, do you have a package? (a Dapper one might work, too)

ALSA sample rate conversion

Reply #46
does anyone know if the sample perioid issue has been resolved in ALSA 1.0.13 ? I just got the libsamplerate plugin to work with ALSA and it sounds very good.

ALSA sample rate conversion

Reply #47
Hi cabbagerat,

Thanks for starting this excellent thread and your serious investigation.

Can you help me? I am using an old Linux distribution that only has ALSA 1.0.8, and i don't really want to upgrade this machine for the moment. The sound card is the onboard nvidia AC97 with an ALC850 codec, which I have connected using SPDIF to my A/V receiver. This sound card cannot output 44.1kHz to the SPDIF, so everything gets upsampled to 48kHz. And the default upsampling in ALSA 1.0.8 is the horrible linear interpolator - I can quite literally hear the artifacts (mostly aliasing) caused by the ALSA resampling. 

I am using Amarok with Xine as the audio engine, and ALSA as the driver. I am not really feeling up to the task of trying to integrate the latest ALSA drivers, libraries and utilities to my heavily patched 2.6.11 kernel and relatively old Linux distribution.

Do you have any suggestions?

ALSA sample rate conversion

Reply #48
I have just read the piece of news about the debian update; this is great.
I am trying to figure out how I could alter /usr/share/alsa/pcm/dmix.conf so that it would use the samplerate_best plugin. It would probably the best way to modify the debian package, because the default configurations in /usr/share/alsa/cards/ would all be affected.
Stupidity is root of all evil.

ALSA sample rate conversion

Reply #49
This is a bit offtopic maybe, but do you guys know how JACK Audio Connection Kit handles resampling? I always use JACK for Audio work on linux. (JACK backend driver is ALSA)

Settings I use are:
Realtime, 64 Frames/Period, 48000 Sample Rate, 2 Periods/Buffer, Forced 16 bit
Latency in this configuration, without realtime kernel patches, seems to be ~2.67ms according to qjackctl?

Anyway... I'm no expert in audio in linux. I hope someone knows more