Sunday, May 17, 2009

The Swarm (48 Hour Challenge)

Chaos Amoeba has challenged me to a 48 hour challenge: "I challenge little-scale to make a piece of music that sounds like a swarm of insects."

I scratched my head and wondered how I would go about this, and what it means exactly - for example, would a swarm of insects be best represented by a given musical theme? Or would it be best to go for a strategy that somehow simulates the perception of hearing and being inside a swarm of insects.

I decided to go for a slightly more abstract path - sonifying the behaviour of a swarm.

There is a Max object called mxj Flies which visually simulates the behaviour of a swarm of flies. The data is output is a set of four values - index (ie. the individual fly), and x, y and z positions. Taking this data, I specifically built a linear feedback shift register (LFSR) object for Max, which outputs pseudo random noise.

LFSR's are used for the noise channel in obsolete sound chips to generate noise and distorted waveforms, such as the Sega Master System's SN76489, the Atari POKEY and the Atari 2600 amongst many others. The sounds that are generated by an LFSR were typically used for such tasks as bass lines, kick drums, snares, hi-hats and explosion sound effects.

Different consoles use LFSRs of different lengths and taps and can thus have a unique sound (the timbres produced by the Atari 2600 come to mind, for example). Even if a given LFSR is structurally a little different, it will possibly generate a significantly different sound - there are various versions of the SN76489, for example, and reportedly the main way in which they differ is through their noise channel, which is similar but not the same amongst some of the versions.

The nice thing about my LSFR object is it can mimick a number of LFSR structures. The object has six inlets and can take up to six arguments, allowing the user to create any LFSR with a length of up to 16 bits with 1, 2 or 3 taps. The taps can be at any bit position. The frequency of the one bit output, the gain, the position of the taps and the length can be set at any time by sending a corresponding message to a given inlet.

Here is a structural overview of my LFSR:

.REGISTER has length of L BITS
<--------------------------------|----> .BIT#0 OUT
|--> .TAP #1 -------------------^
|--> .TAP #2 ----------> OR -^
|--> .TAP #3 --> OR -^

• L is a number between 1 and 16
• TAP #1, #2 and #3 is a number between 1 and L
• The register is updated as determined
by the frequency

The data from each of the flies is used to control the synthesis process of each of the 40 LFSRs. The x co-ordinate controls the panning of the sound, the y co-ordinate controls the frequency and the z co-ordinate controls the volume of the sound - ie. when the flies move closer to the viewer, they appear louder.

The length of all of the LFSRs is controlled globally, and is set to 16. Each tap for each LFSR instance is generated at random when that instance is created. Finally, to add some tonal colour, each LFSR is run through a ring modulator that has a sine wave as a control signal, with a frequency between 100 and 700 Hz. This frequency is also randomly generated at the start of the patch.

Video of "The Swarm". Visual code by Topher Lafata Flies, visual algorithm by Jeff Cragg and Alex Vulliamy. :

The Swarm by little-scale from sebastian tomczak on Vimeo.


Brian Green said...

amazing work.

Veqtor said...

Wow, that's awesome, any chance of releasing the LFSR external?

Sebastian Tomczak said...

Hi Veqtor!
Nice to see you around these parts :)

If you go back to the main blog and look at the post which is one post older than this one, you will find the LFSR external. It's not quite there yet, but its usable :)

Rikki said...

Amazing me again.

ed said...

for sonic swarming, you should definitely check out dan jones...

he built an entire swarming architecture in processing, with different agents possessing different sonic properties, and modifiable parameters (speed, swarm size, communal attachments etc). it's a really beautiful piece of work.