You are not logged in.

#1 2016-05-31 07:30:51

skwee
Member
Registered: 2013-08-15
Posts: 41

[SOLVED] Difference in sound between ALSA and PulseAudio

Hi there!

Long story short. I've played the same audio file once thorough Pulse and once directly via ALSA (using DeaDBeeF as the player) and I found out that pulse provides some sort of gain or bass boost to the file. I assume ALSA is more "pure" than pulse, therefore it outputs the audio as it was recorded, while pulse messing up with it.

I do find pulse useful due to the fact it can output from multiple streams, have independent output device to each source as well as per application volume control, but I want it to be as transparent as possible.

How I can make pulse only mix different sources, but not mess up with my music by doing "fancy" enhancement / re-sampling and etc?

This is my current ./config/pulse/daemon.conf:

#default-sample-format = s32le
default-sample-format = s24le
default-sample-rate = 192000
alternate-sample-rate = 44100
resample-method = speex-float-10
#enable-remixing=no

Thank you!

Last edited by skwee (2016-06-01 06:56:52)


dotfiles
git pull strings master-of-puppets

Offline

#2 2016-05-31 08:05:29

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,657

Re: [SOLVED] Difference in sound between ALSA and PulseAudio

well with that kind of a daemon conf it is unsurprising that your audio is being resampled. Unless all of your audio tracks are in that format, they will be resampled. Usually your audio card can only be  opened at one fixed samplerate (whatever starts to play first) and every sound you add after that will have to be mixed to that samplerate (because the card is opened at that samplerate and you can't just switch around while mixing multiple sources). During your tests, have you configured ALSA to use dmix (configured to the same effect as your posted pulse snippet) or did you play directly to the device? If the latter, the comparison is flawed since ALSA opened the device in exclusive mode which will allow for resampleless passthrough of that one audio file (you won't be able to play anything else at the same time though, that's the point)

Last edited by V1del (2016-05-31 08:08:32)

Offline

#3 2016-05-31 08:11:49

skwee
Member
Registered: 2013-08-15
Posts: 41

Re: [SOLVED] Difference in sound between ALSA and PulseAudio

V1del Thank you!
I did not really invest much time into the deamon.conf, I've just configured it to 192Khz and 24bit because my DAC supports those. I did not know that it is impossible to switch between samplerates on the fly! Thank you for this!
And answering your question, yes I did open ALSA in exclusive mode - i.e. no sound was able to be played from any other source.

So I guess best solution is to stay with deadbeef and exclusive alsa for my music, while leaving pulse for other stuff like skype? Or maybe get rid of pulse at all? I do however like that my skype is always playing to my headphones for example (because this is the way I've set it up once), not sure if alsa provides this.


dotfiles
git pull strings master-of-puppets

Offline

#4 2016-05-31 08:46:01

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,657

Re: [SOLVED] Difference in sound between ALSA and PulseAudio

you should iirc be able to use it like that (keep pulse running and simply use exclusive ALSA on the DAC). A few things you can try on pulse's side, especially since you mentioned bass, would be to set enable-lfe-remixing to no in daemon.conf and unloading and/or commenting in the default.pa the two modules

module-filter-heuristics
module-filter-apply

They aren't really clearly documented anywhere, but they might do some adjustments depending on the role deadbeef's pulsestream sets. I'd say the lfe-remixing is a very likely candidate for the differences you are hearing, so try to set that to no.

Last edited by V1del (2016-05-31 08:46:34)

Offline

#5 2016-05-31 08:47:28

skwee
Member
Registered: 2013-08-15
Posts: 41

Re: [SOLVED] Difference in sound between ALSA and PulseAudio

V1del, thank you very much!
Will try that and report later today!


dotfiles
git pull strings master-of-puppets

Offline

#6 2016-05-31 09:42:24

tmp-meteque
Member
Registered: 2015-12-11
Posts: 30

Re: [SOLVED] Difference in sound between ALSA and PulseAudio

You have to avoid any mixing software (Pulseaudio or dmix in Alsa) if you want bit perfect audio. But then, you can't play more than one thing at the same time.

Check your devices with aplay -l and  write an .asoundrc config file in your home directory like this:

pcm.!default {
    	type hw
    	card X
	device X
}

ctl.!default {
    	type hw           
    	card X
}

With dmix, if you're ok with audio resampling:

defaults.pcm.card X
defaults.pcm.device X
defaults.ctl.card X

You need apulse to use skype without pulseaudio.

Edit:

This guide can be useful if you prefer Pulseaudio over alsa. But first change the resample method (if you don't see src‑sinc‑best‑quality with pulseaudio --dump-resample-methods, change it with speex-float-10).

Last edited by tmp-meteque (2016-05-31 09:50:09)


IBM Lenovo T430

Offline

#7 2016-05-31 09:49:32

skwee
Member
Registered: 2013-08-15
Posts: 41

Re: [SOLVED] Difference in sound between ALSA and PulseAudio

tmp-meteque Thank you for the information! However I'm not yet sure if I want to ditch pulse completely, as I said it does provide some benefits.


dotfiles
git pull strings master-of-puppets

Offline

#8 2016-05-31 09:56:58

tmp-meteque
Member
Registered: 2015-12-11
Posts: 30

Re: [SOLVED] Difference in sound between ALSA and PulseAudio

I understand, you can use mpd to listen to your music with alsa standalone and pulseaudio with your other programs. I don't know how DeaDBeeF works but if you can change the source, it's another option.

I edited my message after you last one with a guide to improve the sound in pulseaudio. smile


IBM Lenovo T430

Offline

#9 2016-05-31 10:23:33

skwee
Member
Registered: 2013-08-15
Posts: 41

Re: [SOLVED] Difference in sound between ALSA and PulseAudio

Many many thanks!


dotfiles
git pull strings master-of-puppets

Offline

#10 2016-05-31 10:52:14

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,657

Re: [SOLVED] Difference in sound between ALSA and PulseAudio

Just a few notes: the relevant pieces of the guide tmp-meteque mentioned you already implemented (configuring resample rates), there are a few others the guide is outdated on (src-sinc-best-quality has been deprecated and removed from the arch package speex-float-10 as you use it currently is the correct way to use a high quality resampler)  frequency msec shouldn't really matter for music (you don't care about latency with music usually) and is outdated as well since modern ALSA uses timer based scheduling (provided the driver/hardware supports it, especially a few USB devices tend to be quirky, but this usually has no bearing on general sound quality, it would be relevant if you notice crackling or the like due to buffer underruns)

In general if you want to find out what pulseaudio is currently doing when playing to a device you can use

pacmd list-sinks
pacmd list-sink-inputs

for various forms of information like the sample rate and bit depth a given sink is oppened with or if a client like deadbeef has to get its output resampled because the stream it passed is incompatible with the samplerate your sink was opened with

Last edited by V1del (2016-05-31 11:00:30)

Offline

#11 2016-05-31 17:01:10

skwee
Member
Registered: 2013-08-15
Posts: 41

Re: [SOLVED] Difference in sound between ALSA and PulseAudio

I'm not exactly sure what was the issue, but I think I've disabled the resampler in deadbeef so it was downsampling everything to 44.1kHz or doing some strange resampling.
I've added deadbeef's resampler to the DSP chain and the sound now identical both from direct ALSA and through PulseAudio (or at least identical to level I can not distinguish from them).

Thank you both for the great explanations you gave there!


dotfiles
git pull strings master-of-puppets

Offline

#12 2016-05-31 21:58:28

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,657

Re: [SOLVED] Difference in sound between ALSA and PulseAudio

Well I'd assume now you have the same/similar difference that irked you initially with ALSA as well since there is resampling done by deadbeef now (afaik it doesn't do any if you explicitly disable the resampler), but oh well, don't forget to mark the thread as [SOLVED] by editing the title of your initial post if that is the case

Offline

#13 2016-06-01 06:59:16

skwee
Member
Registered: 2013-08-15
Posts: 41

Re: [SOLVED] Difference in sound between ALSA and PulseAudio

Yes, the sound now is the same. However I'm not sure ALSA is doing any resampling, I guess it opens the closes the device after each song with the correct sample rate. Before I've enabled resampler on deadbeef, some song sounded very very strange (fast, like they are beying played at 1.25x of their original speed) and I assume this happened because ALSA resampled the song from their original sample rate to the lower one. Anyway, marked as solved, thank you a lot!


dotfiles
git pull strings master-of-puppets

Offline

Board footer

Powered by FluxBB