WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Swap left right audio channel  (Read 9424 times)

Offline Maurits

  • Newbie
  • *
  • Posts: 9
Swap left right audio channel
« on: November 18, 2015, 03:57:01 PM »
Hello,

I'm using Picoreplayer on micro core as an audiostreamer on a Rasp  1 B+. Audio out via a Audio-GD hdmi output module makin use of the i2s GPIO pins. All works fine but one small detail: the left and right audio channel are the wrong way around. This is because the left-right configuration of the audio-gd module is opposite of the right-left ( ;)) config of my Dac (Pink Faun).

To solve this I thought of swapping the channels in linux. Biggest problem with that so far: I'm a absolute Linux n00b...

The possible solution i did find is switching the channels in /etc/pulse/deamon.conf

; default-sample-channels = 2
; default-channel-map = front-left,front-right

to

default-sample-channels = 2
default-channel-map = front-right,front-left

But i can't find this file, or edit any other file that seems to haveanything to do with audio.

Can anyone  help me out? Solving this will make this an ultimate low cost, high end streamer.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Swap left right audio channel
« Reply #1 on: November 18, 2015, 04:36:53 PM »
Wyy don't you swap the Left/Rigth cables? No LINUX knowledge needed, fast, easy and cheap.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Maurits

  • Newbie
  • *
  • Posts: 9
Re: Swap left right audio channel
« Reply #2 on: November 18, 2015, 05:04:56 PM »
Wyy don't you swap the Left/Rigth cables? No LINUX knowledge needed, fast, easy and cheap.

Would work fine if the pi was the only source feeding my dac. Tv is also connecter to the dac, switched left right watching a movie is not what i prefer.

The connection between pi and dac is i2s over hdmi, no chance of swithingthat around...

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Swap left right audio channel
« Reply #3 on: November 19, 2015, 12:29:25 AM »
Not between RPi. I mean the analog cable.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Maurits

  • Newbie
  • *
  • Posts: 9
Re: Swap left right audio channel
« Reply #4 on: November 19, 2015, 12:40:54 AM »
Not between RPi. I mean the analog cable.

This would change the left-right channels for every source that's connected to the dac... Tv is on the spdif input, can't change that either

Offline Maurits

  • Newbie
  • *
  • Posts: 9
Re: Swap left right audio channel
« Reply #5 on: November 19, 2015, 12:49:15 AM »
I found this on another forum, but could not edit the asound.conf file

Add this to your /etc/asound.conf...

Code:
pcm.swapped {
    type route
    slave.pcm "hw:0"
    ttable.0.1 1
    ttable.1.0 1
}

Offline Maurits

  • Newbie
  • *
  • Posts: 9
Re: Swap left right audio channel
« Reply #6 on: November 19, 2015, 08:39:23 AM »
Been working on my SSH skills  ;)

So far i've learned to use vi to edit files, and filetool.sh -b to save changes I made.

I've enriched asound.conf, which now looks like this

Code: [Select]
pcm.!default {
        type plug
        slave.pcm hw
}
pcm.swapped {
        type route
        slave.pcm "default"
        ttable.0.1 1
        ttable.1.0 1
}

I'm not yet able to test because away from home for a few days. This at least doesn't cause any errors booting Picore.

What do you guys think, will this swap the channels? Shouldn't I point another rule to use the pcm.swapped instead of pcm.default?

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: Swap left right audio channel
« Reply #7 on: November 19, 2015, 05:32:21 PM »
hi Maurits,

piCorePlayer doesn't use pulse audio.

Welcome to the ALSA world!

This /etc/asound.conf should work.

Code: [Select]
# swap - Generated by piCorePlayer
pcm.!default {
type route
slave.pcm "hw:0,0"
ttable {
0.1 1
1.0 1
}
}

Your on board audio should be card 0, so the above code should be OK.

Remember to do a backup and restart squeezelite, both buttons on main page.

I have added a screen capture of a "possible" piCorePlayer tool to play with asound.conf. We are just trying to work out to make is generic and simple enough to use.

regards
Greg

Offline Maurits

  • Newbie
  • *
  • Posts: 9
Re: Swap left right audio channel
« Reply #8 on: November 20, 2015, 07:48:35 AM »
Hello Greg,

Thanks for the reply. I've deleted the previous code and added the code you gave in your reply. Tomorrow i'll be able to hook up the Pi to the DAC and test, keep you posted on the results.

The screenshot looks like something that i could work with :). Is this beta or even before beta stage?

One more question, it's a n00b-one i'm afraid... The output card I use is card 1, not 0. I'm using the Hifiberry output, see aplay -l:

Code: [Select]
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 []
  Subdevices: 0/1
  Subdevice #0: subdevice #0

How do i use card 1? Is it as easy as "hw:1,0"?

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: Swap left right audio channel
« Reply #9 on: November 20, 2015, 03:39:23 PM »
How do i use card 1? Is it as easy as "hw:1,0"?

Hi Maurits,

Yes.

I thought you were talking about HDMI audio out?

Code: [Select]
# swap - Generated by piCorePlayer
pcm.!default {
type route
slave.pcm "hw:1,0"
ttable {
0.1 1
1.0 1
}
}
or this. Sometimes I had to use plughw.
Code: [Select]
# swap - Generated by piCorePlayer
pcm.!default {
type route
slave.pcm "plughw:1,0"
ttable {
0.1 1
1.0 1
}
}

Remember to:
  • Clear Output setting in Squeezelite setting page
  • Backup
  • Restart Squeezelite

regards
Greg

Offline Maurits

  • Newbie
  • *
  • Posts: 9
Re: Swap left right audio channel
« Reply #10 on: November 21, 2015, 06:13:22 AM »
Thanks a lot Greg! The plughw did it, left and right are swapped!!  8) 8) 8)