• Week 172

    11 April 2016

    A week spent on Twinklr – most of which was spent on rewriting it.

    Or, rather, rewriting the software. It turns out that lovely as the browser-based prototype is, Chromium on a Raspberry Pi just isn’t up to snuff, performancewise, with everything that’s going on – especially when you’re trying to build an instrument with low perceived latency.

    I’ve been rewriting it in Processing. Processing is a surprisingly good fit: it had just been formally announced for the Raspberry Pi, has built-in support for Sound, MIDI, and the hardware GPIO pins; everything I need. Also, although Java is by no means my forte, I have used Processing in anger before – Spirits Melted Into Air was entirely written in it.

    Progress was reasonably quick: it is, after all, another curly-braces language, and I’ve written a lot of the logic already. A lot of what slowed me down is idiom, and building the interface; the graphics and sound production are reasonably straightforward, but the GUI is more verbose. I’ve been writing it in ControlP5; I said to a friend it’s not so much 2000 lines of Processing, as 1000 lines of Processing and 1000 lines of ControlP5. The GUI library is that verbose.

    No plan survives contact with single-board computers, alas. It turns out that Processing on the Raspberry Pi simply refuses to support the Sound library – the Sound library is currently only compiled for 64-bit processors. Even though the Pi 3 has one, it’s a bust. So I rewrote the whole thing to use Minim (and then rewrote it again to use Minim in a different way, as the first was a no-go on the Pi thanks to the vagaries of Javasound). This time, I found it refused to play back out of anything other than the horrible PWM analogue output.

    Suffice to say: I am tired of Javasound errors, and next week, I’m probably rewriting the sound playback code in my third Java sound library of the project. But: the GPIO code is working well, and the graphics performance is very snappy. I think the rewrite’s been worth it.

    I also took the time to stop rewriting the same old features, and build a new one that I have been interested to experiment with for a while now. It turned out very well indeed, and leads to interestingly musical results.

    Finally, I spent a day with some pens and pencils sketching and exploring the form of the object. I should probably have done this sooner, but it was worth exploring. In the crit at the end of the week, some of this thinking as revealed to perhaps be dead ends – but not all of it, and that’s good enough for me. It was good to spend some time thinking with my hands.