Für den Inhalt dieser Seite ist eine neuere Version von Adobe Flash Player erforderlich.

Adobe Flash Player herunterladen


Sending MIDI with Flash: MIDI Matrix

Yes I had fun.
You might remember the soundMatrix I coded back in the summer. Version 2 is ready! Touchable & with MIDI support. In the first version I used to trigger WAV samples; version 2 now sends MIDI!

There is a online version with samples available, have fun!

http://www.31media.de/soundMatrix/

For all those who want to know HOW to send MIDI via Flash:
You basically send OSC packets to a XML Socket Server. The FLOSC socket server has a output port that transforms the XML/OSC messages back to MIDI. I use a app called “Occam” for the MIDI transformation.

Update: people were asking where they can find “occam”: Occam was coded 1998 by C. Ramakrishnan at the University of California.
If someone needs Occan, contact me – occam is not online any more.

Update 2: Occam works with Snow Leopard! Nice.
Update 3: Occam is online again! Here is the url: www.illposed.com/software/

Here is the code:

package com.thirtyOne.core{

	import flash.display.*;
	import flash.events.*;
	import org.fwiidom.osc.*;
	import caurina.transitions.Tweener;

	public class MIDIGateway {
		private var oscConn:OSCConnection;
		private static const STR_LOCAL_IP:String="ZION.local";
		private static const STR_REMOTE_IP:String="ZION.local";
		private static const NUM_PORT:Number=6666;

		public function init() {
			//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_CLOSE,onClose);
			oscConn.connect();
		}

		private function onConnect(evtEvent:OSCConnectionEvent):void {
			trace("MIDI MODULE CONNECTED.");
		}

		private function onConnectError(evtEvent:OSCConnectionEvent):void {
			trace("ERROR");
		}

		private function onClose(evtEvent:OSCConnectionEvent):void {
			trace("CONNECTION TO SERVER CLOSED.");
		}

		public function sendMIDI(_note:uint,_velocity:uint):void {
			//Send the actual OSC packet
			///osc/midi/out/noteOnchannel (int)key (int)velocity (int)

			oscConn.sendOSCPacket(new OSCPacket("/osc/midi/out/noteOn",[1,_note+"",_velocity+""],STR_REMOTE_IP,57117));
			Tweener.addTween(new Sprite(), {alpha:1, time:.1, onComplete:function():void
				{
					// KILL MIDI NOTE:
				   oscConn.sendOSCPacket(new OSCPacket("/osc/midi/out/noteOff",[1,_note+"",_velocity+""],STR_REMOTE_IP,57117));
			   }});

		}

	}

}

One comment

Leave a comment

You must be logged in to post a comment.