Support > raspberry pi, usb audio > Jittering on RasPi with USB Audio Card

Jittering on RasPi with USB Audio Card

Home Support Java Application (Speaker) – Feedback and Troubleshooting Jittering on RasPi with USB Audio Card

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #670
    JeroenR
    Participant

    Moved from Play.com feedback to your support forums as requested

    I have now purchased SoundSeeder, mainly to use it in combination with the various Raspberry Pis scattered through my house. The quality of the native audio out on the RPi is atrocious so I am using very simple external USB Audio cards. These work great with all applications I run on the RPIs, except Soundseeder, which hiccups so bad it is pretty much inaudible. I have narrowed it down to USB Audio being the problem, plugging a headphone into the RPi’s audio out plays fine, just very bad quality which is beyond Soundseeder’s control. I’d be happy to assist in debugging / testing this, please reach out to me if I can help

    You replied:
    Thanks Jeroen! Please contact me at jekapps@gmail.com or post your problem on http://soundseeder.com/support. I’ll try to reproduce your issues but I don’t have an external USB Audio for my RPi…

    #671
    JeroenR
    Participant

    You can use the fee I paid for the app, with spare change :-), to purchase the USB Audio card at http://www.ebay.co.uk/itm/121476075685?_trksid=p2059210.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

    Alternatively I’d be happy to test / debug things for you. I am using the latest version of Raspbian (on a model B+) with default Alsa settings other than a .asoundrc file that contains the following line to make the USB Audio card the default.

    defaults.pcm.card 1

    Your Card ID may differ, a quick aplay -l will tell the exact ID used by the Audio Device.

    #672
    jekapps
    Keymaster

    Hi Jeroen!

    Thanks for the infos!
    Did you have to install additional audio drivers for the usb audio card?

    #673
    JeroenR
    Participant

    No, it uses the USB Audio Standard, which is supported out of the box by Raspbian

    “aplay -l” shows the following in addition to the standard bcm28355 audio output

    card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
    Subdevices: 1/1
    Subdevice #0: subdevice #0

    • This reply was modified 9 years, 3 months ago by JeroenR. Reason: typo
    #675
    jekapps
    Keymaster

    I’ve been able to reproduce the jittering with an usb soundcard.

    I’m still not sure why this happens, but I’ve found a workaround, that is working with my USB Card.
    Please try the following:

    – Replace the speaker jar file on your Raspberry Pi with the one attached to this post.
    – Start the soundseederspeaker.jar in debug mode by appending the comandline argument “-d”
    You will now see a list of all registered audio mixers:

    Available mixers:
    [0]ALSA [default], version 3.12.28+
    [1]ALSA [plughw:0,0], version 3.12.28+
    [2]ALSA [plughw:0,1], version 3.12.28+
    [3]Set [plughw:1,0], version 3.12.28+
    [4]Port ALSA [hw:0], version 3.12.28+
    [5]Port Set [hw:1], version 3.12.28+
    

    My USB Audio Card is the Audio Mixer with id 3.
    Now stop the speaker (CTRL + C) and launch it with the new comandline arg. “-m”, followed by your desired audio mixer id:
    java -jar soundseederspeaker.jar -m 3

    The “.asoundrc” configuration file can be removed…

    • This reply was modified 9 years, 3 months ago by jekapps.
    #678
    JeroenR
    Participant

    OK, so that makes it possible to use USB Audio, Excellent.
    using .asoundrc to set the USB card as the default still doesn’t work without jittering (other audio software on the same systems needs .asoundrc), but that is OK for now. Added bonus with being able to specify the device on the command line is that (I assume) you can run multiple instances, each sending output to a different device.

    When the -m option is used it shows quite a few mixers, they can’t all be used as that results in errors, which makes it a bit tricky to find the correct number to use. One of my RPis has 2 USB audio cards and I can play through 1 of the USB devices without jittering, but the other USB Audio card jitters very bad. Also if a .asoundrc is present with a different default card then I cannot play through one of the USB cards at all).

    Details below.

    Kitchen-Pi (Standard Raspbian with 1 external USB Audio)
    ========================================================
    java -jar soundseederspeaker_v0.4.1b.jar -m 3
    SoundSeeder Speaker
    Version 0.4.1 beta – built50117
    Copyright 2015 JekApps – http://www.soundseeder.com

    Available mixers:
    [0]ALSA [default], version 3.12.35+
    [1]ALSA [plughw:0,0], version 3.12.35+
    [2]ALSA [plughw:0,1], version 3.12.35+
    [3]Device [plughw:1,0], version 3.12.35+
    [4]Port ALSA [hw:0], version 3.12.35+
    [5]Port Device [hw:1], version 3.12.35+
    Selected mixer: 3
    Device [plughw:1,0], version 3.12.35+
    Supported source line types:
    interface SourceDataLine supporting 8 audio formats, and buffers of at least 32 bytes
    interface Clip supporting 8 audio formats, and buffers of at least 32 bytes

    LivingRoom-Pi (Standard Raspbian with 2 external USB Audio)
    ===========================================================
    [0]ALSA [default], version 3.12.35+
    [1]Device_1 [plughw:0,0], version 3.12.35+
    [2]Device [plughw:1,0], version 3.12.35+
    [3]ALSA [plughw:2,0], version 3.12.35+
    [4]ALSA [plughw:2,1], version 3.12.35+
    [5]Port Device_1 [hw:0], version 3.12.35+
    [6]Port Device [hw:1], version 3.12.35+
    [7]Port ALSA [hw:2], version 3.12.35+

    With .asoundrc set to “defaults.pcm.card 2”
    – Works: 0 (onboard), 2 (USB1), 3 (onboard), 4 (onboard)
    – Error: 1, 5, 6, 7

    With no .asoundrc
    – Jittering: 0 (USB2)
    – Works: 2 (USB1), 3 (onboard), 4 (onboard)
    – Error: 1, 5, 6, 7

    ‘Error’ means the following:
    Exception in thread “SpeakerPlaybackThread” java.lang.IllegalArgumentException: Line unsupported: interface SourceDataLine supporting format PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian
    at com.sun.media.sound.DirectAudioDevice.getLine(DirectAudioDevice.java:174)
    at com.soundseeder.speaker.g.run(Unknown Source)

    So, great progress, but would like to be able to play through the second USB card as well

    #679
    JeroenR
    Participant

    Also, when specifically specifying a mixer using the -m flag, the device (USB Audio) is locked exclusively. If another application wants to use the device I get errors.

    Now, I have no desire to let multiple applications play music at the same time, but when I switch to playing music from the iPad using ShairPlay I don’t want to manully go in via SSH and launch the appropriate process.

    #681
    jekapps
    Keymaster

    Thank you for testing and all the details!
    I’m still not sure if this is an error in my code or if the problem is located in the Pi/Linux/JavaAudio/USB combination.
    There is no difference on Java side, whether you stream to the default audio device or any other device/mixer.
    Its good to know that you can use (most of) your USB-Cards for now, but I’ll keep investigating, how the playback can be improved.

    #705
    mkeyes
    Participant

    Hi!
    So if I was going to roll out Raspberry Pi’s in my house I’d want to use a USB sound card as it’s cheaper than most of the HDMI audio solutions. As long as I use the beta file posted here and configure it to output on the USB sound card everything should work ok, in theory? I realize that it’s still bleeding edge and depending on the sound card I bought, moon phase, and what side of the bed I woke up on could influence it as well. I just wanted to make sure I understood the thread correctly.

    Thanks!

    #712
    jekapps
    Keymaster

    This is hard to say. The solution posted here works fine with my USB sound card. I wasn’t able to reproduce the issues again…

    Maybe you should think about waiting for the first reviews of the new Rasberry Pi 2, which was anounced today. Hopefully they improved the quality of the line out port…

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.