Page 1 of 1

[SOLVED] Adding L + R Audio in Software

Posted: Mon Oct 09, 2017 3:59 pm
by Fredl
EDIT: I'm gonna put the solution here, so you don't have to scroll. ;)

What is this? A rather easy fix, which combines the left and right audio channels into a mono channel. That way, you'll listen to both channels even on a mono speaker. (Keep in mind that you'll only have mono on both channels as well when using headphones!)

Step by step:

1. exit retropie (F4) or connect via SSH
2. type 'sudo nano /etc/asound.conf' (In my case this file was emty yet)
3. copy the code below into the file (all credit for the code goes to the poster from the link above)

Code: Select all

pcm.card0 {
type hw
card 0
}

ctl.card0 {
type hw
card 0
}

pcm.monocard {
slave.pcm card0
slave.channels 2
# type plug
type route
ttable {
# Copy both input channels to output channel 0 (Left) with half amplitude.
0.0 0.5
1.0 0.5
# Same for channel 1 (Right)
0.1 0.5
1.1 0.5
}
}

ctl.monocard {
type hw
card 0
}

pcm.!default monocard
4. type 'sudo /etc/init.d/alsa-utils restart'
5. type 'sudo reboot'
6. go to Retropie -> Audio -> Select your audio device (Jack or HDMI)




ORIGINAL POST:

Hi I'm kinda dissapointed by only hearing the left channel of my games...

So I'm looking for a way to add the left and right channels before they leave the Pi. What I thought of:

1. There is somehow a way of doing this globally for the Pis output....?
2. Find the piece of code in every single emulator and compile it myself. (Tedious af... but doable)
3. Adding the analog signals with a adding/mean circuit. I'm trying to avoid opening up my babies for the 1000th time.

Anyone has an idea on how this could be done?
Thanks, Fred

Re: Adding L + R Audio in Software

Posted: Tue Oct 10, 2017 3:03 am
by salami738
Hi,
maybe you could try downmixing stereo to mono via ALSA.
Link: https://www.raspberrypi.org/forums/view ... 29&t=33431

Re: Adding L + R Audio in Software

Posted: Tue Oct 10, 2017 3:32 am
by Fredl
salami738 wrote:
Tue Oct 10, 2017 3:03 am
Hi,
maybe you could try downmixing stereo to mono via ALSA.
Link: https://www.raspberrypi.org/forums/view ... 29&t=33431

Cool, thanks for the quick answer. Will try it as soon as I get home. One question though:

The code lines:

Code: Select all

    # Copy both input channels to output channel 0 (Left).
    0.0 1
    1.0 1
shouldn't they be rather

Code: Select all

    # Copy both input channels to output channel 0 (Left).
    0.0 0.5
    1.0 0.5
to avoid clipping when adding two identical signals?

Re: Adding L + R Audio in Software

Posted: Tue Oct 10, 2017 11:02 am
by Fredl
Ok it worked (with some troubles). As I expected simply adding left and right to the left channel caused massive distortion.

Here's a step by step guide with the corrected code. (I wonder why this hasn't come up in this forum yet, as most GBZs are mono...? ^^)

1. exit retropie (F4) or connect via SSH
2. type 'sudo nano /etc/asound.conf' (In my case this file was emty yet)
3. copy the code below into the file (all credit for the code goes to the poster from the link above)

Code: Select all

pcm.card0 {
type hw
card 0
}

ctl.card0 {
type hw
card 0
}

pcm.monocard {
slave.pcm card0
slave.channels 2
# type plug
type route
ttable {
# Copy both input channels to output channel 0 (Left) with half amplitude.
0.0 0.5
1.0 0.5
# Same for channel 1 (Right)
0.1 0.5
1.1 0.5
}
}

ctl.monocard {
type hw
card 0
}

pcm.!default monocard
4. type 'sudo /etc/init.d/alsa-utils restart'
5. type 'sudo reboot'
6. go to Retropie -> Audio -> Select your audio device (Jack or HDMI)


I highly encourage everybody to do this with their GBZ, as it's a super easy fix, which lifts the quality of some games drastically ^^

Re: [SOLVED] Adding L + R Audio in Software

Posted: Thu Mar 01, 2018 12:40 pm
by Merlin
So software mixing is better than hardaware mixing?(L with 10 ohm resistor and R with 10 ohm resistor connected togheter)?
This mix affect hdmi audio output also?(if connected to a stereo tv)

Re: [SOLVED] Adding L + R Audio in Software

Posted: Fri Mar 02, 2018 10:25 pm
by FlashyFrank
This is great! I was trying to figure this out and couldn't find anything on how to do it. Makes my mono sound way better!

Re: [SOLVED] Adding L + R Audio in Software

Posted: Fri Mar 02, 2018 10:28 pm
by FlashyFrank
Merlin wrote:
Thu Mar 01, 2018 12:40 pm
So software mixing is better than hardaware mixing?(L with 10 ohm resistor and R with 10 ohm resistor connected togheter)?
This mix affect hdmi audio output also?(if connected to a stereo tv)

I believe this is for people who are using mono speaker with mono input and the 10 ohm resistors are for if you have stereo input into a mono speaker? Someone who is a little more educated might be able to clear that up.

Re: [SOLVED] Adding L + R Audio in Software

Posted: Sat Mar 03, 2018 5:28 am
by Fredl
Merlin wrote:
Thu Mar 01, 2018 12:40 pm
So software mixing is better than hardaware mixing?(L with 10 ohm resistor and R with 10 ohm resistor connected togheter)?
This mix affect hdmi audio output also?(if connected to a stereo tv)
It's not necessarily better. The mixing circuit you're using has its problems though, see this post:
https://electronics.stackexchange.com/q ... io-signals
(Should be fine however)

The advantage of the software solution is
1. You can undo it easily!
2. You can do it with a finished build without opening the thing and adding electronics.

And yes, this will also affect hdmi! It will affect any audio output device!

Re: [SOLVED] Adding L + R Audio in Software

Posted: Sat Sep 12, 2020 11:36 am
by jonny556er
I tried this solution with my freeplay zero w and I lost all audio. I was able to reverse everything but I'm still missing part of the audio, especially in sonic games. I've tried a few other things too but I got errors and no audio, anyone out there have a solution I haven't tried?

edit: It's not just sonic games, I just tested snes games and I'm thinking its any stereo sound game. I think if I can force mono sound it would sound better.