Betablocker DS code patterns (part 1)

2012.01.27

Some useful Betablocker DS code patterns as used in common live coding situations.

Firstly, when carrying out a sound check before a live performance it's important to keep some kinds of sound engineers happy generating as many different sounds as you can so they can fiddle around with stuff - of course remember to turn everything up to 8 when asked to make the loudest sound you can in order to leave some overhead to blow the PA.

This is a betablocker program which will play all the sounds in a sound bank at all frequencies. Add more concurrent threads to make it more interesting. Values interpreted as pointers are visualised as arrows:


(the instruction set description can be found here)

In betablocker the beat is always locked to the instruction cycle rate, so fast changing sounds are a matter of optimisation. One of the most common ways around this (and a good way to start things off in a gig) is to use one fast loop program for playing sounds while another slower program modifies the first by overwriting bits of it.

More to follow in this series. See also evolved betablocker genetic programs.

Categories : howto   livecoding   visual programming

Betablocker DS: Table feedback after Claudius Maximus

2011.08.29

After getting some dates for gigs with Betablocker DS, I am spending some time looking into audio algorithms, and implementing them on the Gameboy DS. Last Thursday I spent some time at the TAI studio/bunker with Till Bovermann investigating these PD patches by Claudius Maximus:

The algorithm uses feedback to create sounds that take some time to play through a wide range of frequencies. It works by writing into the same buffer it's playing, but at a different rate/position - the resulting ugliness suits the style of BBDS very much. As an aid to our understanding Till converted the algorithm to Supercollider, then over the next couple of days I managed to get it running with an inner loop of 9 instructions on the DS (could probably be optimised further, but I'm still a beginner):

@ ----------------------------------------------------
@ qrz_maximus: *dst, length, readpos, writepos [freq, *tab]
@ ----------------------------------------------------
        .global qrz_maximus
	.type   qrz_maximus, %function
qrz_maximus:
        push    {r4,r5,r6,r7}       @ push the registers we need
        ldr     r4, [r13,#20]       @ load freq from stack into r4
        ldr     r5, [r13,#24]       @ load *tab from stack into r5
        ldr     r6, .tablength      @ load the tablen into r6
.maximus_loop:
        ldrh    r7, [r5,r2]         @ load the sample into r7
        strh    r7, [r0], #2        @ write output: *dst=r7 dst++
        strh    r7, [r5,r3]         @ feedback into tab[writepos]=r7
        add     r2, r2, r4          @ readpos+=freq
        and     r2, r2, r6          @ mask readpos into range
        add     r3, r3, #2          @ writepos++
        and     r3, r3, r6          @ mask writepos into range
        subs    r1, r1, #1          @ length--
        bne     .maximus_loop       @ repeat until length zero
        mov     r0, r2              @ return readpos
        pop     {r4,r5,r6,r7}
        bx      lr                  @ exit
.tablength:
        .word   0x00003FF

And here it is running on autopilot with a test program in Betablocker:

Scheme Bricks on Android

2011.06.07


A screenshot of scheme bricks running on android. Its actually the next version of scheme bricks really, as it's been subject to a major rewrite. The original was pretty cluttered with lots of last minute pre-going-on-stage hacks and additions. As in the original, the touchscreen expression selection works by ray casting into the 3D scene with (geo/line-intersect) which is now part of android fluxus, but no dragging or dropping - the fun bit - or even fonts yet.

Still it's somewhat satisfying to work on fluxus scheme code that runs on Linux, Mac, Windows, Android and PS2!

Categories : android   visual programming

Rainy sunday

2011.05.29

A rainy Sunday, with only the dog for company, so in between walks I thought I'd try and learn some assembler. I've been unhappy with triggering samples with Betablocker DS (I prefer synthesis) and I've heard good things about ARM asm - so it seemed like a good opportunity to attempt a small, fast and dirty synth.

I found some really nice tutorials here and here. I've done a tiny bit of this sort of thing before with microcontrollers, but this is a more of a respectable flavour of assembler, on a decent RISC processor (which derives from the Acorn Archimedes and is now used on IPhones, Androids and Gameboys). Here is a white noise generator:

; white_noise(r0=*dst, r1=clock, r2=length, r3=freq)
white_noise:
        push    {r4,r5,r6}          ; need to restore registers we use
        mov     r4, r1              ; r4 is the rand state (start with clock)
        ldr     r5, .rnd_data       ; r5 is the multiplier value
        ldr     r6, .rnd_data+1     ; r6 is the addition value
.noise_loop:
        mla     r4, r5, r4, r6      ; the maths bit: r4 = (r6 + (r5 * r4))
        strh    r4, [r0], #2        ; *dst++ = clock; 
        subs    r2, r2, #1          ; length--;
        bne     .noise_loop         ; branch if length not zero
        pop     {r4,r5,r6}
        bx      lr                  ; return
.rnd_data:
        .word   0x000343FD          ; nicked from ansi c rand()
        .word   0x00269EC3          ; need to keep large numbers (>8bit) as data

This code is based on the ansi C rand() function that basically looks like this:

randnum = randnum * 214013 + 2531011;

Which we can do in a single instruction - mla (multiply with accumulate). Of course, gcc would presumably optimise much better code than mine from C++, but there is something more satisfying about doing it this way. I certainly prefer the sound - and over half the cpu usage remains unused with 5 voices and the interface running. The rest of the code is here.

New Betablocker DS video

2011.05.01

I made a possible candidate for the TOPLAP dvd project - I took some time to get the audio visual sync working properly, which makes it (possibly) a little clearer what's going on.

Video from 4for8 event

2011.04.26

TAI Studio Opening Documentary from LFSaw.de on Vimeo.

More context on the tai studio webpage. Includes my first gameboy ds livecoding performance with webcamera screen/fingers/stylus projection.

Categories : gig   livecoding   visual programming

Betablocker DS premier @ 4for8

2011.04.09

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.

Categories : gig   livecoding   visual programming

More Betablocker DS

2011.04.04

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:

Categories : gig   livecoding   visual programming

Wonky Betablocker DS movie

2010.12.28

More work on Betablocker DS. Note playback cues work (after spending some time scratching my head over the affine transformations on the nds). I find these essential for visual feedback when livecoding. I also appear to be maxing out the graphics chip, which fails pleasingly gracefully - stopping rendering rather than framing out - some parts of sprites disappear in hectic areas of the screen keeping the framerate constant (wish OpenGL would do that).

A lot of the code needs cleaning up (quite a bit of lazy floating point stuff to be removed) but it's starting to feel a bit on the finished side. Just need to learn how to play it now: code & rom.

Categories : games   livecoding   visual programming

New version of Betablocker DS

2010.12.16

Pocket touch livecoding in assembler. More sounds, better icons, pointer visualisation, new programming system, thread control and visualisation (finally also using the top screen). Source and rom. The colours look much better on the real hardware.

Categories : games   livecoding   visual programming