Bluetooth stereo audio with XMMS

(wikify slightly)
Line 1: Line 1:
-
This howto for getting '''[[Bluetooth]] stereo audio with XMMS''' makes the assumption that you are comfortable with the command line and the vi editor.  The user them self is responsible for the quality of their work, and although I'm enjoying my BT headphones with my N800 it doesn't mean it will work for everyone.  Never underestimate the power of a Geek to out think their self.  For now this tutorial only works on the n800 due to the fact that the 770 doesn't have enough oompf for XMMS.  However I'm convinced that some of the information herein can be used with any mplayer based (like kagu) media player or mplayer itself, though I've not tested it. (I'm using my 770 for other tests, I'm playing with)  
+
{{out of date}}
 +
 
 +
This howto for getting [[Bluetooth]] stereo audio with XMMS makes the assumption that you are comfortable with the command line and the vi editor.  The user them self is responsible for the quality of their work, and although I'm enjoying my BT headphones with my N800 it doesn't mean it will work for everyone.  Never underestimate the power of a Geek to out think their self.  For now this tutorial only works on the [[Nokia N800|N800]] due to the fact that the 770 doesn't have enough oompf for XMMS.  However I'm convinced that some of the information herein can be used with any mplayer based (like kagu) media player or mplayer itself, though I've not tested it. (I'm using my 770 for other tests, I'm playing with)  
==Get Software==
==Get Software==
Line 78: Line 80:
For whatever reason, it seems that although BT stereo needs all of the CPU room it can grab it isn't capable of over ridding the power saving features in the IT.  The next step will over ride this and  stop the drops.   
For whatever reason, it seems that although BT stereo needs all of the CPU room it can grab it isn't capable of over ridding the power saving features in the IT.  The next step will over ride this and  stop the drops.   
-
I created a small shell script below.  open vi and copy & paste or type this in.  (much easier than typing it new every time you need it.)  I called the script blues using the vi editor:
+
I created a small shell script below.  open vi and copy & paste or type this in.  (much easier than typing it new every time you need it.)  I called the script blues using the vi editor:
# vi blues
# vi blues
 +
<source lang="bash">
 +
#!/bin/sh
 +
# CPU power mode changer linuxrebel 2008
 +
# Ask what we are to do
 +
echo "bluetooth use state: 1 on; 2 off"
 +
read ans
 +
# take action based on that request
 +
if [ $ans -eq "1" ]; then
 +
      # go into a mode where the cpu is always at full speed
 +
      echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
 +
elif [ $ans -eq "2" ]; then
 +
        # Go into the normal demand driven mode
 +
        echo ondemand  > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
 +
else
 +
      # in case you typed wrong you won't think something happened that didn't
 +
      echo "Try again hombre $ans is not an option"
 +
fi
 +
</source>
-
      #!/bin/sh
+
I then save it, chmod it 755 and through sudo, run it. choose 1, load up XMMS and enjoy as I am hours of near dropout free music.   
-
      # CPU power mode changer linuxrebel 2008
+
-
      # Ask what we are to do
+
-
      echo "bluetooth use state: 1 on; 2 off"
+
-
      read ans
+
-
      # take action based on that request
+
-
    if [ $ans -eq "1" ]; then
+
-
            # go into a mode where the cpu is always at full speed
+
-
            echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
+
-
    elif [ $ans -eq "2" ]; then
+
-
            # Go into the normal demand driven mode
+
-
            echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
+
-
    else
+
-
            # in case you typed wrong you won't think something happened that didn't
+
-
            echo "Try again hombre $ans is not an option"
+
-
    fi
+
-
I then save it, chmod it 755 and through sudo, run it.  choose 1, load up XMMS and enjoy as I am hours of near dropout free music.   
 
-
----
 
'''Post:'''
'''Post:'''
When you are done just re-run blues and choose 2, this will put it back into the normal ondemand mode, and ensure the highest power saving mode.   
When you are done just re-run blues and choose 2, this will put it back into the normal ondemand mode, and ensure the highest power saving mode.   
-
 
-
[[Category:Users]]
 
[[Category:Media]]
[[Category:Media]]
[[Category:Bluetooth]]
[[Category:Bluetooth]]
[[Category:Power users]]
[[Category:Power users]]
 +
[[Category:N8x0]]

Revision as of 15:56, 6 December 2010

Image:Ambox_content.png
This article is out-of-date, and needs to be updated.
Please see the talk page for discussion.

This howto for getting Bluetooth stereo audio with XMMS makes the assumption that you are comfortable with the command line and the vi editor. The user them self is responsible for the quality of their work, and although I'm enjoying my BT headphones with my N800 it doesn't mean it will work for everyone. Never underestimate the power of a Geek to out think their self. For now this tutorial only works on the N800 due to the fact that the 770 doesn't have enough oompf for XMMS. However I'm convinced that some of the information herein can be used with any mplayer based (like kagu) media player or mplayer itself, though I've not tested it. (I'm using my 770 for other tests, I'm playing with)

Get Software

Get XMMS here

You will also find that with XMMS you will need a different kind of keyboard (it isn't Hildon aware.) and that is also available in the debfarm repo. It's called xvkbd. Get xmms + any extra's you want (like infinity) and procede. NOTE: Due to the way crossfade works you can't use it + the Alsa plugin so no crossfade for BT headphones.

Bluetooth setup

First step is of course to properly setup your headphones. Follow your particular headphones instructions and pair your n8XX with the headphones. Don't bother going any further till this is done. Once completed the real fun begins.

Now we go here and follow the first post and it's instructions on how to enable a2dp. In my case I did all of this by hand, but this post seems to make life much easier so, why not?

Next step involves two additional edits to a file. These edits I've found improve, or rather decrease the number of dropouts especially in a bluetooth rich environment (like my office)

Using vi open the file /etc/bluetooth/hcid.conf

  1. vi /etc/hcid.conf

now look for this section:

       # Default link mode
       #   none   - no specific policy
       #   accept - always accept incoming connections
       #   master - become master on incoming connections,
       #            deny role switch on outgoing connections
       lm accept;

you need to change the last line to:

       lm accept,master;  

Notice that there is no space around the comma, this is important as the list is comma delineated, not space. What this doesm, is tells the IT that it can be the master, and control the connection. This seems to decrease the tendency of BT devices to be disturbed by a stronger signal from another device (like someone with a BT phone in their pocket, walking up to talk to you.)

Next we need to find this section, which should be the very next section:

       # Default link policy
       #   none    - no specific policy
       #   rswitch - allow role switch
       #   hold    - allow hold mode
       #   sniff   - allow sniff mode
       #   park    - allow park mode
       lp rswitch,hold,sniff,park;

Now edit it and remove the words rswitch and sniff. so that it looks like this:

       lp hold,park;

The rswitch is for a device that can switch roles between the lower quality headphone protocol and the higher quality a2dp one. It's in our interest to stay high quality. The sniff allows the IT to search for other devices while connected to you. Not desirable in a BT rich environment.

Restart the IT in order to get all of the BT changes picked up. It seems that just restarting the service doesn't quite do the Linux thing and pick up all the changes, so you have to do it win style.

At this point you should have a set of BT headphones that can talk with your IT. If you have mplayer installed the instructions listed above for installing a2dp list a way from the command line to play an individual mp3 with mplayer.


XMMS Setup

The worst is over, Now is time to get XMMS rocking and rolling. Step one is to turn on your headphones and connect to the IT. Once we make the config edits in XMMS we will lock up if it cannot find the bluetooth device.

Open XMMS, then click to open the menu (upper left hand corner of the main xmms 'window') scroll down to Options => Preferences once that window opens choose the first tab labeled "Audio I/O Plugins" Near the bottom you will see a long bar/button click on it and choose the "Alsa 1.2.10 Output Plugin (libALSA.so)" Once you do the 'Configure' button will ungrey click this a new window will open. This is where you will need the xvkbd I mentioned above.

Now using the xvkbd keyboard you installed earlier. click in the small window that says default and enter the word bluetooth. (if you didn't install the xvkbd follow the next few steps till you see the alternate for this.)

Just below this there is a section called mixer. In this section click the box that says "Use software volume control" Now close all the windows using the 'OK' buttons. If you didn't install xvkbd close XMMS, otherwise skip the next step.

For those who didn't use xvkbd, once XMMS has closed open the file .xmms/config and look for the ALSA section and change the line

    pcm_device=default

and make it read

    pcm_device=bluetooth

NOTE some have found that sometimes it takes a couple of re-edits because XMMS changed things back. I've not seen that but, this is a computer and anything can happen. You'll know it happened when sound comes out the IT, and not your headphones.


Last Setup:

For whatever reason, it seems that although BT stereo needs all of the CPU room it can grab it isn't capable of over ridding the power saving features in the IT. The next step will over ride this and stop the drops.

I created a small shell script below. open vi and copy & paste or type this in. (much easier than typing it new every time you need it.) I called the script blues using the vi editor:

  1. vi blues
#!/bin/sh
# CPU power mode changer linuxrebel 2008
# Ask what we are to do
echo "bluetooth use state: 1 on; 2 off"
read ans
# take action based on that request
if [ $ans -eq "1" ]; then
       # go into a mode where the cpu is always at full speed
       echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
elif [ $ans -eq "2" ]; then
        # Go into the normal demand driven mode
        echo ondemand  > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
else
       # in case you typed wrong you won't think something happened that didn't
       echo "Try again hombre $ans is not an option"
fi

I then save it, chmod it 755 and through sudo, run it. choose 1, load up XMMS and enjoy as I am hours of near dropout free music.

Post:

When you are done just re-run blues and choose 2, this will put it back into the normal ondemand mode, and ensure the highest power saving mode.