Archive for the ‘Making Things’ Category

Flashbelt 2008 + Animation to Go + HydroTween + Papervision3D

Getting ready to leave for MN and I’m very excited to be a part of Moses’ presentation at Flashbelt 2008! I will be providing a brief introduction to HydroTween. HydroTween is a multi-purpose tweening parser that runs on top of the Go framework. If you are familiar with ZigoEngine, Fuse, or Tweener, then using HydroTween should be a seamless transition. In this post, you will find the examples shown during the presentation. I’ve also put together an online version of what I will be showing. I was hoping to also include a demonstration of the Making Things controller running a tween on a servo, but my laptop isn’t being cooperative. I will provide a separate post with an update on that as well as a library I am working on for controlling modules.

Back to the subject at hand, here are the 3 examples that I will be showing. The first is an example of generic tweening with most of the basic properties, filters, and image/hsb tweening. The second is a Fuse type example using navigation with multiple tweening properties running at once. The last is a Papervision3D example that is tweening a number of properties including brightness. Thanks to Andy Zupko’s heroic efforts of merging the GreatWhite and Effects branches of Papervision together, we have alpha and the other none-positioning properties at our tweening disposal for 3D objects!

Here is the link to the presentation along with the examples. - Click into the SWF, then use the forward and back arrows to navigate.

I also urge you to check out my previous post that has useful information and source examples, along with changes and important features that have been added. HydroTween will call you renderer for automatic updating of your Papervision scene by registering with HydroTween using the init3D() method. One important new addition is the ability to pass a DisplayObject3D target into this init method for automatic use of the lookAt() method.

Here is the link to the previous post with more information about using HydroTween.

If you’d like to go directly to the examples:
Generic HydroTween
Fuse Style Tweening
Papervision3D - Clicking on an image will bring it up.

Looking forward to seeing everyone there!

And of course, the source! I have included everything in the examples, including the presentation!


Flashbelt2008 HydroTween Source and Examples

Sunday, June 8th, 2008

Making Things + AS3 - Part 4 Serial LCD

Serial LCD

UPDATE - it seems that the classes I have been using are out of date!
Making things has released a library that works with the mchelper application which I actually haven’t been able to get working with this example. Also Adam Robertson has developed a library that works with flex. I tried porting this library to this example but had no luck. And finally, Ignacio/Nacho, from John Barton’s earlier posts has developed a library as well as updates to the Flosc application which I am in the process of testing.

While I haven’t gotten any of the examples working with the LCD, each of them is excellent in its approach and I’m trying to round up John, Liam, Adam, Ignacio, and myself and see if we can make this a collaborative effort. Things have slowed down a bit with work and the Flash Forward convention, but stay tuned for more updates. In the meantime, the included code I have does work if you want to tinker and get a feel for what’s going on with the controller.

Anyone else who is interested, give me a shout!


Be sure to read parts 1-3. Still haven’t tackled the getting data from the board issue yet. I wound up having a lot of fun getting this experiment working and got sidetracked. So this is an example and how-to on getting the making things controller to send serial data to an LCD screen. There’s a weather RSS example out there that doesn’t use flash. This is a scaled down version of that as I haven’t had a chance to get the board working via an internet connection. So what we have here is a simple text input swf that will send the text to the LCD. So let’s get this thing hooked up first. Obviously you will need an LCD screen with serial capability. I purchased mine from SparkFun here. Try not to let the GPS modules distract you ;)

Here’s a diagram of the connections for the controller:

Make Controller Serial LCD Diagram Flash AS3

You might be wondering where that green wire is going. Well if you look really close, you’ll see a set of punched out solder points. This is the serial/RS232 interface connection area. There are points for 3.3v, TX, RX, and some others as well. The TX is the one we need for transmitting the serial data. Grnd to Grnd, 5V to VO, and TX on the board to RX on the LCD. Make sure the power jumper for the digital bank is set to 5V (It’s not in the diagram). Go here for more on that. There is a sub-mini pot on the back of the LCD for adjusting contrast.

package com.hydrotik.make {
       
        import flash.display.Shape;
        import flash.display.Sprite;
        import flash.events.MouseEvent;
        import flash.utils.Timer;
        import flash.events.Event;
        import flash.events.TimerEvent;
        import flash.net.URLRequest;
        import flash.media.Sound;
        import flash.media.SoundChannel;
       
        import flash.text.*;
       
       
       
        import org.fwiidom.osc.*;
       
        public class MakeSerialLCD extends Sprite {
               
                private static const STR_LOCAL_IP:String = “169.254.73.165″;
               
                private static const STR_REMOTE_IP:String = “192.168.0.200″;
               
                private static const NUM_PORT:Number = 10000;
               
                private var oscConn:OSCConnection;
               
                private var tf:TextField;
               
                public function MakeSerialLCD() {
                        //Initialize connection to the FLOSC server
                        oscConn = new OSCConnection(STR_LOCAL_IP, NUM_PORT);
                        oscConn.addEventListener(OSCConnectionEvent.ON_CONNECT, onConnect);
                        oscConn.addEventListener(OSCConnectionEvent.ON_CONNECT_ERROR, onConnectError);
                        oscConn.addEventListener(OSCConnectionEvent.ON_PACKET_IN, onPacketIn);
                        oscConn.addEventListener(OSCConnectionEvent.ON_PACKET_OUT, onPacketOut);
                        oscConn.addEventListener(OSCConnectionEvent.ON_CLOSE, onClose);
                        oscConn.connect();
                }
               
                private function onConnect(evtEvent:OSCConnectionEvent):void {
                        trace(“FLOSC Connection established”);
                       
                        oscConn.sendOSCPacket(new OSCPacket(“/serial/baud”, [9600], STR_REMOTE_IP, NUM_PORT));
                       
                        var button1:Sprite = new Sprite();
                        button1.graphics.beginFill(0xCC6666);
                        button1.graphics.drawRect(20, 10, 40, 20);
                        button1.buttonMode = true;
                        button1.addEventListener(MouseEvent.CLICK, onClick1Handler);
                        addChild(button1);
                       
                        tf = new TextField();
                        tf.background = true;
                        tf.border = true;
                        tf.backgroundColor = 0×00FF66;
                        tf.maxChars = 32;
                        tf.multiline = true;
                        tf.width = 120;
                        tf.height = 32;
                        tf.wordWrap = true;
                        tf.x = 80;
                        tf.y = 10;
                        tf.type = TextFieldType.INPUT;
                        tf.restrict = “A-Z 0-9!.\”\’?”;
                        tf.tabEnabled = true;
                        tf.tabIndex = 0;
                       
                        addChild(tf);
                }
       
                private function onConnectError(evtEvent:OSCConnectionEvent):void {
                        trace(“FLOSC Connection error”);
                }
               
                private function onClose(evtEvent:OSCConnectionEvent):void {
                        trace(“FLOSC Connection closed”);
                }
               
               
                private function onPacketIn(evtOSC:OSCConnectionEvent):void {
                        trace(\t>> data received: “ + evtOSC.data.name + ” “ + evtOSC.data.data);     
                }
               
                private function onPacketOut(evtOSC:OSCConnectionEvent):void {
                        trace(\t>> data sent: “ + evtOSC.data.name + ” “ + evtOSC.data.data)
                }
       
                private function onClick1Handler(event:MouseEvent):void {
                        parseString(tf.text);
                        tf.text = “”;
                }
               
               
                private function parseString(str:String):void {
                        //Initialize LCD
                        oscConn.sendOSCPacket(
                                new OSCPacket(“/serial/char”, [254], STR_REMOTE_IP, NUM_PORT)
                        );
                        //Clears LCD
                        oscConn.sendOSCPacket(
                                new OSCPacket(“/serial/char”, [1], STR_REMOTE_IP, NUM_PORT)
                        );
                        //Loop and send ascii dec
                        for(var i:int = 0; i<str.length ; i++){
                                oscConn.sendOSCPacket(
                                        new OSCPacket(“/serial/char”, [str.charCodeAt(i)], STR_REMOTE_IP, NUM_PORT)
                                );
                        }
                }
               
        }
       
}

The code is pretty straight forward. It’s not doing anything too exciting other then sending the data. I have one OSC command sending a baud rates and a couple other OSC commands that clear the existing text on the screen and prepare it for a fresh batch of characters. Other things you’ll notice is that I have a restriction of chars attached to the input field. You can play with this and add lowercase if you like.

Below I’ve included the changes I made to the OSC class:

package org.fwiidom.osc {
        /**
         * @author adam
         *(based originally on demo code included with Flosc)
         *
         * (c) 2007 Fwiidom.org
         */

        
        import flash.events.DataEvent;
        import flash.events.Event;
        import flash.events.EventDispatcher;
        import flash.net.XMLSocket;
        import flash.xml.XMLDocument;
        import flash.xml.XMLNode;
       
        public class OSCConnection extends EventDispatcher {       
               
                protected var mSocket:XMLSocket;
                protected var mPort:Number;
                protected var mIp:String;
               
                protected var mDefaultSendPort:Number  = 10000;
                protected var mDefaultSendIp:String = “192.168.5.210″;
               
                protected var mConnected:Boolean;
               
                public function OSCConnection(inIp:String, inPort:Number) {
                        super();
                        mIp = inIp;
                        mPort = inPort;   
                }
               
                public function connect () : void {
                        trace(“OSCConnection.connect()”);
                        mSocket = new XMLSocket();
                        mSocket.addEventListener(Event.CONNECT,onConnect);
                        mSocket.addEventListener(Event.CLOSE,onClose);
                        mSocket.addEventListener(DataEvent.DATA,onXml);
               
                        mSocket.connect(mIp,mPort);
               
                        //if (!mSocket.connect(mIp,mPort)) onConnectError();
                }
               
                public function disconnect () : void {
                        mSocket.close();
                        mConnected = false;
                }
               
               
                // *** event handler for incoming XMLDocument-encoded OSC packets
                protected function onXml (e:DataEvent) : void {
                        var inXml:XMLDocument = new XMLDocument(e.data);
                        trace(“OSCConnection.onXml—”+inXml);
                        // parse out the packet information
                        var n:XMLNode = inXml.firstChild;
                        if (n != null && n.nodeName == “OSCPACKET”) {
                                parseXml(n);
                        }       
                }
       
       
                // *** event handler to respond to successful connection attempt
                protected function onConnect (succeeded:Boolean) : void {
                        trace(“OSCConnection.onConnect(succeeded)”);
                        if(succeeded) {
                                trace (“success”);
                                mConnected = true;
                                dispatchEvent(new OSCConnectionEvent(OSCConnectionEvent.ON_CONNECT,null));
                        } else {
                                trace (“fail”);
                                onConnectError();
                        }              
                }
       
       
                // *** event handler called when server kills the connection
                protected function onClose (e:Event) : void {
                        trace(“OSCConnection.onClose()”);
                        mConnected = false;
                        dispatchEvent(new OSCConnectionEvent(OSCConnectionEvent.ON_CLOSE));
                }
       
       
                protected function onConnectError() : void {
                        trace(“OSCConnection.onConnectError()”);
                        mConnected = false;          
                        dispatchEvent(new OSCConnectionEvent(OSCConnectionEvent.ON_CONNECT_ERROR));
                }
               
                // *** parse the messages from some XMLDocument-encoded OSC packet     
                protected function parseXml(node:XMLNode) : void {
                        trace(“/——————- OSCConnection.parseXml(node) “);
                        trace (node);
                        trace(“——————- /”);
                        if (node.firstChild.nodeName == “MESSAGE”) {
                                var message:XMLNode = node.firstChild;
                                                       
                                var name:String = message.attributes.NAME;                 
                                var data:Array = [];
                                for (var child:XMLNode = message.firstChild; child != null; child=child.nextSibling) {
                                        if (child.nodeName == “ARGUMENT”) {
                                                var type:String = child.attributes.TYPE;
                                                //boolean
                                                if (type==“T” || type==“F”) {
                                                        data.push((type==“T”)?true:false);     
                                                } else if (type==“f”) {
                                                        //float
                                                        data.push(parseFloat(child.attributes.VALUE));
//////————————————————————————///////////////////////////////////////////////////
//////  Added new type "i", as "f" is not a type in the Make Controller
//////————————————————————————///////////////////////////////////////////////////
                                                } else if (type==“i” || type==“I”) {
                                                        //float
                                                        data.push(parseInt(child.attributes.VALUE));
                                                } else
                                                //string
                                                if (type==“s”) {
                                                        data.push(child.attributes.VALUE);
                                                }       
                                        }
                                }
       
                                var packet:OSCPacket = new OSCPacket(name, data, node.attributes.address, node.attributes.port);
                                packet.time = node.attributes.time;    
                                dispatchEvent(new OSCConnectionEvent(OSCConnectionEvent.ON_PACKET_IN,packet));         
                        }
                        else {
                                // look recursively for a message node
                                for (var subchild:XMLNode = node.firstChild; subchild != null; subchild=subchild.nextSibling) {
                                        parseXml(subchild);
                                }
                        }
                }
       
       
       
                // *** build and send XMLDocument-encoded OSC
               
                public function sendOSCPacket(outPacket:OSCPacket) : void {
                        var xmlOut:XMLDocument = new XMLDocument();
                               
                        var osc:XMLNode = xmlOut.createElement(“OSCPACKET”);
                        osc.attributes.TIME = 0;
                        osc.attributes.PORT = outPacket.port;
                        osc.attributes.ADDRESS = outPacket.address;
               
                        var message:XMLNode = xmlOut.createElement(“MESSAGE”);
                        message.attributes.NAME = outPacket.name;
               
                        for (var i:Number=0;i<outPacket.data.length; i++) {
                                // send everything as a string
                                // NOTE : the server expects all strings to be encoded
                                // with the escape function.
                                var argument:XMLNode = xmlOut.createElement(“ARGUMENT”);                       
                                setType(argument, “i”); //argument.attributes.TYPE = "s";
                                setValue(argument, escape(outPacket.data[i])); //argument.attributes.VALUE = escape(outPacket.data[i]);
                                message.appendChild(argument);
                        }
                                               
                        osc.appendChild(message);
                        xmlOut.appendChild(osc);
                       
                       
               
                        if (mSocket && mConnected) {
                                //trace ("XMLDocument SEND - ");
                                trace (xmlOut);
                                mSocket.send(xmlOut);
                                dispatchEvent(new OSCConnectionEvent(OSCConnectionEvent.ON_PACKET_OUT,outPacket));
                        }
                }
               

                private function setType(arg:XMLNode, str:String):void{
                        arg.attributes.TYPE = str;
                }
               
                private function setValue(arg:XMLNode, str:String):void{
                        arg.attributes.VALUE = str;
                }
               
        }
}


Making Things Serial LCD Source

Tuesday, September 4th, 2007

Making Things + AS3 - Part 3 Servo Mouse Tracking

Be sure to go to my previous post here so you are up to speed.

For this example we will simply get the servo connected to the board and have it read the mouse position of the screen. When you move your mouse to the left, the servo will turn accordingly and vice versus.

At this point it would also me good for me to point that the way in which we are sending data to flosc might not be ideal. I noticed in the making things AS3 example and source that’s to be used specifically with mchelper, they have a communication method for bundling data together. Not sure if this is workable with flosc. While I’m on the topic, I’d also suggest you check that code out. You can find their AS3 examples and library here. I plan on experimenting with the mchelper method of using AS3 and the board shortly.

package com.hydrotik.make {
       
        import flash.display.Shape;
        import flash.display.Sprite;
        import flash.events.MouseEvent;
        import flash.utils.Timer;
        import flash.events.Event;
        import flash.events.TimerEvent;
        import flash.net.URLRequest;
        import flash.media.Sound;
        import flash.media.SoundChannel;
        import org.fwiidom.osc.*;
       
        public class MakeServo extends Sprite {
               
                private static const STR_LOCAL_IP:String = “169.254.73.165″;
               
                private static const STR_REMOTE_IP:String = “192.168.0.200″;
               
                private static const NUM_PORT:Number = 10000;
               
                private var oscConn:OSCConnection;
               
                public function MakeServo() {
                        //Initialize connection to the FLOSC server
                        oscConn = new OSCConnection(STR_LOCAL_IP, NUM_PORT);
                        oscConn.addEventListener(OSCConnectionEvent.ON_CONNECT, onConnect);
                        oscConn.addEventListener(OSCConnectionEvent.ON_CONNECT_ERROR, onConnectError);
                        oscConn.addEventListener(OSCConnectionEvent.ON_PACKET_IN, onPacketIn);
                        oscConn.addEventListener(OSCConnectionEvent.ON_PACKET_OUT, onPacketOut);
                        oscConn.addEventListener(OSCConnectionEvent.ON_CLOSE, onClose);
                        oscConn.connect();
                }
               
                private function onConnect(evtEvent:OSCConnectionEvent):void {
                        trace(“FLOSC Connection established”);
                        this.addEventListener(Event.ENTER_FRAME, trackServo);
                }
       
                private function onConnectError(evtEvent:OSCConnectionEvent):void {
                        trace(“FLOSC Connection error”);
                }
               
                private function onClose(evtEvent:OSCConnectionEvent):void {
                        trace(“FLOSC Connection closed”);
                }
               
               
                private function onPacketIn(evtOSC:OSCConnectionEvent):void {
                        trace(\t>> data received: “ + evtOSC.data.name + ” “ + evtOSC.data.data);     
                }
               
                private function onPacketOut(evtOSC:OSCConnectionEvent):void {
                        trace(\t>> data sent: “ + evtOSC.data.name + ” “ + evtOSC.data.data)
                }
               
                private function trackServo(event:Event) {
                        var pos:int = (this.mouseX/200) * 1023;
                        trace(pos);
                        oscConn.sendOSCPacket(
                                new OSCPacket(“/servo/0/position”, [pos], STR_REMOTE_IP, NUM_PORT)
                        );
                }
               
               
        }
       
}

Making Things Servo Source

Tuesday, September 4th, 2007

Making Things + AS3 - Part 1 and 2 LED Sound Visualizer

In the obnoxious spirit of having a ton of “Part 1″ posts going on here, I decided to put up this initial experiment with my new making things controller. There’s a lot to cover as this has become one of the more challenging things I have been tinkering with lately. Before going any further let me give you a brief introduction to what this is. If you are familiar with Making Things and flosc then skip to the next paragraph. The fine folks at Making Things have made a hardware controller kit that is capable of interfacing with the Flash environment. Basically what this means is that you can interact with a swf electronically and mechanically using this hardware interface. Things like stepper and servo motors, proximity sensors, and other electronic devices can be controlled and monitored through flash. Flash is able to do this by way of a java server application that is run in the background called flosc. It’s based on the system of OSC that is typically used to interface MIDI applications and hardware. You can learn about OSC here and you can read more about flosc here.

Also before going any further I highly recommend you read through John Barton’s progress before proceeding with this post as he has provided the insight and basis for this experiment and has gone through a few more trials and tribulations over this then myself. Check out his blog here. Make sure you go through all his posts first as there is a progression and you will have a good sense of where things stand.

That being said, AS3 integration of the controller seems to be a relatively new thing. I know John, as you saw in his posts, hit some snags with the communication of data and flosc. I know I came across issues on my own trying to get his examples working but hopefully this will be one more resource to help get something going. Just so you know, the code used to communicate with flosc is in “beta” version if you will. John mentioned planning on updating the code per the recent developments he encountered in his latest post. Since he’s a busy man like the rest of us, I tried making a couple modifications myself in the meantime. Ideally it would be great to do a re-write using the Binary Socket class in AS3.

I have included what seems to be the most recent version of flosc in the source files. I reccomend you check on the version and with John’s progress as well. Be patient and prepared for frustration as there are a lot of elements in this scenario that can create issues and make things NOT work.

Before starting up flosc you will need to disable your internet settings. I hope to have an example of the controller working within a network even a utility class that can configure the controller in a network using DHCP, but for the time being… Go to your system preferences. Make sure both the ethernet and the usb connection are plugged into the computer (I have the external power supply connected to mine). You might get a message saying that the Network has detected the Making Things etc.. click ok and enable that along with your ethernet port. That message simply indicates that the computer can connect to the board via the USB cable. Because the board only communicates via ethernet, the USB is only important for powering the board and using mchelper.

At this point you could fire up the mchelper application that I included with the source. Be sure to check the version of this on the making things site. Test if the board is connected by clicking on the Ethernet tab and in the command line type in “/appled/0/state 1″ and click send. Hopfully your number 0 LED will light up! Make sure you quit the mchelper program as it will block connections made using flosc.

Next we need to start up the flosc server application. First, make note of your computers IP address as you will need it in the class source. To start flosc using a mac:
Open up the terminal. Type “cd ” (be sure to include the space after cd)
Then drag the flosc folder into the terminal window. This will paste the path into the terminal window.
Hit return and you should be in the flosc directory.
Type “java Gateway 10000 10000″ and you should see “OscServer created…” and “TcpServer created…”
This will tell you that the flosc server is running. Gateway is the java program in the flosc directory and the 10000 numbers designate the incoming and outgoing ports respectively that flosc and the board talk to each other on.

Next open up the MakeLEDTest.fla and the MakeMusicLED.as file. In the class file you will see const variables for the computer and controller IP address you should really only need to add the computers IP address. Publish the file and hopefully you will see a successful connection in the output/debugger window. If you do, click on the green button and the music should be playing along with the LEDs on the controller and the visual representation in the swf. If they don’t, don’t fret. It took me quite a while to get things working. I noticed things as silly as adding a private class variable to the as file would prevent the LED’s from working. Retrace your steps and check the data flow. Make sure the IP addresses match up.


Before getting to the LED code, be aware that I have made a couple minor changes to the OSCConnection.as file that John did. I added two private methods to reorder the OSC attributes in the XML data in regards to Johns discoveries. I also changed the type to “i” instead of “s” and things worked well. I’m sure this is a band-aid fix for the time being.

So now for the code actual LED code. Here we are going to load a mp3 and have the LED’s on the board reflect the amplitude level of the music. Check out Lee Brimelow’s example here for a refresher on getting the amplitude value of a sound channel. The only change I made is averaging the two channels since we have one set of LED’s on the board.

Here’s the code:

package com.hydrotik.make {
       
        import flash.display.Shape;
        import flash.display.Sprite;
        import flash.events.MouseEvent;
        import flash.utils.Timer;
        import flash.events.Event;
        import flash.events.TimerEvent;
        import flash.net.URLRequest;
        import flash.media.Sound;
        import flash.media.SoundChannel;
        import org.fwiidom.osc.*;
       
        public class MakeMusicLED extends Sprite {
               
                private static const STR_LOCAL_IP:String = “169.254.73.165″;
               
                private static const STR_REMOTE_IP:String = “192.168.0.200″;
               
                private static const NUM_PORT:Number = 10000;
               
                private static const LOOP:String = “jens_buchert.mp3″;
               
                private var oscConn:OSCConnection;
               
                private var ledArray:Array;
               
                private var _ledShapeArray:Array;
               
                private var sc:SoundChannel;
               
                private var s:Sound;
               
                public function MakeMusicLED() {
                        //Initialize connection to the FLOSC server
                        ledArray = [];
                        oscConn = new OSCConnection(STR_LOCAL_IP, NUM_PORT);
                        oscConn.addEventListener(OSCConnectionEvent.ON_CONNECT, onConnect);
                        oscConn.addEventListener(OSCConnectionEvent.ON_CONNECT_ERROR, onConnectError);
                        oscConn.addEventListener(OSCConnectionEvent.ON_PACKET_IN, onPacketIn);
                        oscConn.addEventListener(OSCConnectionEvent.ON_PACKET_OUT, onPacketOut);
                        oscConn.addEventListener(OSCConnectionEvent.ON_CLOSE, onClose);
                        oscConn.connect();
                }
               
                private function onConnect(evtEvent:OSCConnectionEvent):void {
                        trace(“FLOSC Connection established”);
                        var button:Sprite = new Sprite();
                        button.graphics.beginFill(0×66CC66);
                        button.graphics.drawRect(20, 50, 40, 20);
                        button.buttonMode = true;
                        button.addEventListener(MouseEvent.CLICK, onClickHandler);
                        addChild(button);
                       
                        s = new Sound();
                        s.load(new URLRequest(LOOP));
                       
                        _ledShapeArray = [];
                        var startX:int = 20;
                       
                        for(var i:int = 0; i<4; i++){
                                _ledShapeArray[i] = new Shape();
                                _ledShapeArray[i].graphics.beginFill(0×00FF00);
                                _ledShapeArray[i].graphics.drawRect(0, 0, 8, 3);
                                _ledShapeArray[i].x = startX;
                                _ledShapeArray[i].y = 20;
                                _ledShapeArray[i].alpha = .1;
                                addChild(_ledShapeArray[i]);
                                startX = startX + 10;
                        }
                       
                }
       
                private function onConnectError(evtEvent:OSCConnectionEvent):void {
                        trace(“FLOSC Connection error”);
                }
               
                private function onClose(evtEvent:OSCConnectionEvent):void {
                        trace(“FLOSC Connection closed”);
                }
               
               
                private function onPacketIn(evtOSC:OSCConnectionEvent):void {
                        trace(\t>> data received: “ + evtOSC.data.name + ” “ + evtOSC.data.data);     
                }
               
                private function onPacketOut(evtOSC:OSCConnectionEvent):void {
                        trace(\t>> data sent: “ + evtOSC.data.name + ” “ + evtOSC.data.data)
                }
       
                private function onClickHandler(event:MouseEvent):void {
                        this.addEventListener(Event.ENTER_FRAME, showAmplitude);
                        sc = s.play(0, 1000);
                }
               
               
                private function showAmplitude(eventArgs:Event) {
                        var v:Number = 4 * ((sc.leftPeak + sc.rightPeak)/2);
                        for(var i:int = 0; i<4; i++){
                                if(v > i){
                                        _ledShapeArray[i].alpha = 1;
                                        oscConn.sendOSCPacket(
                                                new OSCPacket(“/appled/”+i.toString()+“/state”, [1], STR_REMOTE_IP, NUM_PORT)
                                        );
                                }else{
                                        _ledShapeArray[i].alpha = .1;
                                        oscConn.sendOSCPacket(
                                                new OSCPacket(“/appled/”+i.toString()+“/state”, [0], STR_REMOTE_IP, NUM_PORT)
                                        );
                                }
                        }
                }
               
               
        }
       
}

Jens Buchert
The music is the song “Mélange Eléctrique” from Jens Buchert’s album Spa Lounge. Great downtempo album.


Making Things Music LED Source

Tuesday, September 4th, 2007