Posted by: Robin Leboe | September 12, 2009

Flash Animation and Max/MSP

I’m finally getting around to putting Flash, ActionScript 3.0 and Max/MSP to work creating animation driven, interactive sound.

The Flash animations I’m using are based on Keith Peters examples in his terrific book Foundation Actionscript 3.0 Animation: Making Things Move! I’m also using Olaf Matthes Flashserver external to create a bi-directional socket connection between Flash and Max/MSP.

In this example I’m using a modified version of Keith’s Bouncing2 class as the Flash document class. There are no assets in the library and no frame scripts in the file. Here are the resources being used on the Flash side:

  • Test.fla // empty Flash document
  • Bouncing2.as // bouncing action with gravity, used as document class for the Test.fla file
  • Ball.as // object to bounce
  • FlashserverConnect.as // create socket connection and handle events

Note: The socket connection details are handled by the FlashserverConnect class and Max/MSP external Flashserver as detailed in my previous post.

This is about as basic as it gets but it really does open up a universe of exciting interactive sound and music possibilities.

On the Max/MSP side the patcher features an instance of the Flashserver external and a few widgets to create some visual and auditory feedback. Here are the required resources for Max/MSP:

Run the Max/MSP patcher and test the flash movie or publish it as a projector file (note that exporting the movie and running it in the Flash Player outside the browser generated security warnings).

The bouncing ball will trigger the keyboard object that creates a MIDI note and routes it to the OS. It also sends the values to a series of conditionals that trigger a series of 6 different basketball sounds, each one recorded at a different level.

It’s crude but it’s a start.

Zip archive of the files coming soon.

Posted by: Robin Leboe | August 23, 2008

Flashserver install: OS X (Tiger)

After downloading the latest version of Flashserver and expanding the archive I placed the flashserver.mxo object in the max-startup folder of the Applications/MaxMSP4.6 directory. This is not per the manual, which directs you to place the file in the Application Support folder. I also placed the flashserver.help file in the max-help folder as directed. So far so good!

After loading up a new Max patch I created an Object Box and scrolled through the list to find the Flashserver object type and set the port parameter to 5150 (arbitrary – even crazy! – but above 1024 to avoid collisions with OS ports). I also specified 1 connection out of a possible 256.

Uber basic Max/MSP 4.6 patch for Flash communication

Uber basic Max/MSP 4.6 patch for Flash communication

On the Flash side, I specified the FlashserverConnect class as the Document class and made sure that the port parameter specified in the class was also set to 5150. Here’s the class:

package {

import flash.display.Sprite;
import flash.events.Event;
import flash.events.DataEvent;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.net.XMLSocket;
import flash.events.IEventDispatcher;

// FlashserverConnect must extend Sprite to serve as Document class in CS3
public class FlashserverConnect extends Sprite {

private var host:String = “localhost”;
private var port:uint = 5150; // LAPD code for crazy person (!?)
private var socket:XMLSocket; // Create socket
private var val:String = “Hello from Flash”; // initial value for testing
private var header:String = “val”;
private var maxData:* = header + ” “+ val + “;”

public function FlashserverConnect() {

socket = new XMLSocket();
configureListeners(socket);
socket.connect(host, port);
send(maxData);
}

public function send(data:Object):void {

trace(“sending “+data);
socket.send(data);
}

private function configureListeners(dispatcher:IEventDispatcher):void {

dispatcher.addEventListener(Event.CLOSE, closeHandler, false, 0, true);
dispatcher.addEventListener(Event.CONNECT, connectHandler, false, 0, true);
dispatcher.addEventListener(DataEvent.DATA, dataHandler, false, 0, true);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler, false, 0, true);
dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler, false, 0, true);
}

private function closeHandler(event:Event):void {

trace(event.type + “Handler: Closed”);
}

private function connectHandler(event:Event):void {

trace(event.type + “Handler: Connected”);
}

private function dataHandler(event:DataEvent):void {

trace(“data received” + event);
}

private function ioErrorHandler(event:IOErrorEvent):void {

trace(event.type + “Handler  ” + event.text);
}

private function progressHandler(event:ProgressEvent):void {

trace(“progress…”);
}

}

}

The next step was to test the Flash movie and view the results in Max/MXP’s output panel…

Success! Now we can get down with some serious Max Flash fun.

Posted by: Robin Leboe | March 29, 2008

Free Space

Especially handy for those who work with large audio, video and graphic files, this tip was lurking for a long time before I came across it.

To turn on a label beneath your drive icons that displays the size and available capacity of your hard drives do the following:

1. Select the Show View Options menu item.

Mac view menu

2. Enable Show item info by clicking the check box.

View options

And here is the result:

Mac item options enabled

A quick and easy way to tell if you’ve got enough space for your next project.

Posted by: Robin Leboe | March 28, 2008

Power Sets

A power set is a set that contains all of the possible subsets of a given set and is denoted by P\left(S \right) or {2}^{A} In other words:

{2}^{A}=\{X:X\subseteq A\}

In plain English this reads the collection of X such that X is a subset of A.

As an example, the power set of \{a, b, c\} would be:

{S}_{1}=\oslash {S}_{4}=\{c\} {S}_{7}=\{c, a\}
{S}_{2}=\{a\}  {S}_{5}=\{a, b\} {S}_{8}=\{a, b, c\}
{S}_{3}=\{b\} {S}_{6}=\{b, c\}  
     

From this we find that if the original set has n members then the Power Set will have {2}^{n} members. In the case of the preceding example:

|P\left(S \right)| = {2}^{n} = {2}^{3} = 8

Note that the number of members in a set is often denoted |S| . In the preceding example |P\left(S \right)| can be translated the number of mebers in the power set of S.

Another interesting way to look at the various subsets within a power set is to relate them to binary digits like so:

{S}_{1}=\oslash 000
{S}_{2}=\{c\}  001
{S}_{3}=\{b\} 010
{S}_{4}=\{b, c\} 011
{S}_{5}=\{a\} 100
{S}_{6}=\{a, c\} 101
{S}_{7}=\{a, b\} 110
{S}_{8}=\{a, b, c\} 111
   

Next time we’ll look at sample spaces and events and you won’t want to miss that!

Posted by: Robin Leboe | March 22, 2008

Cardinality

Cardinality refers to the number of elements in a set and is denoted using the notation card \left(X \right), where X is the name of a particular set. If a set has an infinite number of elements, such as the set of natural numbers, we can write card \left(N \right) = \infty.

While counting small sets is trivial, the enumeration of large sets would be unmanageable if a manual counting method was employed. Over the next while we’ll look at methods we can employ to do this more efficiently.

Big sets are a challenge, but infinite sets make things even more complicated. Not that we could really count an infinite set, but there are, in reality, two types of infinite sets to contend with. They are referred to as countably infinite and uncountably infinite. Let’s take a look at these before we move on.

Countably infinite sets are made up of numbers that could theoretically be counted, for example the set of natural numbers or the set of even numbers.

\{0,1,2,3,4,5,6,7\}

\{0,2,4,6,8,10,12,14\}

The sets of integers and rational numbers are also countable according to mathematical proofs that we’ll not get into here.

Uncountably infinite sets are said to be ‘denser’ than their countable counterparts. Their ‘type of infinity’ is larger than that of, for instance, the set of natural numbers. As a matter of fact, the set of real or decimal numbers between any two natural numbers like 1 and 2 is as big as the entire set of natural numbers! The following set is considered uncountably infinite:

\{x\ \epsilon\ R :1\leq x \leq 2 \}

Next time we’ll look at determining the number of subsets present in any given set using the power set.

Posted by: Robin Leboe | March 21, 2008

Celtx rocks!

My wife and I recently finished a script for a short film called Beyond the Fall of Darkness. During the process it became clear that some form of web-based collaboration would be a great help. After Googling around a bit I came across Celtx. It is amazing and it’s free! The software not only allows you to collaborate online to write and format a script, it allows you to gather and post any production related materials for characters, locations, SFX etc.

Best of all? It’s Canadian! [insert anthem here...]

Check it out yourself at www.celtx.com 

Posted by: Robin Leboe | March 21, 2008

Plotting With Keynote

I’ve been reading The Marshall Plan for Novel Writing by Evan Marshall. It’s a great book that helps a guy like me understand what’s going on under the hood of a good read. I’ve been reading quite a bit in the action/suspense/mystery genre and I really appreciate how careful plotting can lead to a heart pounding climax.

One of Evan’s prescribed methods is to use a collection of Section Sheets to block out the plot of a novel and keep things on track. Being a guy who likes to keep things organized I thought there might be a form on the web somewhere. No luck. So I thought “Hey! Why not use Keynote!”

I quickly made up a template for the Action and Reaction sections and now I can step through the plot one screen at a time. Cool.

Posted by: Robin Leboe | March 21, 2008

DVD to Final Cut Pro

This is coming up a lot lately. Clients want material from a previously recorded DVD re-cut or cut together with new footage.
Since I’m using FCP on the Mac, my research first led me to Mac the Ripper.

MtR extracts all of the DVD files into a new directory that mirrors the original DVD directory structure. This gets you part way there but alas, at this point there is no file to be imported or even directly converted i.e. mpeg 2.

The next piece of the puzzle I discovered was ffmpeg, which is another free download – actually a set of downloads.

Here is the basic process for the economy (free) method:

  • Rip to Vob using Mac the Ripper
  • Convert Vob to DV video using ffmpegX (I’ve read to be carefull with audio track numbers so the process works for both audio and video)
  • Convert sound from Vob to DV on a second pass
  • Mate the video and audio in FCP



Let’s see how easy this is…

Posted by: Robin Leboe | March 21, 2008

Get with the program

Since I already have the latest versions of both Flash and Max/MSP, the first stop on the journey to Flash/Max nirvana was to download Olaf Matthes’s FlashServer application from the nullmedium website. The latest version of the software is flashserver 1.1 . There are versions available for both Macs and PCs.

After downloading and extracting the PC version of the application, I consulted the README.pdf file. It contains mostly mundane information: system requirements, licensing information, disclaimer etc.

Next I located and cracked the FlashServer manual. This is a MUST READ for everyone who is new to the software. According to the manual:

“The basic functionality of flashserver is to establish a connection between Macromedia’s Flash – be it a standalone projector or a web Plug-In – to communicate with Max/MSP. The TCP/IP socket connection that gets created allows to exchange data between both programs in either direction over local network or the internet. It thus allows to build interactive web front-ends to
Max/MSP or Max-controlled animations in Flash.”

YES!

The manual gives a good overview of the software, it’s specific functions and it’s general application, but a lot of Max knowledge is presumed and it will be hard (or impossible) to follow if you have little experience with Max/MSP.

I highly recommend doggedly pursuing the Max/MSP overview and tutorial documentation that comes with the software (put on the coffee – and make it STRONG). Investing time here will make everything that follows a whole lot clearer.

Posted by: Robin Leboe | March 21, 2008

Flash meets Max/MSP

Since I’m heading into uncharted territory, I thought it wise to leave a trail of blog entries to chronicle my progress – or lack thereof.
I’ve been using Flash since the MX days and have been a big fan of the “instant gratification” attainable with ActionScript programming. With the release of ActionScript 3.0, I became increasingly interested in the platform, especially after learning about computeSpectrum(), which provides a whole new level of access to audio data in a Flash movie.

I also began wondering about the possibility of interaction between Flash and the visual object oriented audio programming application called Max/MSP. It seemed to me that an interface between the two would a great way to teach interactive audio principles to my students.

After some Googling, I came upon FlashServer and FLOSC (Flash OpenSound Control). I intend to begin with FlashServer and see how far I can get with it.

In journaling this process it is my hope that I can provide useful information to those who follow and spare them some of the pain and hours of wasted time I’m surely about to face as I explore this little known corner of the cyber-world.

Older Posts »

Categories

Follow

Get every new post delivered to your Inbox.