radioSHARK in Linux

Some time back I tried to get a Griffin Technology radioSHARK working in Linux, but ran into USB problems. Now Michael Rolig has gotten it to work. Read on for my experience and suggestions.

I was trying to use libusb, and had a lot of trouble writing to an interrupt endpoint.

Michael Rolig has gotten it to work using libhid, and has released a public domain radioSHARK control program.

It requires the latest libhid code from the Subversion repository. Once I had that built, the program worked fine, though it requires root privilege. I suppose you could install it setuid, or perhaps there’s a way to set up the hotplug system to make it available without privs.

The next hurdle was getting the actual sound out of it. The web page suggests that the radioSHARK only support 6400 samples per second, and gives directions for using ecasound to do live play with sample rate conversion. However, my experience is that the radioSHARK is perfectly happy to sample at 8000 or 32000 samples per second, or perhaps other rates.

I’ve never been able to get ecasound to build on a 64-bit platform. I figured out that I can use the ALSA arecord utility to record from it, and aplay to play the recording to my sound card or headset. This records half an hour from a local station:


sudo shark -fm 89.7 # KFJC - Los Altos Hills CA
arecord -d 1800 -c 2 -f S16 -r 32000 -D hw:1,0 foo.wav

Anything that can play .wav files should work with the result. On my system, I can play it with:


aplay -D hw:0,0 foo.wav

Of course, doing it that way doesn’t play it live. One way to do that is:


arecord -c 2 -f S16 -r 32000 -D hw:1,0 | aplay -D hw:0,0

Possibly a “tee” command could be put into the pipeline if you want to record and listen simultaneously.

Maybe JACK would make this stuff easier. JACK is another thing I haven’t yet got working.

If anyone wants it, I can put together Fedora Core 4 RPMs of the shark program and the required version of libhid.

Thanks to Michael for making the code available!

This entry was posted in Hardware, Linux. Bookmark the permalink.

8 Responses to radioSHARK in Linux

  1. Kevin says:

    Eric,
    I’ve been trying to get this to work in FC4 as well, and have had trouble with libhid. If you made a FC4 RPM, I’d be eternally grateful.
    Thanks,
    -Kevin

  2. eric says:

    I put an SRPM and binary RPMS for i386 and x86_64 at http://www.brouhaha.com/~eric/software/fedora/fc4/shark/

    The x86_64 binary RPM seems to work. I have not tested the i386 binary RPM. There is, of course, no warranty.

    Good luck with your RadioShark!

  3. Stu says:

    After much hair-pulling with libhid, I’ve finally gotten it to at least make noise. The feed is skips a lot, though, with “underrun!!!” errors, the static is terrible, and I can’t seem to get ecasound to work properly at all. (aplay/arecord is fine) All that aside, though, it’s progress! Not bad for a little $35 toy. (I got it 1/2 off at a Suncoast store closing sale)

  4. Eric says:

    Yes, libusb and libhid could use some major rearchitecting. Anyhow, I’m surprised that you’re getting underruns. What kind of hardware are you using? Is the USB port being heavily used by other devices, such as disks?

  5. Stu says:

    Actually, the underruns were because I was trying to use the 6400 rate that the wiki suggested. It was too slow for aplay and it kept chewing through its buffer and skipping. If I go up a bit (say 8000) then I stop getting them.

    Which is something else worth mentioning – this website only mentions 8000 and 32000; however, I’ve tried at least a dozen others and all have worked. The highest I’ve gone is 48000 (better than CD quality) and it hasn’t so much as flinched. In fact, it sounds better the higher I go. I haven’t bothered going over 48000 so I really don’t know what the top limit is. Quite an impressive little toy…

  6. Klown says:

    The arecord/aplay tools could not find files in /dev/snd for the “hw:1,0″ parameter. My sound card does come up when referenced as “hw:0,0.”

    What could I have done wrong?

  7. Chad says:

    I’ve successfully setup the RadioShark on a Debian system (had to compile libhid from source). To listen since it’s a remote server I use DarkIce and IceCast per the instructions here:

    http://javier.rodriguez.org.mx/index.php/2006/06/10/griffin-radio-shark-icecast2-on-debian-gnulinux/

    You can TUNE-IN here http://www.phlat.com/radio.php

  8. Pete says:

    Has anyone had any recent success? I’ve used shark2.c to change the stations, but I get sample format errors now with Fedora 10. Not sure what’s the issue though. The only interesting part is that it’s an old Mac mini PPC. Not sure if that should matter, sound works, but maybe. I’m gonna try it on my x86 fedora box next.

Leave a Reply