New project – Arduino, Processing, Generative Audio…

I’m still searching for a nice new Actionscript Developer post, which means I’ve currently got more time for developing some of the personal projects I’ve been planning whilst away. One idea I’ve been keen on for a long time is Generative Systems – for art and music.

Generative Art

Generative art refers to art that has been generated, composed, or constructed in an algorithmic manner through the use of systems defined by computer software algorithms, or similar mathematical or mechanical or randomised autonomous processes.

Generative Audio

Generative music is a term popularized by Brian Eno to describe music that is ever-different and changing, and that is created by a system.

My first steps into this domain, was my Maths Flash Generative Art Animation from about 4 years ago. And I recently picked it up again in my Flash Media Server demos – Sonar and WebCamColours.

So this week I’ve been thinking about technologies other than Flash which could be used for some generative projects. At the minute, I’m looking at Processing, Arduino, Max MSP/PureData/VVVV, Kontakt and OpenFrameworks.

As my musical skills are slightly limited, I’ve teamed up with awesome sound engineer, programmer, musician and artist Josh Sadler. We talked over how to make a generative system sound more musically appealing, batted a few ideas round and left it at that. A few hours later he sent me the track below.

In his own words –

I had a go at making that music generator you were talking about. Here’s the result. You pick the scale hit go and there’s a button to change it up a bit, bring instruments in and out as you like, needs refining. This one was just 3 button clicks, I think it’s more musical although I’ve been listening to it for so long now I’m not sure what music is anymore

I was blown away! See what you think –

Musicgen2 by Catfurnace

I’m really looking forwards to seeing where this goes. Should be fun.
More info as it happens.

Flash Midi Server 0.1 released + Sonar source code and audio air apps.

The title says it all really. I’ve updated the project page, but I’ll add the info here too incase you’re reading this through an RSS reader.

Flash Midi Server v0.1

Lawrie Cape 2010
Download from the Google Projects Page.

WHAT IS IT?

Flash Midi Server is method for sending MIDI data out of Flash. Using an Actionscript 3 class and a Processing application, you can create generative,

dynamic, fun audio tools in Flash.

WHY?

Mainly just for fun. Flash Midi Server (FMS) started as an experiment to test communication between Processing and Flash. From there it developed into a

class I played around with a lot – seeing what fun things I could use it for.

As FMS is built in Flash, it allows developers to rapidly prototype audio tools, experiment with new input methods and acess to a huge public code base to

build on top of. There’s a huge amount of technical skill and creativity in the Flash scene and hopefully some of it will be applied to creating innovative

new audio apps using FMS.

HOW DOES IT WORK –

FMS sends data from Flash to the FMS server – which then sends the data as a Midi signal.

Firstly run the FMS app in the “Server App” folder.
Then run one of the Flash or Air apps. Note – you cannot run .swf files as they do not have the security permissions to access the midi server, unless you

set the permissions here – http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html

You can set which Midi Channel the audio is played through via the drop down on the FMS app.
Windows XP has “Microsoft Midi Mapper” which plays the notes back over the soundcard. Mac OSX has a similar default Midi Playback setting.

To use FMS with other audio apps, you must install virtual midi softward. For example – LoopBe http://nerds.de/en/loopbe1.html
These channels will then show up in the FMS settings drop down.

HOW DO I USE THE CLASS MYSELF? –

Place the uk.co.lawriecape.midi folder structure in you classes folder.
You can then check out the .Fla sources in the “Example FLAs” folder.
A basic setup can be seen below –

In flash –

//Import the Flash Midi Server class.
import uk.co.lawriecape.midi.flashMidiServer;
//Create an instance of the class.
var MS: flashMidiServer = new flashMidiServer();
//Add event listeners for the various Server events - (optional)
	MS.addEventListener("FLASH_MIDI_SERVER_ESTABLISHED", connectionEstablishedHandler);
	MS.addEventListener("FLASH_MIDI_SERVER_LOST",        connectionLostHandler);
	MS.addEventListener("FLASH_MIDI_SERVER_NOT_FOUND",   connectionNotFoundHandler);

function connectionEstablishedHandler(e:Event):void{
	trace("Flash midi server connected.");
	trace("You can start sending data now!");
	MS.sendNote(50);
	//or
	//MS.sendCC(50);
}

function connectionLostHandler(e:Event):void{
	trace("Flash midi server disconnected.");
}


function connectionNotFoundHandler(e:Event):void{
	trace("Flash midi server not found, please check the program is running and try again.");
}

WHAT COMES NEXT? –

There are quite a few limitations to the current system, which I’ll be trying to address in future releases. These include –
The ability to send CC data on specified CC numbers.
The ability to have audio output on multiple midi channels at once – to controll multiple instruments from a single server instance.
The ability to send multiple notes at once – eg. Chords or simultaneous drum hits.

If you have any suggestions, or make anything using FMS, please get in touch with me.
Cheers.
Lawrie.

Lawrie at LawrieCape.co.uk

See also –

Flash Midi Server – Sonar reproduction. from Lawrie Cape on Vimeo.

Download the source code for Sonar from the Google Projects Page.

Flash Midi Server – Processing + Flash + Webcam Instrument from Lawrie Cape on Vimeo.

Flash Midi Server – Sonar reproduction.

Sonar from Renaud Hallée on Vimeo.

I just watched the spectacular “Sonar” by Renaud Hallée – A piece he describes as “Rhythmic cycle w/ abstract animation. Basic keyframe animation using flash, without scripting.” You can see it above. Awesome eh?

Seeing as I was working on my Flash based Midi Server, I thought I’d try and reproduce the basic elements of it using Actionscript.

This is my homage to Sonar – Basic scripting in Flash, using FlashMidiServer and FruityLoops for dynamic audio. I’ll post the SWF and source soon, when I upload the full Flash Midi Server package – Source, Java App, Demos, Air apps etc coming soon.

Flash Midi Server – Sonar reproduction. from Lawrie Cape on Vimeo.

Flash Midi Server – Processing + Flash + Webcam Instrument

Right, this has been something I’ve had in development for a while – and I’ve finally decided to put out a video demo. More info, videos, audio and hopefully source coming soon.

Flash Midi Server + Webcam image to audio app

An early test of my Flash Midi Server – used to send Midi notes and controllers from within Flash movies.

This early demo shows the Processing based Midi server (blue app in the bottom left), and also a Flash Webcam based audio tool. The Flash app takes still images from a webcam, and analysies them for 4 colours within them. These colours are then mapped to a range of notes, so for example, a white image will send a high note, whilst a black image wil send a low note. These notes can then be played back using Midi, and the corresponding images are displayed.

As an extra feature – the “activty level” (amount of movement) in the webcam can be monitored, and sent as CC data, to alter any settings. Here it is linked to a paramater of the midi instrument.

More polished versions coming soon.

Hopefully some nicer audio coming soon too : )

Open Processing

Following on from my post about Daniel Shiffman’s Nature of Code, and the benefits of digging into the processing community, here’s a post about the excellent site OpenProcessing.org

“What? A website to share Processing sketches??”
Share your sketches with others.
Help and collaborate with the community.
Improve and polish your programming skills.

Even if you’re not delving into Processing development yet, there are some amazing examples on the site, which should provide you with some inspiration and ideas, no matter what platform you use. Just check out some of thse incredible pieces –

Empathy –

pEmpathy

Awesome! And here’s the code that makes it –

/** 

Don't move too fast — you might scare it. Click to forgive and forget.

*/ int n = 5000; // number of cells float bd = 37; // base line length float sp = 0.004; // rotation speed step float sl = .97; // slow down rate Cell[] all = new Cell[n]; class Cell{ int x, y; float s = 0; // spin velocity float c = 0; // current angle Cell(int x, int y) { this.x=x; this.y=y; } void sense() { if(pmouseX != 0 || pmouseY != 0) s += sp * det(x, y, pmouseX, pmouseY, mouseX, mouseY) / (dist(x, y, mouseX, mouseY) + 1); s *= sl; c += s; float d = bd * s + .001; line(x, y, x + d * cos(c), y + d * sin(c)); } } void setup(){ size(300, 300, P2D); stroke(0, 0, 0, 20); for(int i = 0; i < n; i++){ float a = i + random(0, PI / 9); float r = ((i / (float) n) * (width / 2) * (((n-i) / (float) n) * 3.3)) + random(-3,3) + 3; all[i] = new Cell(int(r*cos(a)) + (width/2), int(r*sin(a)) + (height/2)); } } void draw() { background(255); for(int i = 0; i < n; i++) all[i].sense(); } void mousePressed() { for(int i=0;i

And that's just one of hundreds of amazing Processing sketches. Here's some more of my favourites.

Scrunch / Flower generator -

pFLower

Spring Snipper -

pSpring

Scattered Letters -

pLetters

Nebula -

pNebula

Spiral Galaxy Mutation -

pGalaxy