You are not logged in.

#1 2013-11-12 08:21:53

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Alsa not outputting surround sound

I have a very bad problem.

speaker-test -c 6

Works perfectly fine and i hear sound from all channels (this is regardless of if i have asound.conf or not).

However when i get into a program that's trying to send a 6 channel audio to alsa, alsa seems to output it as 2 channel audio so it only uses my front 2 speakers.

I tried both  CMPlayer and Mpv with this and got the same result with a 5.1 sound movie (i confirmed the surround of the movie works if i'm in windows).

CMPlayer gives me some convenient info such as the input audio it gets and the output (output being determined by my sound driver, which in this case is alsa.)

Input: FLAC 48Khz 5.1 (32 bits)
Output on defaults: s32le 48Khz 2.0 (32 bits)

if i have asound.conf and use this

pcm.dmixed {
	type asym
	playback.pcm {
		type dmix
		ipc_key_add_uid true
		ipc_key 5678293
		ipc_perm 0660
		ipc_gid audio

		slave {
			channels 6
			pcm {
				format S32_LE
				rate 96000
				nonblock true

				type hw
				card 0
				device 0
				subdevice 0
			}
			period_size 1024
			buffer_size 16384
		}
	}
	capture.pcm "hw:0"
}

Output: s32le 96Khz 2.0 (32 bits)

Additional info:
I use a soundblaster X-Fi card, i have another problem with alsa which is not a big deal to me but the Master channel doesn't have a mute(toggle) function available (could be related).
If i use my intergrated Intel card the problem still persists both on default and if i use the custom asound.conf.
WM: Openbox

Edit:I have managed to make precisely 1 application work correctly, and that is mpv, if i configure it with

channels=5.1

Last edited by rabcor (2014-05-07 19:51:57)

Offline

#2 2013-11-21 13:06:02

max kaspar
Member
Registered: 2013-04-11
Posts: 57

Re: Alsa not outputting surround sound

Same problem here. I have X-fi titanium and couldn't setup surround sound trying many .asound configurations. Probably we'll have to wait for some next (far far away smile) version of alsa to fix this.

Offline

#3 2013-11-21 16:03:32

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: Alsa not outputting surround sound

Show us your definition for pcm.!default

Default is for *stereo* - use surround51 for 6 speakers.

Offline

#4 2013-11-22 14:03:44

max kaspar
Member
Registered: 2013-04-11
Posts: 57

Re: Alsa not outputting surround sound

Since I have surround speakers that redirect input to all speakers, i gave up on trying .asoundrc files from the web. This is my .asoundrc now

#high quality resampling

defaults.pcm.rate_converter "samplerate_best"


pcm.!default {
  type hw
  card 0

}

ctl.!default {
  type hw         
  card 0

}

Maybe this example will explain better.

With VLC i play a movie with surround sound. When i choose Creative X-Fi Front/WaveIn speakers, there is output only on the front speakers, adequatly when i choose Creative X-Fi Surround rear speakers there is sound only on rear speakers. Also Center/LFE works as it should. But when i choose Creative X-Fi Front\WaveIn 5.1 Surround output to Front, Center, rear and Subwoofer speakers, then sound is produced only on the front speakers. This screenshot is from Audio setup on VLC Alsa Device configuration:

8z0c.png

Offline

#5 2013-11-22 16:10:48

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Re: Alsa not outputting surround sound

pcm.!default {
	type plug
	slave.pcm "dmixed"
}

(That's why i just showed the dmixer code)

But it really doesn't seem to matter what settings i use, i could also use:

pcm.!default {
	type plug
	slave.pcm "surround51"
	slave.channels 6
}

and get the same result (i've tried) like i said, "speaker-test -c 6" is the only thing that outputs to all my channels, any media player will output to stereo.

Last edited by rabcor (2013-11-22 16:12:04)

Offline

#6 2013-11-30 02:31:58

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Re: Alsa not outputting surround sound

@max kaspar i'm wondering what happens if you select other channels like 5.0 or 7.1 or even 4.0.

Offline

#7 2013-11-30 14:59:22

max kaspar
Member
Registered: 2013-04-11
Posts: 57

Re: Alsa not outputting surround sound

The 4.0 and 7.1 output only to front speakers, and 5.0 and 4.1 output to front speakers with volume turned up and a lot of humming noise. As it looks, the channels are mixed up and needs to be set properly in .asundrc, but i can't find any guide for x-fi titanium (emu 20k2)

Offline

#8 2013-12-01 04:14:51

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Re: Alsa not outputting surround sound

please do share if you find a way to fix this, it bothers me a lot. I'd be using linux a lot more than i currently am if my sound was actually anywhere near as good as it is in windows sad

Also, rather than X-Fi Titanium specific, assume it's just X-Fi specific.

Last edited by rabcor (2013-12-01 04:24:10)

Offline

#9 2014-01-18 12:22:45

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Re: Alsa not outputting surround sound

Still not solved, i looked around for clues, found this and installed libdca, that didn't help.

I didn't stop there and installed gst-plugins-bad. Still nothing.

Then i found this

Still haven't been able to fix this with any asound configuration sad

I tried messing with VLC like max kaspar and got pretty much the same results.

The only "hotfix" is to upconvert the downconverted stereo sound back up to surround sound, which i imagine absolutely destroys the quality.

Last edited by rabcor (2014-01-18 12:38:18)

Offline

#10 2014-01-18 13:00:07

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: Alsa not outputting surround sound

rabcor wrote:

"speaker-test -c 6" is the only thing that outputs to all my channels, any media player will output to stereo.

That command is WRONG. You need to understand that there are different PCMs.

A correct command, to test 6 speakers:

speaker-test -c 6 -D surround51 -t wav

The PCM named "default" is for stereo, i.e. "surround20". That's all it's for - no more speakers than *two*.

Look at the config in my sig. For example, it has many speaker-test lines as examples for you try try, and they *all* specify the PCM wink

For upmixing a song in the best way (sending the right tones to the subwoofer and tweeters), see upmix_20to51 in my config.

So, in your media player, if it's outputting stereo, make it send the stereo to PCM "upmix_20to51" rather than PCM "default". This makes it unnecessary for the speaker hardware to do upmixing from stereo to surround - a big question is whether it was splitting the *tones* to the appropriate speakers, as in this ALSA snippet:

    # From http://alsa.opensrc.org/Low-pass_filter_for_subwoofer_channel_%28HOWTO%29
    1 {
        id 1672 # 4 Pole Low-Pass Filter with Resonance (FCRCIA) (1672/lp4pole_fcrcia_oa)
        policy none
        input.bindings.2 "Input"
        output.bindings.2 "Output"
        input {
            controls [ 300 2 ]

Offline

#11 2014-01-18 17:04:45

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Re: Alsa not outputting surround sound

Sorry for not being perfect, that command works too.

Why is it called default if it means stereo? :I that's just confusing! so which PCM is default then?

Anyways, the problem i'm having is not that surround sound isn't working, (in speaker-test) the problem is that no application i've used outputs more than 2 channels, like i said in the OP, i play a 5.1 file, my program reads it as 5.1 file and redirects it to alsa, then alsa downconverts it to 2.0. The only exception is the rear-speaker option in VLC which then does 2.0 but for the rear speakers instead of front.

I can use "route_policy duplicate" to duplicate sound on all channels, but i want my alsa to pick up that 5.1 source and deliver it as 5.1 sound!

My media player is outputting surround sound, VLC using the 5.1 option in the dropdown menu that max kaspar screenshotted is the most reliable thing i have right now that i know is 100% configured for 5.1 sound, it's alsa that's downconverting the 5.1 sound the programs send to it.

So a program (any program, it's not limited to just 1 program) is configured for 5.1, but alsa reads 2.0


Sure, i can redirect 2.0 sound to upmixing to 5.1, but this still means that my 5.1 source is converted down to 2.0 before it's played at 5.1 (meaning heavy loss of quality)

btw,

pcm.!default {
	type asym
	playback.pcm "upmix_20to51_resample"
}

from your example does not work, (yes, i do have the rest of the file too) i only hear 2.1 sound. (no, it's not an improvement, the subwoofer always worked, i guess because the subwoofer duplicates the 2.0 source if it doesn't get an input from it's own channel)

I have a program which show's me alsa's output (not it's own output, alsa's output, i know because if i changed the frequency in alsa the frequency of that line changed too) but alsa ALWAYS outputs a source as stereo, and my only way to bypass it is with the duplicate route policy.

Fun note: upmix_20to51 doesn't even work in speaker-test, whereas ch51dup does.

using ch51dup seems to be the best thing i can do right now, but it doesn't change the fact that alsa is only reading a 5.1 source as 2.0 hmm

This is painful, i really want a solution badly sad i'm pretty certain it has to do with the X-Fi drivers. Like i said i have another ninja problem where i cannot "mute" the "Master" and "PCM" channels, i can only adjust their volume (in alsamixer for example)

Last edited by rabcor (2014-01-18 17:33:09)

Offline

#12 2014-01-18 18:02:56

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: Alsa not outputting surround sound

rabcor wrote:

which PCM is default then?

The PCM named "default" is defined in /usr/share/alsa/pcm/default.conf

Have you googled, and found evidence that your particular model of soundcard is supported by ALSA for surround sound?

Offline

#13 2014-01-18 18:19:37

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Re: Alsa not outputting surround sound

I may have found a problem, look at the output of "aplay -L"

default:CARD=XFi
    Creative X-Fi, Front/WaveIn
    Default Audio Device
sysdefault:CARD=XFi
    Creative X-Fi, Front/WaveIn
    Default Audio Device
front:CARD=XFi,DEV=0
    Creative X-Fi, Front/WaveIn
    Front speakers
rear:CARD=XFi,DEV=0
    Creative X-Fi, Surround
    Rear speakers
center_lfe:CARD=XFi,DEV=0
    Creative X-Fi, Center/LFE
    Center and Subwoofer speakers
side:CARD=XFi,DEV=0
    Creative X-Fi, Side
    Side speakers
surround41:CARD=XFi,DEV=0
    Creative X-Fi, Front/WaveIn
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=XFi,DEV=0
    Creative X-Fi, Front/WaveIn
    5.0 Surround output to Front, Center and Rear speakers
surround71:CARD=XFi,DEV=0
    Creative X-Fi, Front/WaveIn
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=XFi,DEV=0
    Creative X-Fi, IEC958 Non-audio
    IEC958 (S/PDIF) Digital Audio Output

Everything has the same "DEV" value (all 0) is that a problem?

the default.conf is set to well.. it's defaults (got any suggestions for editing it?)

My specific model is a PCI-E, X-Fi Elite Pro, our buddy has X-Fi Titanium (which isn't very specific) the problem is possibly related to the "emu20k1" driver.

As for evidence... i found this i think the elite pro card is fairly rare, so i wouldn't be surprised if only a handful of linux users have it. The only evidence i have of another user having the same problem is max kaspar, the only others were using x-fi USB cards with S/PDIF (i'm using analogue) one (of two found) i linked above from the suse forums.

Edit:
I think i figured out in my head what the problem is, my X-Fi drivers (assumed: "emu20k1", however i just installed my drivers on my windows and it calls it Titanium Fata1ty Pro, so it might actually be "emu20k2") I think the problem is that the drivers are supposed to tell alsa how many channels it's got, and the drivers are supposed to auto-detect that depending on what jacks are in use right? the drivers definitely do detect my 5.1 speakers, and when i test on specific channels with alsa (speaker-test) it forwards the sound to all the right speakers, however when i've got a 5.1 sound file in use by any third party program forwarded to alsa, i get a 2.0/2.1 output, i figure this means that my drivers while "working" with the 5.1 speakers are telling alsa i only have 2 so it downmixes all audio to 2.0?

This is just an uneducated guess, but sounds plausible enough right? I would go check and see if i can make sense of the driver code to see what's up, and try rewriting some piece of it to fix this and recompile it, sure it'd probably take me 1 week to a month, but give it a bit of devotion i will eventually make it work (like my keyboard) or i could possibly mess with alsa's source, but the thing is that while i could do that if these were just normal packages installed via AUR or Pacman, i have no idea how to do that for alsa and the creative sound drivers....
or

Last edited by rabcor (2014-01-20 02:14:51)

Offline

#14 2014-04-25 03:34:15

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Re: Alsa not outputting surround sound

Update! I think I solved this problem, but I'm not sure exactly how. But since I got it working, I am not so heavily inclined to mess it up again to reproduce it just yet.

What I did precisely was:

pacman -S pulseaudio pulseaudio-alsa lib32-libpulse lib32-alsa-plugins pavucontrol

then from inside of pavucontrol, I went to configuration and set my card(Emu20k2) to "Analogue Surround 5.1 Output + Analogue Stereo Input"

And it worked. it upmixes 2.0 to 5.1 and also plays 5.1 sources as it should, however if I don't set it to this option (keep it at Analog stereo duplex, or stereo output) I'll get crackling sounds.

After this my sound just works, both software configured to communicate directly with alsa and software that uses pulseaudio. This is very strange, but well if pulseaudio fixes my problems I guess I'll just use pulseaudio and let that be the end of this.

I think I'm holding off from that solved tag until I've actually pinpointed the solution better, since this is still technically only half solved, but I suppose I'll probably end up sticking with pulseaudio since if I use ttables to upmix my sounds I remember I ran into errors here and there. Also I haven't been using this for very long so there are a few more potential problems for me to run into.

Edit: I had some serious issues with pulseaudio which lead to me uninstalling it. The weird part is that now my sound works perfectly fine. So the solution seems to have essentially been to install and then uninstall pulseaudio as ridiculous as that may sound.

Last edited by rabcor (2014-04-28 23:03:51)

Offline

#15 2014-05-01 13:36:39

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Re: Alsa not outputting surround sound

I was off; I don't know what sort of black magic happened back there, it's clear though that it wasn't pulseaudio alone that did any good. I had to reinstall my system after breaking it with some graphics driver issues, and I tried fixing this with the same method as above, but it did not work for me this time.

This is really killing me, both alsa and pulseaudio detect the 6 channels, but both are converting 5.1 tracks into 2.0 tracks and then upmixing them back to 5.1 >_>

I'm tempted to see what kind of results I get if I use other distros.

Last edited by rabcor (2014-05-01 14:15:37)

Offline

#16 2014-05-03 23:26:56

linktohack
Member
From: Vietnam
Registered: 2011-02-22
Posts: 6
Website

Re: Alsa not outputting surround sound

Thank you @rabcor! I have exactly the same problem as you and the pavu config trick really work! I think the problem is PulseAudio does not recognize the right configuration for the sound card so we have to manually select it (Still no idea how to have it work with ALSA smile)

Offline

#17 2014-05-04 08:41:18

Roken
Member
From: South Wales, UK
Registered: 2012-01-16
Posts: 1,251

Re: Alsa not outputting surround sound

After two years of trying, I finally removed my X-Fi card from my system and went to on board audio. Either I couldn't get surround working with alsa, or using pulseaudio the server would crash intermittently.

Since removing the card I've had no problems. I've come to the conclusion that Creative cards are just not a good choice on Linux.


Ryzen 5900X 12 core/24 thread - RTX 3090 FE 24 Gb, Asus Prime B450 Plus, 32Gb Corsair DDR4, Cooler Master N300 chassis, 5 HD (1 NvME PCI, 4SSD) + 1 x optical.
Linux user #545703

Offline

#18 2014-05-05 12:20:46

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Re: Alsa not outputting surround sound

linktohack wrote:

Thank you @rabcor! I have exactly the same problem as you and the pavu config trick really work! I think the problem is PulseAudio does not recognize the right configuration for the sound card so we have to manually select it (Still no idea how to have it work with ALSA smile)

Well in my cause I actually uninstalled pulseaudio and it worked with alsa without any configuration. But if you want an upscaling algorithm to use in alsa to convert 2.0 to 5.1, I am now using this. (However my sound broke again after a reinstall, and installing pulseaudio/pavucontrol like I did before doesn't fix it this time) You can use the console output of mplayer or mpv to play a surround sound file, or the info in CMPlayer.

pcm.!default {
	slave.pcm "surround51"
	slave.channels 6
	type route

	# Front and rear
	ttable.0.0 0.7
	ttable.1.1 0.7
	ttable.2.2 0.6
	ttable.3.3 0.6

	# Center and LFE
	ttable.4.4 1
	ttable.5.5 1

	# Front left/right to center
	ttable.0.4 0.5
	ttable.1.4 0.5

	# Front left/right to rear
	ttable.0.2 0.5
	ttable.1.3 0.5
}

I don't know precisely how the first number in this works (it is though obviously for forwarding the sound from the front speakers to the rear and center/LFE ones, I just don't understand how), but the latter seems to be a volume percentage (1 is 100% and 0 is 0%) which can be set per speaker.

I actually just made a discovery now. MPV outputs 6 channel sound whereas CMPlayer and Mplayer only output 2ch sound for surround sound files. This means that some applications do output surround sound properly.

Upon investagting further, I found out theres a setting in mpv.conf that allows for this to happen.

# prefer using 5.1 channels audio (defaults to 2 - see mpv --channels=help) 
channels=5.1

If I have that setting mpv will output surround sound correctly yikes this gives at least a glimpse into how this can be fixed, I hope. This leads me to believe that the actual problem is that applications acnnot autodetect that I have 6 channels but if they can be manually configured to output to 6 channels they will work. (However do note that there MUST be a way to fix this since I essentially did a few posts up, I just don't know exactly how and can't fix it again)

Last edited by rabcor (2014-05-05 13:52:02)

Offline

#19 2014-05-05 17:23:22

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: Alsa not outputting surround sound

rabcor wrote:

I don't know precisely how the first number in this works (it is though obviously for forwarding the sound from the front speakers to the rear and center/LFE ones, I just don't understand how), but the latter seems to be a volume percentage (1 is 100% and 0 is 0%) which can be set per speaker.

Alsa documentation on plugins. You could use "plug" for this.

Offline

#20 2014-05-06 02:13:09

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Re: Alsa not outputting surround sound

Not if I'm running it as the default 2.0 PCM no. Don't remember specifics. Naturally I could write it separate from the default PCM and then use it as a plugin for that, but that wouldn't really change much I think.

Offline

#21 2014-05-06 11:00:09

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: Alsa not outputting surround sound

rabcor wrote:

But if you want an upscaling algorithm to use in alsa to convert 2.0 to 5.1, I am now using this.

emeres wrote:

You could use "plug" for this.

Alsa documentation wrote:

Automatic conversion plugin - This plugin converts channels, rate and format on request.

Offline

#22 2014-05-07 19:40:40

rabcor
Banned
Registered: 2013-02-09
Posts: 500

Re: Alsa not outputting surround sound

If I do this:

pcm.!default {
	type asym
	slave.pcm "ch51dup"
}

pcm.ch51dup {
	slave.pcm "surround51"
	slave.channels 6
	type plug

	# Front and rear
	ttable.0.0 0.7
	ttable.1.1 0.7
	ttable.2.2 0.6
	ttable.3.3 0.6

	# Center and LFE
	ttable.4.4 1
	ttable.5.5 1

	# Front left/right to center
	ttable.0.4 0.5
	ttable.1.4 0.5

	# Front left/right to rear
	ttable.0.2 0.5
	ttable.1.3 0.5	
}

I get this

ALSA lib pcm_asym.c:101:(_snd_pcm_asym_open) Unknown field slave
Playback open error: -22,Invalid argument

if I replace "asym" with "plug" the sound works in some applications but not all, like mpv for instance:
(edit: or if I do "asym" right and use "playback.pcm" instead of "slave.pcm"

[ao/alsa] Unable to set hw-parameters: Invalid argument
[ao] Failed to initialize audio driver 'alsa'
Could not open/initialize audio device -> no sound.

I'm better off doing it the way I was before.

Last edited by rabcor (2014-05-07 19:50:29)

Offline

#23 2014-05-31 01:51:44

jwenzel2
Member
Registered: 2012-10-31
Posts: 3

Re: Alsa not outputting surround sound

i have a creative XiFi myself my problem is dispite having 5.1 surround sound my sub and center speaker WILL NOT work with any of the 5.1 configurations however i gave other configs a try and found that 4.1 analog surround sound selected everything but the sub works. just thought id give what worked the most for me in the event you never gave this a try yourself

Offline

#24 2014-07-12 21:19:47

rfaa
Member
Registered: 2012-06-14
Posts: 1

Re: Alsa not outputting surround sound

I use pulseaudio and recently had this problem, you will have to manually unmute Center/LFE in alsamixer(muted by default...).
My x-fi is now working properly with 5.1 surround!

Offline

Board footer

Powered by FluxBB