Apr 28 2009

Voronoi diagram generator in flash

Category: Development, flashMartin @ 12:31 am

After reading Ross Bencina’s paper : “The Metasurface – Applying Natural Neighbour Interpolation to Two to Many Mapping”, I decided to have a go at building a similar system myself and hopefully revive an earlier project for creating different ways of modulating parametric systems (for me that means audio).

The first pass is done and you can see it working right here (flash player 10 required)

The code will be up somewhere soon, at the moment its mainly a port of the code from this page (but refactored to seperate the voronoi model, the scanner and the renderer). Thats combined with an implementation of the FastClip algo from this wikipedia page to keep the lines in the bounding box.

next up is gathering the line segments into polygons and linking stuff together ready for some nearest-neighbour evaluation.

Tags: ,


Oct 08 2008

OSC - Open Sound Control

Category: Development, Java, OSC, open sourceMartin @ 12:11 pm

For some reason, MIDI isnt dead yet, although it is indeed ‘ubiquitous and lightweight’ that doesn’t mean it should stick around. For some tasks its fine, but its definitely starting to show its age. One of the alternatives for communication between audio / video software and devices is Open Sound Control - OSC.

Im not going to go into a deep discussion of MIDI vs. OSC at this point, there are of course some benefits to MIDI which OSC should deal with in some way (e.g. a standardised namespace for representing MIDI semantics, or a discovery mechanism for that namespace..)..anyway, I just want to let you know that I’ve been working on some OSC related stuff to make using it easier from both Actionscript 3 and Max/MSP.

First up is OSCLib, this is intended as a low level set of OSC libraries which you can use in other applications. Actionscript 3 doesnt have UDP, only HTTP sockets whereas most OSC implementations (e.g. Reaktor, Bidule) are UDP based although one notable exception is SuperCollider which supports both. So to help bridge the gap there are java implementations for both HTTP and UDP clients and servers (well, the UDP server is currently missing but should be done in a day or two..)

For Max/MSP there is an MXJ object which wraps the HTTP server so you can send messages from a Flash / Flex client directly to Max/MSP.

There is some documentation on the project wiki pages for getting your dev environment setup and also a Flash / Max demo you can try out.

As a side note if anyone has a Korg Kontrol49 then i’ve also got a project based on OSCLib for working with the Kontrol49 in native mode : KontrolTools. This allows you to have full control of the lights and text displays via OSC as well as generate OSC message from all the knobs, sliders and buttons.

Tags: , , , , , , , , ,


Jan 15 2008

Reaktor Sample Map Generator

Category: Development, Other PlacesMartin @ 6:10 pm

Reaktor is great, but one thing that i dont like about it is the built in sample management, you have to create these ’sample maps’ to use your own samples but the UI for it is a bit rubbish, like an awful version of kontakt. so i built a tool to generate map files automatically.

UPDATED
I’ve built a new version in Java which is tested and working on both Windows and OSX. You can download the app here.

I’ll put the source up soon when I get a spare minute.

comments, suggestions, modifications are all welcome.

UPDATE 2
If you are wondering how to run a .jar file then you will need to first download and install java then you should then be able to just double-click the .jar file. If for some reason that doesnt work you can ‘Open With…’ and then find where java is installed, somewhere like : C:/Program Files/Java/jre1.6.0_07/bin and choose the ‘javaw.exe’ program.

Tags: , ,


Aug 17 2007

MDK Recorded Live on that there internet radio

Category: Other Places, mp3 downloadMartin @ 3:25 pm

Bit late I know, but you can download a recording of me playing live on the Silent Block show right here, right now

Its about 85 mb.

NOTE. I just updated the link because it was broken (15th Jan 2008)


Jun 14 2007

MDK Live on your internet radio.

Category: Other Places, RealityMartin @ 8:16 am

100% new and unreleased MDK. Make sure you tune in.


Jan 28 2007

MDK - A Theme 12″ : OUT NOW!

Category: Other PlacesMartin @ 5:40 pm

You heard me. The brand new MDK 12″ is ready and waiting for your love and attention courtesy of WeMe records.

Just click the record to grab your copy now.

WeMe 08

Better hurry, theres only 300 copies.

You can check out a couple of the tracks by visiting the MDK MySpace page and the WeMe Myspace page


Dec 25 2006

Flash, file uploads, a 403 and mod_security

Category: DevelopmentMartin @ 11:03 pm

If, like me, you have just spent a good while pulling your hair wondering why your file upload from flash mysteriously return a 403 : access forbidden even though the url is accessible from the browser and you might have even gone to the trouble of building an html form to prove that the damn thing works. then, you might be running into a problem with mod_security.

The solution :

add this to a .htaccess file :

SecFilterEngine Off
SecFilterScanPOST Off

Tags: , , ,


Dec 21 2006

Yuletide Logs!

Category: Other Places, mp3 downloadMartin @ 1:06 pm

Its jingly, its frosty, it rips off Tchaikovsky

The best christmas single ever, available to download FOR FREE from your favourites and mine.

Pleated Lemon

Tags: , , , ,


Nov 17 2006

PixLib part 3. Abstract Factory

Category: Development, PixLib, flashMartin @ 9:19 pm

Today I found yet another good reason to test PixLib (and I still have some others in mind that are to come, like removing all my dependencies on the mx.* packages)

To give a bit of background, the application im building is a drag-and-drop based story creator for schoolkids. Theres a stage onto which they can add different types of things (aka artifacts) and move them around, scale, rotate etc.. Now most artifacts behave the same way, but some need special abilities, for example speech bubbles have text which can be edited ‘live’ (i.e. inside the bubble not in a seperate text field) and there are other types of artifact with their own peculiarities. Each of these types of artifact inherits from one base class and its this base class which most of the application deals with. It doesnt need to know about the difference between a normal artifact and a speech bubble it just wants to keep a list of them, save and restore their state etc..

To attain this goal i have decided to use a factory to create the artifacts. A factory is just a class (or often a single method) that is used to create objects. If you havent heard of these then Wikipedia has some more information: Factory Method Pattern and Abstract Factory

At creation time I know the type of the artifact I want (its a string property of an Artifact model object) and I need to create the corresponding UI object. I could code my own factory method or factory class and use a big if / else (or switch / case) construct to decide what to build depending on the artifact type but there has to be a better way. Enter PixLib’s AbstractFactory.

If you look at the API for AbstractFactory its very minimal, the only public method is push (sKey:String, classConstructor:Function). This is used to register the types of objects I want to build.
Now if you look at the source you will notice the more interesting method _buildInstance (much like the buildInstance from the HashCodeFactory from the previous post).
Because its an AbstractFactory that means I have to make my own concrete subclass which will implement my factory method. I also need to register the types I want to create by their string identifiers.

(Its worth noting at this point that the PixLib AbstractFactory class doesnt play the exact role of the AbstractFactory class in the canonical AbstractFactory Pattern. It is ‘Abstract’ because you create concrete subclasses and dont use it directly but unlike the usual AbstractFactory in the pattern it doesnt have the same interface as those subclasses, instead it provides a facility for dynamically linking identifiers to class constructors which the concrete subclasses can use to create objects.

If thats just made things even more confusing dont worry about it..)

First, I need to extend the Abstract Factory and register my types :

class EditableObjectFactory extends AbstractFactory
{
    // private constructor for Singleton
    private function EditableObjectFactory()
    {
        super();
        // register artifact types
        push(Character.TYPE_ID,Character);
        push(SpeechBubble.TYPE_ID,SpeechBubble);
    }

...

}

Then I can implement my factory method which looks a bit like this :

public function createEditableObject(artifact:ArtifactModel,mc:MovieClip):EditableObject
{
    // Create instance according to artifact type (i.e. Character.TYPE_ID, SpeechBubble.TYPE_ID etc..)
    return _buildInstance(artifact.getType(),mc);
}

Then the application code can just ask the EditableObjectFactory to create the appropriate item when a user requests a new artifact to be added to the stage.

Another benefit of this is that each of the 3 versions of the application can easily add their own custom artifact types. They each just register the type with EditableObjectFactory at startup and the rest happens like magic. :)

Another examples is available within PixLib. If you look at the TweenFactory class in the com.bourre.transitions package you will see that it subclasses AbstractFactory to be able to create instances of Tween objects.

If you find yourself in the situation where you are dealing with a set of if / else or switch / case statements when you are creating objects then its definitely worth considering using a factory and encapsulating the creational process into its own class.

Tags: , , ,


Nov 15 2006

PixLib part 2. More configuration features and a ‘hidden’ gem.

Category: Development, PixLib, flash, open sourceMartin @ 10:11 pm

After the previous success of PixLib dealing with my configuration needs, today brought a new challenge, creating instances at runtime from string identifiers (aka Class Factories).

To complete part of the project im working on in a nice way I want to be able to create instances of UI classes at runtime, using their fully qualified package names as identifiers. e.g. com.relivethefuture.ui.Stage.

The package names will be specified in the config file, but the class constructors need to be passed parameters which can’t be declared in the config as well.

IF the instances could be created without parameters then I could have used the config type called ‘class’. This would have meant that the framework would have done the hard work for me and created me an instance of the class specified.

When you are able to use this feature you can setup your config like this (note the quotes around the package name and any string arguments)

<config>
    <instance type="class">'com.mydomain.MyClass',23,12,'hi Mum'</instance>
</config>

The interesting thing is whilst investigating the source code to see how PixLib creates the class instance I found a handy little utility function tucked away in the HashCodeFactory class (com.bourre.core.HashCodeFactory).

This class has a static method just for building instances, it looks like this :

public static function buildInstance(sPackage:String, aArgs:Array)

Exactly what I need.

I can just specify the class name in my config file

<config>
  <stage>
    <classname type="string">com.relivethefuture.ui.Stage</classname>
  </stage>
</config>

and when the time comes I just call the buildInstance method (note the parameters are supplied as an array)

stage = HashCodeFactory.buildInstance(Config.getInstance().stage.classname,[mc.mainStage]);

Magic.

Now, for those of you who are going to be creating classes from package names remember one vital thing. You *MUST* reference the class at some point in your code for the compiler to include it into the swf, otherwise you wont be able to create an instance. This is slightly unfortunate, but its easy enough to deal with, just add

static var myClass:com.mydomain.MyClass

to your main class (or in a seperate class that is just used as a placeholder to ensure the classes are imported) and you’re good to go.

Tags: , , , ,


Next Page »