LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-18-2014, 11:36 PM   #1
Digger1
LQ Newbie
 
Registered: Sep 2011
Location: Colorado Springs, CO
Distribution: Debian Squeeze
Posts: 24

Rep: Reputation: 0
Reroute All Audio to Right Speaker


Hello all,

I've got an Asus eee pc 901 with Wheezy running on it (quite nicely, thank you).

The netbook has two speakers and the left one took a dump. I guess I could open it up and swap out the speaker pair, but I'm sorta lazy and would prefer a software solution if I could rig one up. Stereo sound from the speakers is not important to me, but I'd like to preserve stereo capability in the headphone.

I use ALSA. What I'd like to do is set up a scheme whereby the signal that is supposed to go to the now defunct left speaker gets routed to the right speaker, resulting in mono sound from the right speaker. I'd like this capability to be set at boot time, so I could run applications without having to do something special for the sound.

I've fooled around with ALSA and even loaded jack and fooled with it. No success as of yet.

Any ideas out there?

TIA!
 
Old 04-19-2014, 05:36 PM   #2
turtlebay777
Member
 
Registered: Apr 2014
Posts: 39

Rep: Reputation: 3
How about opening the audio section and moving the left/right slider all the way to the right?
 
Old 04-19-2014, 10:48 PM   #3
Digger1
LQ Newbie
 
Registered: Sep 2011
Location: Colorado Springs, CO
Distribution: Debian Squeeze
Posts: 24

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by turtlebay777 View Post
How about opening the audio section and moving the left/right slider all the way to the right?
Hi Turtle,

Thanks for your reply.

I don't think this will work for me. Are you performing this action on an Asus eee pc 901? That is what I'm working with.

If you ARE referring to an eee pc 901, which operating system are you using? I'm using Debian Wheezy.
 
Old 04-19-2014, 10:55 PM   #4
Digger1
LQ Newbie
 
Registered: Sep 2011
Location: Colorado Springs, CO
Distribution: Debian Squeeze
Posts: 24

Original Poster
Rep: Reputation: 0
More information:

The "lspci -s 00:1b" command yields:

Code:
00:1b.0 Audio device: Intel Corporation NM10/ICH7 Family High Definition Audio Controller (rev 02)
The "amixer info" command yields:

Code:
Card default 'Intel'/'HDA Intel at 0xf7eb8000 irq 44'
  Mixer name    : 'Realtek ALC269'
  Components    : 'HDA:10ec0269,1043831a,00100004'
  Controls      : 16
  Simple ctrls  : 10

I'm still stumped on this problem.....
 
Old 04-20-2014, 12:27 AM   #5
bcwagne
Member
 
Registered: Feb 2008
Distribution: Debian Testing, OSX
Posts: 164

Rep: Reputation: 32
It sounds like you need to downmix your audio to mono, then output it normally. Here are a few options, assuming (as you say) you're using ALSA:

http://superuser.com/questions/15552...-mono-on-linux
http://askubuntu.com/questions/17791...-audio-to-mono
http://pastebin.com/Y3MMae6V
https://bbs.archlinux.org/viewtopic.php?id=103694

I've never done it, but all of these solutions seem similar. The other options are to repair your speaker, or modify the circuit so that it is shorted to mono, but as you said, you are not going to do that.

Good luck!
 
Old 04-20-2014, 11:11 PM   #6
Digger1
LQ Newbie
 
Registered: Sep 2011
Location: Colorado Springs, CO
Distribution: Debian Squeeze
Posts: 24

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bcwagne View Post
It sounds like you need to downmix your audio to mono, then output it normally. Here are a few options, assuming (as you say) you're using ALSA:

http://superuser.com/questions/15552...-mono-on-linux
http://askubuntu.com/questions/17791...-audio-to-mono
http://pastebin.com/Y3MMae6V
https://bbs.archlinux.org/viewtopic.php?id=103694

I've never done it, but all of these solutions seem similar. The other options are to repair your speaker, or modify the circuit so that it is shorted to mono, but as you said, you are not going to do that.

Good luck!
bc,

Thanks for those links! I'm actually making progress now!

I created a "/etc/asound.conf" file and put the following content into it:

Code:
pcm.!default makemono

pcm.makemono {
    type route
    slave.pcm "hw:0,0"
    ttable {
        0.1 1    # in-channel 0 (left), out-channel 1 (right), 100% volume
        1.1 1    # in-channel 1 (right), out-channel 1 (right), 100% volume
    }
}
After a boot, I got what I was after...as far as the speakers went. Both channels of audio are now being piped to the right speaker. Now, I can reach in and snip the wires leading to the overheating and weak sounding left speaker!

I still have a problem, however.

I'm trying to get stereo sound back into my headphones. Is this possible after the external speakers have been set up for mono sound?

Alternatively, I'm wondering if there is a way for the computer to automatically run some sort of script after the headphone jack has been inserted.

Any more ideas out there?
 
Old 04-20-2014, 11:56 PM   #7
Digger1
LQ Newbie
 
Registered: Sep 2011
Location: Colorado Springs, CO
Distribution: Debian Squeeze
Posts: 24

Original Poster
Rep: Reputation: 0
I think I might be able to work out something with the hints present in this link:


https://bbs.archlinux.org/viewtopic.php?id=141910


Any other ideas?
 
Old 04-21-2014, 01:01 PM   #8
bcwagne
Member
 
Registered: Feb 2008
Distribution: Debian Testing, OSX
Posts: 164

Rep: Reputation: 32
I think in order to get stereo out of headphones, but mono out of the speakers, you have to have a script to change the alsa settings back to stereo. I think on one of those threads there was some info about that.

So you'll end up with two configuration files: One for stereo (headphones), and one for mono (speaker), and you'll just restart alsa, loading the appropriate configuration file according to your needs. Kind of a clunky workaround, but it should work.

Edit:

Okay...I'm not sure how all this works, since I've never done it, but I think the idea is that you can set up virtual devices for your needs. You can set up one virtual device for stereo playback, and one virtual device for mono playback. It looks (at a first glance) to be fairly complicated, but it should be doable. Here is a more detailed explanation/place to start:

http://www.alsa-project.org/main/index.php/Asoundrc (The official ALSA page)
http://www.volkerschatz.com/noise/alsa.html

These are some SIMILAR examples, but not the same:

http://ubuntuforums.org/archive/inde...t-1952124.html
http://www.raspberrypi.org/forums/vi...p?f=29&t=33431
http://www.robertwrose.com/2011/09/l...icrophone.html

Edit:

Oh, and if it were me, I'd see if I could put the alsa configuration files in my home directory and load them from there. Simply from a system administration standpoint, the file in /etc should be pretty standard, in case other users need to just have things default, whereas your personalized settings should only be present in your /home. Not that it really matters from a practicality standpoint, since you're the only user of that machine...

Again, best of luck!

Last edited by bcwagne; 04-21-2014 at 10:37 PM. Reason: Added information
 
Old 05-17-2014, 11:03 PM   #9
Digger1
LQ Newbie
 
Registered: Sep 2011
Location: Colorado Springs, CO
Distribution: Debian Squeeze
Posts: 24

Original Poster
Rep: Reputation: 0
OK, finally got some time to fiddle with this.

I've got the system working to my satisfaction. I'm not especially proud of my solution, but it works for me.

Let me reiterate that I am rocking an Asus eee PC 901, running Debian Wheezy.

I first created a "/etc/asound.conf" file:

Code:
pcm.!default makemono

pcm.makemono {
     type route
     slave.pcm "hw:0,0"
     ttable {
          0.1 1   # in channel 0 (left), out channel 1 (right), 100% volume
          1.1 1   # in channel 1 (right), out channel 1 (right), 100% volume
     }
}
"makemono" effectively downmixes stereo to mono and spits the sound out of the right speaker.

I then created a "/etc/acpi/events/asus-headphones" file:

Code:
event=jack/headphone*
action=/home/user/scripts/headphones.sh %e
It turns out that, for my machine, anyway, plugging a headphone jack in and pulling it back out are acpi events. I used this fact to my advantage.

Here is the script ("/home/dg/scripts/headphones.sh") that is invoked by said acpi events:

Code:
#!/bin/sh

# This is a script that runs when a headphone jack is either inserted or removed.  This will give you stereo sound when a headphone jack is inserted and will revert back to all sound being routed to the right speaker when a headphone jack is not inserted.

if [ $3 = "plug" ]
then

	# FYI, the text below, up to and including the "DISPLAY=$..." line, is needed so that any user can read the resulting zenity message.

	ACTIVE=$(ck-list-sessions | awk -F' = ' '
	    function f(){if(A=="TRUE"){P=U"\t"D;gsub("'"'"'","",P);print P}}
	    $1=="\tunix-user"{U=$2} 
	    $1=="\tx11-display"{D=$2} 
	    $1=="\tactive"{A=$2} 
	    END{f()} /^[^\t]/{f()}
	')
	USERID=${ACTIVE%    *} # tab
	USERNAME=$(getent passwd $USERID|cut -f1 -d':')
	# DISPLAY=${ACTIVE#*  } # tab
	DISPLAY=:0.0

	DISPLAY="$DISPLAY" su $USERNAME -c "zenity --info --text='The system has detected that a headphone jack has been plugged in.  If you want stereo sound in said headphones, and the sound-producing application is currently running, you will need to restart said application (this means that if you were using the browser to listen to something, you will need to restart said browser) to get stereo sound.  If the sound producing application is NOT currently running, then you are good to go.'"

# Comments out the "default" line in "/etc/asound.conf", sending you back to system defaults (stereo).

sed -i '/^pcm.!default makemono/ s/^/# /' /etc/asound.conf

fi

if [ $3 = "unplug" ]
then

	ACTIVE=$(ck-list-sessions | awk -F' = ' '
	    function f(){if(A=="TRUE"){P=U"\t"D;gsub("'"'"'","",P);print P}}
	    $1=="\tunix-user"{U=$2} 
	    $1=="\tx11-display"{D=$2} 
	    $1=="\tactive"{A=$2} 
	    END{f()} /^[^\t]/{f()}
	')
	USERID=${ACTIVE%    *} # tab
	USERNAME=$(getent passwd $USERID|cut -f1 -d':')
	# DISPLAY=${ACTIVE#*  } # tab
	DISPLAY=:0.0

	DISPLAY="$DISPLAY" su $USERNAME -c "zenity --info --text='The system has detected that a headphone jack has been unplugged.  If you want both sound channels to be sent to the right speaker (desired), and the sound-producing application is currently running, you will need to restart said application (this means that if you were using the browser to listen to something, you will need to restart said browser) to get the proper sound.  If the sound producing application is NOT currently running, then you are good to go.'"

# Un-comments the "default" line in "/etc/asound.conf", sending you back to stereo downmixed to mono, out the right speaker.

sed -i 's/^# pcm/pcm/' /etc/asound.conf

fi
Note that the zenity messages are quite descriptive, as I have some unsophisticated users on this machine.


Last, I added the following line to my "/etc/rc.local" file:

Code:
sed -i 's/^# pcm/pcm/' /etc/asound.conf
This reconfigs the "/etc/asound.conf" file, if required, for speaker use vice headphone use, upon boot.


I thank everyone here who helped me out and, in turn, hope that my solution will be helpful to someone else, if for no other reason than to get them pointed in the right direction in solving their problem.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to stop audio from playing out the PC speaker ? Ubuntu 11.10 solorize Ubuntu 8 10-19-2011 07:43 AM
Audio from music player to speaker yethish Linux - Newbie 3 05-12-2011 07:40 AM
My audio speaker is not working REDHAT 5.0 manred Linux - Newbie 4 04-04-2009 12:15 PM
Onboard audio and speaker static phyrko Linux - Hardware 2 04-18-2007 03:45 AM
4 speaker audio not working GreenerLinux Mandriva 1 11-15-2003 11:05 PM


All times are GMT -5. The time now is 12:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration