1 (edited by wrybread 2008-04-03 11:40:54)

Topic: My new jukebox-like interface for internet radio stations....

I made a little jukebox style interface to play internet radio streams on the Chumby, you can see it and download it (with source code) here:

http://gizmoware.net/chumby (scroll down to Chumby Jukebox)

Since internet widgets can't access the internet from the Chumby it has to be run locally, i.e. from a USB key. There's instructions for doing that on that page.

Some features:

- one touch play, making it much easier to play stations than with the pre-loaded internet radio tuners

- currently has about 40 of the best college and/or community radio stations that I know of, and all high bandwidth (usually > 128k)

- one touch to play a random station

- the stations with stars are my favorite ones, but these are college stations so of course everything completely changes hour by hour....

- soooo close to having the accellerometer control volume. If you look at the traces, it knows when its tilting backwards and forward, if I knew the code to set volume it could be the coolest beanbag on the planet.

- coolio jukebox background



To do:

- possible to control volume of the Chumby from ActionScript?

- possible to receive input from the button on top of the Chumby? Since the control panel isn't running, that button currently does nothing, would be nice to assign it to play random station or use it to calibrate the accellerometer...

- load the stations in from an external xml file

- let people add stations to their favorites page.... A little "add to favorite" icon while a station is playing.

- make the gui purdier... The source code is posted if any designey people want to take a crack at it?

Re: My new jukebox-like interface for internet radio stations....

I seem to have missed Duane on this one.

Duane - sorry to post the question directly at you, but you're probably the only one who can answer it: is there some ASNative call to control volume from a local flash widget? Or some other way to control volume from a local flash widget?

And while I'm here, any way to detect presses of the top button from Flash? The control panel isn't running so the button doesn't nothing, and pressing it causes a trace in SSH, so maybe this is usable by scripts?

Re: My new jukebox-like interface for internet radio stations....

In the current firmware release, there's no ASnative call, however, we're adding one for a future release.

In the meantime, your can use the "exec://" protocol to run a local executable, in this case, "chumby_set_volume".

x = new XML();
x.load("exec://chumby_set_volume "+volume);

The "exec://" protocol handler is only available to the "master" Flash player instance, normally the Control Panel, however, your movie will also be able to call it if launched directly.

The ASnative for the top button is documented here.  The driver for the switch is /dev/switch, from which you read bytes that have the value of 0 or 1 to reflect the state of the switch.

Re: My new jukebox-like interface for internet radio stations....

Awesome!

Thanks, that exec interface is great.

Re: My new jukebox-like interface for internet radio stations....

Stylin, the volume on my jukebox is now fully controlled with the accelerometer:

- tilt it forward (towards you) to turn volume down

- tilt it backwards (away from you) to turn volume up

- slap it to toggle mute

It takes the state of the Y & Z coordinates at startup as the acceleratometer calibration, but note that button on the last page (currently page 5) to recalibrate it.

Re: My new jukebox-like interface for internet radio stations....

Wrybread:

From a human factors perspective, you might consider reversing the tilt/volume relationship. If you want less of something, you'd normally push that something away from yourself; if you want more, you'd pull the something toward yourself. So it might be easier to remember if you had the volume go down with a tilt to the back (away from yourself), and go up with a tilt toward yourself.

Just a thought. Nice work in any event.

Re: My new jukebox-like interface for internet radio stations....

Have you tried it? I see it as "turning the face upwards" to turn the volume up. I just experimented with reversing it and it was confusing, but htat might just be because I'm now used to the other way.

I'm planning on having a configuration page, and I guess one of the options can be to set which way to push it to raise volume.

Currently working on an issue where BTPlay becomes unresponsive after running overnight. Tricky to troubleshoot since it takes so long for the problem to occur. These are the traces when it you try to play a station if its crashed, if anything jumps out at anyone:

2008-04-04 10:07:24 TRACE: play kdvs

2008-04-04 10:07:24 NetStreamRequest::Open(7): Opening protocol 'http://' host 'gizmoradio.org' port 80 location '/chumby/kdvs'
2008-04-04 10:07:24 NetStreamRequest::Open(7) opened http object id 7
2008-04-04 10:07:24 ClientObject::HeartBeat(20762093) elapsed 15.092s prev high 15.085s
2008-04-04 10:07:25 HTTPCurlObject::SetFinalLocation(id=7, http://radiogizmo.org/query.php?station=KDVS) reassembled as http://radiogizmo.org:80/query.php?station=KDVS
2008-04-04 10:07:25 HTTPCurlObject::SetFinalLocation(id=7, http://kdvs.org:8000/kdvs192.mp3) reassembled as http://kdvs.org:8000/kdvs192.mp3
2008-04-04 10:07:25 HTTPCurlObject::ReceiveHeader(id=7) flagging length 0 as suspect because Location is changing
2008-04-04 10:07:26 HTTPCurlObject::ReceiveData(id=7) after redirect - removed 2 duplicate Content-Type values
2008-04-04 10:07:26 HTTPCurlObject::ReceiveData(id=7) removed content length 0 (header length 893) from redirected fetch (OK)
2008-04-04 10:07:26 NetStreamRequest::ProcessHeaders(7) content-type: audio/mpeg
2008-04-04 10:07:26 HTTPCurlObject::PassFinalLocationToFlash(http://kdvs.org:8000/kdvs192.mp3) stream id=7
2008-04-04 10:07:39 ClientObject::HeartBeat(20777160) elapsed 15.067s prev high 15.092s

For comparison, here's what it looks like when everything's working:

2008-04-04 10:18:56 TRACE: play kdvs

2008-04-04 10:18:56 BtPlayObject::Pump(cycle 29) got response OK playnow 7
2008-04-04 10:18:56 BtPlayObject::Pump(cycle 29) got 1 responses, executed 0 deferred actions
2008-04-04 10:18:59 BtPlayObject::Pump(cycle 56) got 0 responses, executed 1 deferred actions
2008-04-04 10:19:10 ClientObject::HeartBeat(334341) elapsed 15.032s prev high 15.084s

It won't play streams after the above happens, even if I manually restart btplay and btplay-daemon.

I'm pretty sure the RAM isn't full, but I'll post the output of "top" next time it crashes.

One thing I'm wondering: I'm polling the accelerometer every 350ms, I wonder if that's too often? Is polling the usual way to do this?

Re: My new jukebox-like interface for internet radio stations....

One thing you also may want to add is a way to turn on/off mute mode on the chumby from your app.. First time i ran it, i inadvertently had the chumby muted in the control panel.. and of course nothing would play wink

Re: My new jukebox-like interface for internet radio stations....

You mean have it set volume to some number (75?) at startup? Good idea.

I wonder if there's a way for ActionScript to get current volume level of the Chumby?

I'm also finding the impact is a bit too sensitive, so I'm muting it when when I don't mean too. I made it so the screen background goes red when its muted so at least its obvious, but still. I'm using the impactTime property from the accelleromer, which records when there was an impact. So if impacttime changes, I toggle mute. I'm wondering if there's some way to set the impact threshhold to make it less sensitive?

Here's some fairly good documentation on the accelerometer for anyone who needs it by the way:

http://www.adobe.com/devnet/devices/art … nt_06.html

Here's how I'm reading from it:

function calculateMovement() {
    
    currentX = getAccelerometer(2);
    currentY = getAccelerometer(3);
    currentZ = getAccelerometer(4);
    //avgX = getAccelerometer(5);
    //avgY = getAccelerometer(6);
    //avgZ = getAccelerometer(7);
    //impactX = getAccelerometer(8);
    //impactY = getAccelerometer(9);
    //impactZ = getAccelerometer(10);
    impactTime = getAccelerometer(11);
    
    // Set calibration values, i.e. untilted X, Y, and Z
    if (x_calibrated == undefined) x_calibrated = currentX;
    if (y_calibrated == undefined) y_calibrated = currentY;
    if (z_calibrated == undefined) z_calibrated = currentZ;
    if (last_impactTime == undefined) last_impactTime = impactTime;
    
        // Check for motion
    if ( (currentY - y_calibrated) > 200 ) set_volume("up"); 
    else if ( (y_calibrated - currentY) > 200 ) set_volume("down"); 
    
    if ( (last_impactTime - impactTime) > 50) {
        trace("bashed!---------------------------------------");
        toggleMute();
        last_impactTime = impactTime;
    }

    else if ( (impactTime - last_impactTime) > 50) {
        trace("bashed!---------------------------------------");
        toggleMute();
        last_impactTime = impactTime;
    }
    
    //trace("Accellerometer data: " + currentX + ", " + currentY + ", " + currentZ + ", " + avgX + ", " + avgY + ", " + avgZ + ", " + impactX + ", " + impactY + ", " + impactZ + ", " + impactTime);
    
}


// Will check accelerometer every 350ms
read_interval = setInterval(calculateMovement, 350);

Re: My new jukebox-like interface for internet radio stations....

wrybread wrote:

I wonder if there's a way for ActionScript to get current volume level of the Chumby?

chumby_set_volume returns the current volume level.  Without a parameter, the volume is left unchanged.

Re: My new jukebox-like interface for internet radio stations....

How would I read that into my flash? In other words, how would actionscript know the current volume?

Re: My new jukebox-like interface for internet radio stations....

x = new XML();
x.onData = function(data) {
   trace(data);
}
x.load('exec://chumby_set_volume');

Re: My new jukebox-like interface for internet radio stations....

Fantastic, thanks.

One more question while you're reading this: is there a way for ActionScript to get the status of the button on top of the Chumby? I see it causes a trace in SSH...

And of course I'm talking about widgets running outside the control panel.

Re: My new jukebox-like interface for internet radio stations....

I thought I answered that question in the other thread about setting the volume, but if not, the doc on this sensor is here

Re: My new jukebox-like interface for internet radio stations....

Oh man that page is spectacular, wish I'd found it sooner.

Thanks.

16 (edited by wrybread 2008-04-04 16:34:15)

Re: My new jukebox-like interface for internet radio stations....

The "_setSpeakerMute = ASnative(5,18);" function is behaving in a way I didn't expect: apparently triggering it only cuts off the sound momentarily, like for a quarter of a second? Is that correct?

In the current build of my Jukebox I assigned top button presses to mute (_setSpaekerMute), but its so momentary that I'm having to poll the top button every 50ms, and even that doesn't result in reliable silence while its pressed.

Is there some example for using the setSpeakerMute interface? Or some tips on using it?

And is polling the top button the best way to do this, or is there some other way to fire an event when its pressed?

Thanks for you help.

Re: My new jukebox-like interface for internet radio stations....

Correct - you're fighting with a system daemon running outside of Flash that's responsible for detecting the presence of something plugged into the headphone jack and automatically muting the internal speakers.  To make full use of that ASnative, you'd have to kill the "headphone_mgr". process.

If your intent is to put a "mute" button on your UI, what you want to do is call "chumby_set_mute" (in the same manner you called "chumby_set_volume") - this mutes both the speakers and the headphones, and is what the "mute" button in the Control Panel does.