OSC in Games?

Posted on

Had Some Fun This Weekend

Had some fun this weekend :D

So something I've always wanted to have was a decent way of sequencing stuff in games. What does that mean Gaz? Well most super nice things in games are a sequence of events that creating some sort of nice audio visual 'stuff'

Demo-scene coders do this very well and generally use some sort of script specifying what happens when so the music and visuals get nicely synced. It was pretty interesting looking at how these guys did things after a few of the bigger groups chucked a load of their tools and source onto github a couple of years ago.

I'm kind of a lazy swine who doesn't like editing text files, the way this stuff is mostly done and always thought that this would rule if you had some sort of time line you could vary parameters, trigger events and do all that kind of stuff.

Loads of programs have this kind of thing, Max, Maya, Final Cut Pro and even some game engines; Unity, CryEngine and the excellent Unreal Engine 4.

But you know what? This is for home hobby projects. All of those things are tightly bound to either and activity (editing animation, music, videos) or to a specific technology (as is the case with UE4, Unity and CryEngine). I don't really want that, I'd rather write my own cack handed gaming tech that can be instrumented to receive parametric data from any old external program.

So I got a good part of that working after jack-dawing some existing technology and shoehorning it together. Tech piece the first:


Open Sound Control is a protocol for sending 'stuff'. It's basically a MIDI replacement that fills in some of the horrible gaps MIDI has (low parameter resolution, lag, built around a physical transport {cables! Yuck!}) that can work over the network nicely.

There's a slew of OSC clients and a great little library called OscPack that can receive OSC chatter. And now tech part the second.


And this is a generic OSC time line editor. With this you can send information to an OSC server, information that you edit in multiple channels and gets played back, nicely interpolated and sent to an OSC server. It's nice and general, can control MIDI too if you like it and you can find it here.

The Results

Early days but I have a little flying around demo that takes only a couple of inputs (time and field of view) but I got those hooked up to a time line I'd edited.

And it works nicely. The cuts are done by jumping different time points and then increasing / decreasing time at different rates. They sync with some music playing and despite being very remedial looks nice and was easy to put together.

Ha! I even got my iPad controlling the thing using [TouchOsc][touchosc] as you can see below. It's great, the game hasn't a clue what's telling it to do the stuff it's doing. An excellent detachment of mechanics and content :)

There's a lot of potential here. Next up I'm going to try and hook Logic via an OSC -> MIDI bride. Vezér is good but expensive to buy (I already own Logic) and though admirable is a little bit rough around the edges. The other thing I might try is hooking up a tracker like Renoise that already has OSC support directly built in. I wouldn't lose a load of parameter resolution that way and would have less need value interpolation in the game.