drumloud
Posts: 4
Joined: Tue Nov 05, 2013 7:45 pm
Location: Seattle, WA
Contact: Website

RPi Subsonic Music Server with USB Dac

Tue Nov 05, 2013 8:20 pm

Raspberry Pi Subsonic Music Server with USB Dac

These notes assume that you have Raspberry Pi Subsonic installed and it plays music through the 3.5mm jack and now you want to improve the sound by implementing a USB DAC.

After a week fooling around with my Modi USB DAC (http://schiit.com), I finally found what I was looking for. If you want to use anything other than a cheap USB sound device, apparently the Java jukebox player must be "told" which sound card to use. My RPi kept defaulting to the internal 3.5mm jack, even after I modified the necessary files (asoundrc, alsa-base.conf and asound.conf files) to indicate the default card to use was the USB device card 0. I knew the USB DAC worked because I could do a:

#sudo speaker-test somemp3file.mp3

...and it would play fine through the DAC. But when I fired up Subsonic on the PI, and played a song it would default to the 3.5 Jack. Ahhggg!

What I found was that the Java sound library may reference your sound card as something different than what linux identifies it as when you do a "aplay -l". So...first you need to find out what your soundcards are named in the sound library used in Java. To do that you need to do a little programming trickery.

Create a file in your home directory called "audioDevList.java"

#sudo nano ~/audioDevList.java

...and copy this in it:

import java.io.*;
import javax.sound.sampled.*;

public class audioDevList{
public static void main(String args[]){

//Get and display a list of
// available mixers.

Mixer.Info[] mixerInfo =
AudioSystem.getMixerInfo();
System.out.println("Available mixers:");
for(int cnt = 0; cnt < mixerInfo.length;
cnt++){
System.out.println(mixerInfo[cnt].
getName());
}//end for loop
}
}

Then compile by running:
#sudo nano javac audioDevList.java

Then execute:
#sudo java audioDevList

Here is a sample output:

Available mixers:
Device [plughw:0,0]
NVidia [plughw:0,3]
NVidia [plughw:0,7]
NVidia [plughw:0,8]
NVidia [plughw:0,9]
Intel [plughw:1,0]
CX8801 [plughw:2,0]
Port NVidia [hw:0]
Port Intel [hw:1]
Port CX8801 [hw:2]

Modify your (#sudo nano /usr/bin/subsonic) with your device name: mine happenes to be "Device [plughw:0,0]"

'-Djavax.sound.sampled.SourceDataLine=#Device [plughw:0,0]' \

NOTE: ATTENTION! ATTENTION! ATTENTION!

Note the single quotes and the hash mark(#) before the sound card name. Those are required!

That was it! There may be a whole host of other configuration issues but this was the final hurddle for me. Good Luck!

Be sure to backup your RPi image. Here are the simple instructions:
http://lifehacker.com/how-to-clone-your ... 1261113524

Other Sources:
http://sourceforge.net/apps/mediawiki/s ... le=Players
http://www.raspyfi.com/the-right-usb-da ... pberry-pi/
Picture of My Setup: http://pinnedurl.com/pipic1
Last edited by drumloud on Fri Nov 22, 2013 5:43 pm, edited 1 time in total.

avago
Posts: 14
Joined: Mon Jan 28, 2013 9:20 pm

Re: RPi Subsonic Music Server with USB Dac

Sun Nov 17, 2013 2:58 pm

Thank you for sharing this - I'd got the DAC working under mpd by using plughw:0,0 instead of hw:0,0, but subsonic was driving me mad until I found this.
Where you've put
'Then compile by running:
#sudo nano javac audioDevList.java

Then execute:
#sudo nano java audioDevList '

I took out the word nano.
It's also worth checking with alsamixer that the volume for the DAC isn't set to zero
If a man says something, and a women doesn't hear, is he still wrong?

drumloud
Posts: 4
Joined: Tue Nov 05, 2013 7:45 pm
Location: Seattle, WA
Contact: Website

Re: RPi Subsonic Music Server with USB Dac

Sun Nov 17, 2013 5:56 pm

Thank you! Yes, that was a typo mistake. Execute without the word "nano".

Roof
Posts: 4
Joined: Wed Nov 27, 2013 5:02 pm

Re: RPi Subsonic Music Server with USB Dac

Tue Dec 03, 2013 4:01 pm

Please help,

The speaker test works through my DAC
#sudo speaker-test somemp3file.mp3

But music played through Logitech media player, it reverts back to playing through the headphone jack.

I made a file called (audioDevList.java) in a folder called home on my Pi.
-root on pi the folder takes:squeezeplug>rootfs>home>audioDevList.java

Then i did this:
sudo nano ~/audioDevList.java

...and copy this into the box that opens:

import java.io.*;
import javax.sound.sampled.*;

public class audioDevList{
public static void main(String args[]){

//Get and display a list of
// available mixers.

Mixer.Info[] mixerInfo =
AudioSystem.getMixerInfo();
System.out.println("Available mixers:");
for(int cnt = 0; cnt < mixerInfo.length;
cnt++){
System.out.println(mixerInfo[cnt].
getName());
}//end for loop
}
}

But when i try to compile with this run code (sudo nano javac audioDevList.java) it just opens another box to past code into rather than compiling.

please let me know what i did wrong.

thanks

User avatar
Douglas6
Posts: 4741
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: RPi Subsonic Music Server with USB Dac

Tue Dec 03, 2013 4:50 pm

See the post in this thread previous to yours:
"Thank you! Yes, that was a typo mistake. Execute without the word "nano"
So:

Code: Select all

sudo javac audioDevList.java
sudo java audioDevList
Note: these instructions are for the Subsonic music streamer, and may not apply to the Logitech music player

Roof
Posts: 4
Joined: Wed Nov 27, 2013 5:02 pm

Re: RPi Subsonic Music Server with USB Dac

Tue Dec 03, 2013 5:28 pm

Thanks but i get command not found when i put in (sudo javac audioDevList.java) : (

can u think of a reason the sample sounds play through the Dac but the logitech media sever keeps playing through the head phone jack???

User avatar
Douglas6
Posts: 4741
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: RPi Subsonic Music Server with USB Dac

Tue Dec 03, 2013 6:15 pm

If you have an OS other than the latest Raspian, you may not have Java installed.

I'm afraid I'm not familiar with how the Logitech player works. I imagine it's an ALSA configuration issue, but I'm no expert there either. You might start a new topic with this question, and include the contents of your /usr/share/alsa/alsa.conf and /etc/asound.conf files, and also the results of the 'aplay -L' command. Some sound expert may be able to help.

Return to “Media centres”