More context on the tai studio webpage. Includes my first gameboy ds livecoding performance with webcamera screen/fingers/stylus projection.
In order to figure out the source of the crashes I was getting I quickly wrote a linux wrapper around the android code so it could run in a simpler-to-debug environment. This of course was running without any problems, so not much help, but it’ll come in useful anyway.
Next step, try it in the emulator – this exhibited the crash, but I couldn’t get a good stack trace from gdb. While investigating this I decided I could use a simpler method with the hardware, which is much faster than the emulator. addr2line is a program you can use for making sense out of crash reports, you take the address reported in the crash log (using adb logcat to read them from the android device), feed it to addr2line with the library and it tells you the corresponding line number in the source.
It turned out the crashes were down to something more fundamental as they were happening all over the place in the scheme interpreter – so I had a bit of a wider search and it came down to threads, I hadn’t noticed that Android’s GLSurfaceView uses a separate thread for rendering, so I was calling the scheme interpreter in the midst of other evaluations, not too great. A simple fix using java locks around the evaluations and rendering calls.
The next thing was implementing more fluxus features. One major improvement is using with-state to wrap push and pop so they are implicitly scoped. This means you can’t miss (or add extra) a pops or pushes to your state stack manipulations, so something like:
(push) (translate (vector 1 2 3)) (build-cube) (pop)
(with-state (translate (vector 1 2 3)) (build-cube))
To do this I had to learn TinyScheme’s macro language which is different to Racket’s, but this isn’t too complex a task:
(define-macro (with-state . args) `(begin (push) (let ((r (begin ,@args))) (pop) r)))
Here we call push then basically “paste” the code given to the with-state function into a begin block, and record it’s return before calling pop. Then we return the value. There is a very similar macro for with-primitive.
There are now quite a few commands ported – there is a new version packaged here, and this is the test script that I’m using:
(clear) (colour (vector 0 0.5 1 1)) (define cubes (map (lambda (p) (with-primitive p (apply-transform) (translate (vector -2.5 2 5)) (rotate (vector 45 0 0)) (translate (vector (quotient (- p 1) 6) 0 (modulo (- p 1) 6))) p)) (build-list (lambda (n) (with-state (scale (vector 0.5 0.05 0.5)) (build-cube))) 36))) (every-frame (for-each (lambda (p) (with-primitive p (rotate (vmul (vector (sin p) 0 (cos p)) 5)))) cubes))
Mostly my android experience has been good so far, it’s been very quick to get things running and be fairly productive. It doesn’t come without it’s share of yak shaving though. I’ve spent quite a lot of time trying to get remote debugging of native code working with my phone (a HTC desire) with little success. This seems to be a fairly well documented problem, the symptoms are messages like this when running ndk-gdb:
ERROR: Could not setup network redirection to gdbserver?
Maybe using –port=
to use a different TCP port might help?
When run with –verbose it seems something a little different is wrong:
run-as: Package ‘am.fo.nebogeo.fluxus’ has corrupt installation
Which looks like some result of having a rooted phone (which I do) as ndk-debug is a possible attack vector for doing nasty things and is therefore very critical of the permissions of the directories on the system. In order to fix this I installed ROM Manager from the market which contains a script to fix permissions. This didn’t work at first by pressing the button in the app so after some poking around I found the shell script in: /data/data/com.koushikdutta.rommanager/files/fix_permissions
It turned out that this script depended on an interesting utility called busybox, which provides tiny versions of GNU programs for phones. The easiest way to install this was to install TitaniumBackup and click on it’s “Problems” button which would download it, then copy it from /data/data/com.keramidas.TitaniumBackup/files into /system/bin/ and run busybox –install -s /system/bin/
Then the script could run, and additionally I needed to run chmod 774 /data/data/* to get make sure everything was in the correct state, but still no luck with gdb. At this point I decided my time would be better spent on making a linux version of the android app for debugging purposes and get it running in the software emulator. More on this soon.
I’m also documenting bits and pieces of my android development notes on FoAM’s wiki here.
I spent thursday afternoon in the tangible auditory interfaces studio at the Helsinki Media Lab with Till Bovermann and Erich Berger. Till has a report on our investigations of taking the Betablocker virtual machine into new noisemaking territories.
Here is an example of a betablocker program written without the help of the graphical programming interface, by poking heap memory directly to create a simple sawtooth oscillator:
// begin LFSaw u32 threadID = m.add_thread(23); m.poke(23, ORG); m.poke(24, PIP); m.poke(25, 6); m.poke(26, JMP); m.poke(27, 1); // end
I recently took a long train journey and had an idea to use my android phone for taking timelapse photos for Miska Knapek. I had no laptop with me, and realised there was no way I could script anything on the phone itself to do this, or anything more complex. This was the kernel of an idea that ended up as two intense days of hacking fluxus into android.
It’s running as native code (underneath the JVM), and as it’s got the same type of processor as the NDS it shares some code with Betablocker DS which has similar restrictions. There is only a tiny amount of fluxus code ported at the moment, but the scenegraph and core maths is pretty much the same (with some changes to fixed point). I’ve used TinyScheme for the interpreter (the same one Impromptu is based on) which gives you an impressively complete language with a very small footprint.
This is just a quick proof of concept (how far I got is testament to the excellent documentation and ease of portability using C++ with the NDK more than my abilities). It would be nice to expose all the sensors to the script (motion, compass, GPS, camera, wifi) and make it quite general purpose. Writing code with the touch screen is do-able but not very usable – but I have some ideas in this area also…
My first attempt at homebrew driven “touch” livecoding at the TAI studio opening event at the Helsinki Media Lab. The DS itself proved to be quite a draw for the audience, and I think the addition of hands and fingers to the projection of a livecoding interface is a (partly unintentional) move in a good direction.
Photos by Till Bovermann.
Betablocker DS is going to get it’s premier outing at 4for8 at Helsinki Medialab this Thursday. This is an all new upside-down video: