USB Audio on BBGW/BBB using also and mpg321 : Distorted/clipped/too fast playback

Hi all,

I’m still pretty new to my BBB / BBGW (I prefer the BBGW simply because of it’s inbuilt wifi - real simple).
So, I’m running on a SEED BeagleBone Green Wireless.
with Debian / Linux 8 : 2016-06-14. The system is up to date - as of now.
I’m running headless via wi-fi ssh on Terminal (Mac Sierra).
and I’m trying to add sound playback of mp3 / wav files.

So Far:

I’ve installed / updated alsa and alsa-utils.
I’ve plugged in a standard 10$ USB sound stick form EC Technology - some post suggest I get this one - I’m ambivalent as to the precise device but the smaller the better :
I’m also happy to switch to a new device if there is an even smaller / better / more readily hackable device available - but that’s probably for another time - suggestions always welcome though !)

I’ve used ‘aplay -l’ to confirm the USB device exists :
card0:WILINK8_BT… device 0: WILIINK8 …
Subdevices: 0/1
Subdevice #0: subdevice #0
card1: Device [USB Audio Device], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0

I have reconfigured the alsa device file (/usr/share/alsa/alsa.conf) to direct audio to the USB card (defaults.ctl.card 1 and defaults.pcm.card 1) and not the BT module and I can hear pink noise (sound-test) from the connected USB Audio stick & speakers / headphones following an alsa restart / system reboot.
I have installed mpg321 and, more recently, madplay.
I have dumped some ripped mp3 music files into a ‘Music’ directory on uSDCard and can hear the output with :
mpg321 -g 50 /media/uSDCard/Music/MyMusicTrack.mp3

The sound that I hear appears to be ‘clipped’. It is distorted and plays back too fast but with no increase in pitch etc. just like a broken / poor 'phone connection.

Initially, I thought the problem may be with the track/file I had copied across & chosen to play, so selected another (no difference). Then I selected and left playing the whole folder (around 12 tracks) whilst I did some research.
mpg321 -g 50 /media/uSDCard/Music/*

Oddly enough, after a couple of tracks the sound was perfect and I listened to the rest of the selection (maybe 8 or 9 tracks in total) with some satisfaction. I also concluded (incorrectly) that the problem must have been with some of the files having been corrupted during the transfer process. However, when I decided to play the tracks again I note they are ALL suffering from the same clipped / broken / slightly too fast playback problem.

I’m delighted to have gotten this far but… frustration… so near and yet so far…

I have tried with powered speakers and with a simple headset… (no difference, remains distorted / clipped).
I have tried with mpg321 and madplay… (no difference, remains distorted / clipped).

Anyways, I’m now pretty sure this is a sampling mismatch / there will be some setting I’ve missed but, like my opening line said, I’m still pretty new to the BBB / BBGW and I’m unsure as to how to proceed - especially as I’m pretty nervous of taking too many retro-steps and ‘playing’ with far too little knowledge. I have googled and forum-ed this but find it confusing enough extracting relevant Wheezy / Jessie differences and trying to adapt Raspbian / Debian examples etc… anyways… I’m lost…
Apologies for the length of this post but too much info is generally better than way too little… I hope…
Thanks for reading, hope you can give me some pointers.

Sound is tricky because there are several layers that interact in
interesting ways: hardware, the USB layer, sound drivers, and the
transcoder software. I'd try to simplify: for instance, exclude the
transcoding layer by translating the files offline to a non-compressed
format, like .wav, and playing those. Now, the .wav files do have a
tradeoff: they don't require decoding, but they are larger, so they
may tax the mass storage bandwidth, so make sure to put them on the
fastest storage you have (presumably eMMC, or even a ramdisk). If the
.wav files play OK, then you'll know that the mpeg3 decode is to
blame. Othwerwise, it's down to examining other layers: e.g. trying a
different hardware sound card.

Thanks Przemek. Yeah, I’ve spent a bit of time now trying to boot up on the complexities of sound and hit upon the various ‘layers’ sitting between the file (mp3 or wav) and the speakers (powered or headset). A little over my head at the moment. I guess more research and playing around will be required before I get this one ‘cracked’ !

I tried your ‘convert compressed mp3 to uncompressed ‘wav’ idea’ with no luck, In fact the ‘mp3’ sound, although clipped and little too fast is comprehensible (one can hear it’s Vienna/Ultravox or Mr. X/Genesis but no such luck with the ‘wav’ just horrible high pitched white noise…

What’s most strange is that 80% of the ‘mp3’ tracks, the first time round, played perfectly - I was like a pig in the proverbial…

From your response, I guess I should, therefore, be concentrating on the alsa / player setup and config rather than the USB audio stick (?) - that’s helpful. At least, in theory, I know where to concentrate my time…

One question at this time, if you or anyone else does have a working USB Audio stick config, maybe you’d be willing to share the make / model ? It would be good to rule that out right now especially as ‘playing’ with alsa could be more hassle than it’s worth ESPECIAALY if it’s the card !!!

Back to the drawing board for me ! (I guess first thing (I used mpg321 to handle the ‘mp3’/‘wav’ conversion) is for me to go check the new ‘wav’ plays form my Mac… just to check !!

Thanks anyways. Have a great weekend !

Hoping it may help : a wee bit more info :

I checked :
-1- apt-get install alsa-oss — Already installed, no updates required.
-2- apt-get install libsamplerate0 — Already installed, no updates required.

So I thought I should probably check that i had initialised alsa correctly (I can’t honestly remember, but quite possibly not) …
-3- alsactl init —which produced :

alsactl: sysfs_init:48: sysfs path ‘/sys’ is invalid

Found hardware: “WILINK8_BT” “” “” “” “”

Hardware is initialized using a generic method


OK. Not quite what I was hoping for… on two levels…
1: there’s no mention of the USB Card that DOES show up with aplay but isn’t itemised in the ‘alsactl init’ output :
aplay -l

**** List of PLAYBACK Hardware Devices ****

card 0: WILINK8BT [WILINK8_BT], device 0: WILINK8 wilink8_bt-hifi-0 []

Subdevices: 0/1

Subdevice #0: subdevice #0

card 1: Device [USB Audio Device], device 0: USB Audio [USB Audio]

Subdevices: 0/1

Subdevice #0: subdevice #0

(card 1 is the device I want to use)
and 2: I thought I’d already instructed alsa.conf to configure itself for device:card 1 with :
defaults.ctl.card 1
defaults.pcm.card 1
(FYI, I ‘found’ asla.conf at /usr/share/alsa/alsa.conf )
not to mention the fact that ‘speaker-test’ produces pink noise out of both speakers attached to the USB stick…

Any ideas ?
Really appreciated.
Have a great weekend.

As a final note for the night :

I went back into the alsa.conf file to take another look (getting ‘desperate’ / keen to put this one to bed for the weekend !) and :

defaults.ctl.card 1 ## CONFIGURING FOR USB AUDIO STICK - ORIG =‘0’ (20170208)

defaults.pcm.card 1 ## AS ABOVE - ORIG = ‘0’ (20170208)

defaults.pcm.device 0 ## AS ABOVE - TRIED ‘1’ - THREW ERRORS

defaults.pcm.subdevice -1 ##AS ABOVE - TRIED ‘0’ - TYHREW ERRORS

defaults.pcm.nonblock 1

defaults.pcm.compat 0

defaults.pcm.minperiodtime 5000 # in us

defaults.pcm.ipc_key 5678293

defaults.pcm.ipc_gid audio

defaults.pcm.ipc_perm 0660

defaults.pcm.dmix.max_periods 0

defaults.pcm.dmix.rate 48000

defaults.pcm.dmix.format “unchanged”

defaults.pcm.dmix.card defaults.pcm.card

defaults.pcm.dmix.device defaults.pcm.device

defaults.pcm.dsnoop.card defaults.pcm.card

defaults.pcm.dsnoop.device defaults.pcm.device

defaults.pcm.front.card defaults.pcm.card

defaults.pcm.front.device defaults.pcm.device

defaults.pcm.rear.card defaults.pcm.card

defaults.pcm.rear.device defaults.pcm.device

defaults.pcm.center_lfe.card defaults.pcm.card

defaults.pcm.center_lfe.device defaults.pcm.device

defaults.pcm.side.card defaults.pcm.card

defaults.pcm.side.device defaults.pcm.device

defaults.pcm.surround21.card defaults.pcm.card

defaults.pcm.surround21.device defaults.pcm.device

defaults.pcm.surround40.card defaults.pcm.card

defaults.pcm.surround40.device defaults.pcm.device

defaults.pcm.surround41.card defaults.pcm.card

defaults.pcm.surround41.device defaults.pcm.device

defaults.pcm.surround50.card defaults.pcm.card

defaults.pcm.surround50.device defaults.pcm.device

defaults.pcm.surround51.card defaults.pcm.card

defaults.pcm.surround51.device defaults.pcm.device

defaults.pcm.surround71.card defaults.pcm.card

defaults.pcm.surround71.device defaults.pcm.device

defaults.pcm.iec958.card defaults.pcm.card

defaults.pcm.iec958.device defaults.pcm.device

defaults.pcm.modem.card defaults.pcm.card

defaults.pcm.modem.device defaults.pcm.device

truncate files via file or tee PCM

defaults.pcm.file_format “raw”

defaults.pcm.file_truncate true

defaults.rawmidi.card 0

defaults.rawmidi.device 0

defaults.rawmidi.subdevice -1

-1- I thought the above might help

-2- You’ll see I tried ‘1’ and ‘0’ on lines 3 and 4.

-3- ran alsactl init

alsa disliked that and mpg321 hung - or seemed to…

-4- restored lines 3 and 4 alsa.conf to 0 and -1

-5- ran alsactl init

-6- tried my playlist again…

Blown away… first two tracks PERFECT… subsequent tracks all clipped / noisy / broken / too fast

Killed the playback and restarted with the two tracks that worked - Not anymore. All are now clipped / noisy / broken / too fast.

Does the above help / shed some light. I’m totally confused.

Thanks mil. Truly appreciated.

Have a great weekend.

This is maybe good news because the error is not subtle. Something is
wrong with the way you convert or play them; a .wav file should simply
play, period. Maybe get some .wav files on the desktop (translate
some mp3 files, or find some .wav files already on your system), and
confirm that they play fine on the desktop, and then move them to BBB.

Thanks Przemek. Appreciated.

Indeed. Transferred my mpg321 converted mp3 → wav track back to my Mac and - played perfectly (as, obviously, did the mp3 track).

I also found a load of wav files, verified they played on the Mac, transferred them to the uSDCard and thence to the BBGW. All played fine on the Mac, all were ‘broken’ (as per last posts) on the BBGW.

What I don’t ‘get’ is that, after updating alsa.conf and re-initialising alsactl, the BBGW seems to play tracks correctly until it detects a change in sample rate (maybe ?) then nothing / no tracks play correctly - not even the ones that just played perfectly !!!

So, all-in-all, I’m still not sure whether it’s a software ‘thing’ or a USB hardware ‘thing’…

I’ll get back onto it first thing in the morning… thanks for your ongoing help.

Maybe try your USB sound card on the Mac. Also, do you have access to
a Linux desktop running a version of Debian comparable to what you
have on the BBB? Maybe try audio there, to compare 'ceteris paribus'.

Hi Przemek,
I’ve been a little tardy following this one up recently - I mean, I do have sound; it’s simply ‘broken’ / distorted and, with all the other items / features of the project, I’ve allowed myself to ‘park’ this one thereby allowing me to continue with the other aspects whilst hoping I’ll ‘stumble’ across something as I progress them and advance my learning in general with the BB series…
Having said that:
-1- I have tried the USB stick on my Mac with the same sound files and listening to streamed radio etc - all work well :frowning:
-2- I do not have Linux per se running on any other machine here - although I do have a spare / naughty Win7 (which I detest) PC, so I do have a potential candidate although where to start with that one?..
-3- I also note that converted files (mp3 to wav using mpg321 on the BB) do not play - worse in fact BUT wav files, transferred to the BB uSDCard from my Mac, play perfectly… so…
Thanks a million for your help and encouragement. I’ll update this thread as and when I have news. Again, thanks - really appreciated.

You could download a bootable Ubuntu/Debian image to a USB stick and
boot from it in the 'live test' mode that doesn't overwrite your hard
disk. It basically has full functionality, and you even can download
and install additional packages if the original image lacks them.
Good luck--I think you're close to the solution, just have to find the
pesky glitch.

Any news on this, as I am really interested in adding sound my system, in the easiest and most stable way…?

Thanks in advance


Unfortunately, I haven’t had much time lately… ‘proper’ work has been hectic.
I will get back onto this though as time allows and will update this thread.
To summarise my final position :
mp3 files played via mpg321 sometimes played perfectly but more-often-than-not did not. Even re-playing a file that previously payed perfectly (on the BB with no changes / amendments / additions to the Distro) would fail - bizarre.
wav files (both those that already existed as wav files and those converted from mp3) displayed pretty much the same issue. The only caveat here is that files converted from mp3 to wav using mpg321 on the BBGW (basically a wi-fi-ed version of the BBB) played as total white-noise / mush and were unrecognisable as music - I had better luck converting them on my Mac and putting them back onto the uSDCard !
You’ll glean more info from my posts above but… sorry… that’s as far as I got :frowning:
Like I say, I’ll update this thread as and when I have some news. Maybe you’d do the same :wink:
Best of luck.