Saturday, July 13, 2013

The Infamous Cellular Automaton Synth

It started with the obfuscated C competition... and a youtube video. Well, no it really started with learning about Conway's Game of Life. Err.. It started with a video about a 13 year old girl who was implementing Conway's Game of Life on the raspberry pi... Ahem. I became interested in cellular automata and especially linking it to music. I originally tried to emulate this one liner that was getting passed around on IRC:
echo "main(i){for(i=0;;i++)putchar(((i*(i>>8|i>>9)&46&i>>8))^(i&i>>13|i>>6));}" | gcc -x c - && ./a.out | aplay
I tried to implement my own version that used an automaton to do the same sort of thing (I'll let you scratch your head on what it does, or just copy and paste it into your terminal). It took me a while to get it working, but I eventually got an automaton operating successfully on a torus. I then went and obfuscated it thinking of entering it into the IOCC. It looks pretty good:
echo "main(_i_,i,_,i_i){i_i=30;for(i=7;;i=_i_<<1|_i_>>7) {_i_=0;for(_=0;_<8;_++)_i_|=((i_i&1<<((i>>_|i<<(1+~_&7))&7))>0) <<_;putchar(_i_);}}" | gcc -x c - && ./a.out | aplay
 
Got it? Simple enough. So where did I go with this?