picture home | pixelblog | qt_tools

omino code blog

We need code. Lots of code.
entries for category "c"
David Van Brink // Sun 2008.03.23 20:54 // {c code wbl weird blinking lights}

Retro USB MIDI Device VI

First Working Code

After much tinkering and poring over data dumps and specs, I have flashed the PICDEM FS USB board such that, when plugged into the Mac, it shows up as a usable MIDI input. (Doesn’t yet show up properly on Windows XP, though.) This, using a Pic 18F4550.

From reading and googling the subject, it seems that most USB developers start by creating the descriptors, and committing them to ROM.

I took a different approach. I wanted to have a flexible and repeatable way to create new MIDI devices as needed. Who knows, I might do more than one. And this way others might benefit from it too, potentially. As part of main, I call a setup method which dynamically creates the all the descriptors, strings, & so on. I donated 256 bytes of RAM (out of 2k) to hold the descriptors. And the code to poke it all in chews up a K or so of program space. But, for now at least, the freewheeling flexibility is worth it.

        "omino.com products",
        "omino 8038 controller"

The above C call creates in memory the device and configuration descriptors for a Streaming Audio (MIDI) USB device with Vendor ID 0832, Product ID 401C, five MIDI input cables, five MIDI output cables, for a company named “omino.com products”. It shows up in the MIDI patchbay as an “omino 8038 controller”.

Below the cut, some trivia about the Pic 18F4550, the PICDEM FS USB demo board, and their development tools.


oh, i dont know. what do you think?

David Van Brink // Tue 2007.03.20 01:06 // {c code}

Always with the Printf()

So here’s an interesting problem. Suppose that you’re writing an After Effects plugin, and trying to debug some of the graphics renderings and primitive routines.

Sure, modulating a handful of tinted rectangles which alter their dimensions based on the red and green components of the color they’re drawn over looked right when I tried it…

And then doing a spherical projection looks more than right, it starts to look kind-of cool…

But at some point I got paranoid that my antialiased rectangle routine, at the core of everything, hadn’t been rigorously exercised.

And so, short of pixel-sniffing (which I’m just not studly enough for today) how best to check a whole lot of different cases? Niftily, the application in normal use lends itself to the problem. Since it’s an animation program, and highly parameterizable and scriptable, it’s possible to animate any and all parameters and render the sequence over time. It’s a gosh-darned parameter sweeping test system built into a… gosh-darned keyframed animation system.

This still requires visual inspection of a lot of frames, but at least it’s pixels, and therefore fun.

But how to match up each rendered frame with the parameters that created it? One way might be to create a log file, pipe it to the line printer, get the 400 pages together in one of those nifty binders, and squint at it and the screen… But then again: rendered frames. A tidier approach is to printf to the rendered frame itself.

They say in cinematography to strive to have “Every frame a masterpiece,” but I’ll settle for “Every frame a self-explanatory test-case.”

Here in the future, you can find anything you want, and Googling for “8×8 font” delivered some hits right off. (I wanted to have my own font to reduce involvement with the OS, to maintain portability.)

It’s so technical looking. It has that marvelous anti-aesthetic that comes only naturally from a non-artist… so functional, so 1970’s NASA. But it’s there, and I used it, thanks to a generous soul at http://overcode.yak.net/12.

Here’s the whole font, for your viewing pleasure.

And here’s the C data file I generated using a Perl script to parse the .bmp on the link above. Note the festive ascii-grid representation of each character… Every file, a self contained thingum.

Feel free to use this 8×8 C data file for your retrovideo 8×8 font needs. And such.

Edit: reading further on http://overcode.yak.net/1 I see that the font author, John Reeves Hall, passed away in 2005. Interesting. The ultimate goal of technology, I believe, is to demolish all boundaries of time and space, allowing intantaneous communication with any person, living or dead. Thanks for the font, John.
oh, i dont know. what do you think?

David Van Brink // Mon 2006.10.16 20:45 // {audio c code mac os x}

Core MIDI and Funny Noises

The Sound

The Code

Here’s a super simple plain-old-C file that uses Core MIDI on Mac OS X to send random notes to all the channels:

And here is a Reason setup with some various cute sounds used for the MP3 above.


Oh… I write MIDI software so infrequently these days that I need to keep around a starter-app, to remember how it’s done. Perhaps someone else might happen upon this example and benefit. Meanwhile, at least I know where to find it.

Daniel Jalkut // Tue 2006.10.17 07:457:45 am

Very cool sounding. Sort of reminds me of some Harry Partch pieces I heard back in school. That might be a naive interpretation of “random notes” – but … all the same :)

w of wbl // Wed 2007.08.8 07:067:06 am

are you saying that nearly 100 years of electronic music can be summarized by this one piece of software?

oh, i dont know. what do you think?


(c) 2003-2011 omino.com / contact poly@omino.com