Dorkcamp ‘09

June 21st, 2009

Douglas Repetto started dorkbot in nyc in late 2000, as a free forum for “people doing strange things with electricity”, with each meeting consisting of a few informal presentations within the broad remit of electronic/electric/robotic/software art.  After meeting Douglas at a crummy generative art conference, some friends and I decided to start dorkbotlondon.  We had our first event in late 2001 and it was an immediate success, there’s something about the combination of artist geeks, geek artists, free entry and cheap beer that makes things flow.  The Belgians had the same idea, and it has since spread to something like 60 different cities…

We’re about to have our 62nd dorkbotlondon event this Tuesday 23rd June ‘09, a really great lineup including Douglas himself.

The reason I’m posting though is dorkcamp (aka burningdork), dorkbotlondon’s annual camp.  It happens late summer, somewhere an hour or so out of London, and features workshops, presentations, performances etc.  It’s an actual camp, although we’ve done it on campsites with kitchen, indoor space, showers etc so isn’t a great hardship…  To get a flavour, here’s video documentation of the first one in 2006:

We’re looking for a venue, and for people who want to join in (this is one of those ‘everyone is a volunteer’ type events).  If you’re interested, head over to the wiki page and/or join the mailing list to find out more.

Patterns in Haskell

June 17th, 2009

I’ve been trying to make music with Haskell for a little while now.  One thing about Haskell is that its strict typing forces you to think a lot about how you represent things.

I wanted to support two things in my musical pattern representation, firstly polyphony (more than one sound being triggered at the same time) and secondly recursive structure. In the west we often think of rhythm in quite `flat’ terms – a 2d pattern like this:

fruity

Of course that’s a pretty useful techno interface, allows for polyphony, and could be represented in haskell using a straightforward list of lists.  However this 2D structure is only really suitable for making music with fixed timed signatures, most notably 4/4.

Time: you're doing it completely wrong

Time: you're doing it completely wrong

Enter Bernard Bel (pictured right).  His BP2 software represents music in a manner inspired by Indian classical music.  His 2001 paper Rationalising musical time has all the details and is a great read, formalising a quite beautiful way of thinking about time. As part of that it defines an elegant pattern syntax that allows patterns to be embedded inside patterns of differing time signatures.

Here’s my first attempt at representing analogous structures in Haskell.  Straightforwardly, a musical event is either a sound (represented by some string) or some silence:

data Event = Sound String
           | Silence

A musical structure is either an event, a cycle of structures, or a polymetry of structures:

data Structure = Atom Event
               | Cycle [Structure]
               | Polymetry [Structure]

A cycle allows us to sequence structures one after another, and a polymetry allows us to represent several structures occuring over the same period of time.  If the structures within a Polymetry have different durations, then they are ’stretched’ until they are the same length (equal to the lowest common multiple of their lengths). I’ve written something in parsec that parses Bel’s notation into the Structure datatype.

The problem with the above representation is that it gets unwieldy with complex rhythmic structures.  The whole point of generative music is being able to make very long patterns out of much shorter rulesets.  However with this representation, to find the 10,000th event you’d have to calculate the 9,999 events preceeding it.  This becomes a particular problem when modifying these structures as part of a live coded musical improvisation.

So I instead came up with this representation:

data Pattern a = Pattern {at :: Int -> [a], period :: Int}
type SoundPattern = Pattern String

Instead of explicitly representing a recursive structure, I’m now hiding everything inside a function mapping from integers to a list.  You pass the function the current position in the pattern (e.g. the current ‘beat’, and get back the list of events at that position.  For certain operations you still need to know the period (length) of the repeating pattern, so that’s in the datatype constructor too.

What kind of operations can I do to these patterns?  Here’s one that simply shifts events backwards in time:

(<~) :: Pattern a -> Int -> Pattern a
(<~) p steps = Pattern (n -> at p (n + steps)) (period p)

And in the other direction:

(~>) :: Pattern a -> Int -> Pattern a
(~>) p n = (<~) p (-n)

Here’s a higher order one that applies an operation conditional on the time value (while preserving the period of the original):

when :: (Int -> Bool) -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a
when pred f p = Pattern l (period p)
where l n = at (if (pred n) then (f p) else p)  n

Making this possible …

when (n -> n `mod` 8 > 3) (<~ 2) p

… which shifts the pattern back in time two steps, but only affects every other group of 4 steps.

This is probably fairly humdrum stuff, but quite fascinating to me as someone relatively new to both haskell and functional programming. Being able to pile functions on top of functions in this way lets me compose complex patterns out of simple parts, and I only ever have to deal with the simple parts in memory, not the complex patterns. Great! Thanks to the parameterisation of the Pattern datatype, I can also use patterns for different aspects of a rhythm, my recent screencasts [1,2] showing concurrent patterning of samples, vowel formant filtering, sample playback speed and a comb filter.

I’ve also been looking at making the Pattern a Monad (my first ever monad instance, woo!):

instance Monad Pattern where
    return x = loop $ [x]
    (Pattern l len) >>= f = Pattern l' (lcm len len')
        where l' n = at (combine $ map f (l n)) n
              (Pattern _ len') = f undefined

Where ‘combine’ is another function not shown that which merges patterns together. The problem I’m having with this is that functions of type a -> Pattern a for use with >>= can’t do that much, not being able to consider any pattern context, and not being able to return a different period depending on the input (otherwise that ‘undefined’ value would bite). This is about the most useful thing I can come up with, which ‘masks’ events every other time measure:

mask :: (a -> Pattern a)
 mask x = Pattern (n -> if n `mod` 2 == 0
                         then [x]
                         else []
                   ) 2

Maybe I should be thinking of what I could do with more general functions of type (a -> Pattern b) instead. I guess I’m just getting a better handle on what monads are really for…

Monads aside I guess my Pattern representation would really become unstuck with patterns that have a lot of interdependencies. For example if every event depended on the event preceding it then you’d have to recalculate the whole pattern all the time. Hmm.

Well that was quite an extended haskell wibble. If by some strange chance you’ve read this far I’d love to hear your thoughts and especially advice!

More hackery

June 4th, 2009

Another screencast:

Trying a lower bpm than normal. Also I’m starting to add more higher order rhythm functions to increase live coding potential… “(~> n)” shifts the pattern one beat to the right, (<~ n) to the left, and "when" allows such ops to be applied selectively depending on function over the beat number. I feel a monad coming on.

Someone on twitter wondered whether the last one was faked, I’ll take that as a compliment! As Kassen pointed out, that one was mainly just a sequencer. A polyrhythmic sequencer, with sequences for parameter values as well as samples but a sequencer nonetheless. My aim is to try to stay as simple as possible but I’m currently looking for ways of transforming sequences through live coding. This is a step towards that.

Thanks for all the source code requests, I will release the code eventually and announce it here, but might take a while… Sorry.

I might do an opendork showing this stuff at dorkbotlondon tonight. Might not be time though as we’ve got a lot of classy presentations to get though.

(UK) Stop the racists tomorrow

June 3rd, 2009

If you are in the UK and have a vote, please use it. The BNP are racists, who want all “non-indigenous” (i.e., non-white) people to leave the country. If there is a low voter turn out, they have a good chance of getting their first MEP, which means much more money for their cause and stronger links with other fascist parties in europe. That would be a disaster.

Before the current BNP leader, Nick Griffin, took charge, the BNP were openly racist. He has been working hard to clear up their image and the language they use, but that is all that has changed. He remains a racist, holocaust-denying homophobe who believes that no black or asian person could ever be described as british. Griffin considers the BNP to be “a strong, disciplined organisation with the ability to back up its slogan ‘Defend Rights for Whites’ with well-directed boots and fists. When the crunch comes power is the product of force and will, not of rational debate.”

See wikipedia articles on the BNP and Nick Griffin, and the hope not hate website including this leaflet for more info.

But most of all — please vote, for any party but the BNP! If you’re unsure who to vote for, euprofiler.eu does a good job of matching your opinions to party manifestos.

toplapuk – pubcode, London

May 26th, 2009

We’re starting regular livecoding nights in London UK, first one this Friday at the Roebuck near London Bridge from 7pm. Free entry, good beer and the best algorithms in London — drop by and see what it’s all about. I’ll be there as part of slub. More info at the toplapuk website, and the email flyer below.

++ PUBCODE ++

The first series of livecoded music events in London.

http://toplap.org/uk/

Live coding is a new direction in electronic music and video, and is
starting to get somewhere interesting. Live coders expose and rewire
the innards of software while it generates improvised music and/or
visuals. All code manipulation is projected for your pleasure.

When:
 7pm - 11pm Friday 29th May

Featuring:
 Yee-King
 (spasmic drumming)
 slub
 (ambient skiffle techno)
 Click Nilson
 (slurs, arrows, slurring)
 Pixelpusher vs The Cane Toads
 (dirty pixel raga)
 Scott Hewitt
 (patching things)

Place:
 The Roebuck
 50 Great Dover Street
 London
 SE1 4YG

Map:
 http://is.gd/CL5G

Door tax:
 Free

Tube:
 Borough (5 mins walk)
 London Bridge (9 mins walk)

More info:
 http://toplap.org/uk/

TOPLAP UK gratefully acknowledges financial support from the PRS Foundation.

Haskell hack

May 22nd, 2009

Finally off the back burner, some music in haskell.

This is very much in progress, more ideas to implement but I think it’s getting quite interesting already. Beat rotation heavily influenced by douglas.

Sensation, perception and computation

March 31st, 2009

There’s often seen to be a fight between symbolic AI and  artificial neural networks (ANNs).  The difference is between either modeling either within the grammar of a language, or through training of a network of connections between cells.  Both approaches have pros and cons, and you generally pick the approach that you think will serve you best. If you’re writing a database backed website you’ll probably use symbolic computation in general, although it’s possible that you’ll use an ANN in something like a recommendation system.

There is a third approach though, one I’ve fallen in love with and which unifies the other two.  It’s really simple, too — it’s geometry.  Of course people use geometry in their software all the time, but the point is that if you see geometry as a way of modeling things, distinct from symbols and networks, then everything becomes beautiful and simple and unified.  Well, maybe a little.

Here’s an example.  I’m eating my lunch, and take a bite.  Thousands of sensors on my tongue, my mouth and my nose measure various specialised properties of the food.  Each sensor contributes its own dimension to the data sent towards the brain.  This is mixed in with information from other modalities — for example sight and sound are also known to influence taste.  You end up having to process tens of thousands of data measurements, producing datapoints existing in tens of thousands of dimensions.  Ouch.

Somehow all these dimensions are boiled down into just a few dimensions, e.g. bitterness, saltiness, sweetness, sourness, sweetness and umami.  This is where models such as artificial neural networks thrive, in constructing low dimensional perception out of high dimensional mess.

The boiled-down dimensions of bitterness and saltiness exist in low dimensional geometry, where distance has meaning as dissimilarity.  For example it’s easy to imagine placing a bunch of foods along a saltiness scale, and comparing them accordingly.  This makes perfect sense — we know olives are saltier than satsumas not because we’ve learned and stored that as a symbolic relation, but because we’ve experienced their taste in the geometrical space of perception, and can compare our memories of the foods within that space (percepts as concepts, aha!).

So that’s the jump from the high dimensional jumble of a neural network to a low dimensional, meaningful space of geometry.  The next jump is via shape.  We can say a particular kind of taste exists as a shape in low dimensional space.  For example the archetypal taste of apple is the combination of particular sweetness, sourness, saltiness etc.  Some apples are sharper than others, and so you get a range of values along each such dimension accordingly, forming a shape in that geometry.

So there we have it — three ways of representing an apple, either symbolically with the word “apple”, as a taste within the geometry of perception, or in the high dimensional jumble of sensory input.  These are complimentary levels of representation — if we want to remember to buy an apple we’ll just write down the word, and if we want to compare two apples we’ll do it using a geometrical dimension — “this apple is a bit sweeter than that one”.

Well I think I’m treading a tightrope here between stating the obvious and being completely nonsensical, I’d be interested in hearing which way you think I’m falling.  But I think this stuff is somehow really important for programmers to think about — how does your symbolic computation relate to the geometry of perception?  I’ll try to relate this to computer music in a later blog post…

If you want to read more about this way of representing things, then please read Conceptual Spaces by Peter Gärdenfors, an excellent book which has much more detail than the summary here…

Mary Hallock-Greenewalt

March 24th, 2009

Hallock-Greenwalt at the sarabet

Hallock-Greenewalt at the sarabet

“Broadly, it is my desire to express emotions by means of timed variations of light and color in a manner analogous to that employed in the art of music. Such expression may either be for its own sake, or … as an accompaniment.”

In 1906, about 40 years after the invention of the commercial light bulb, Mary Hallock-Greenwalt (1871-1950) began work on her colour organ, the sarabet.  She was an accomplished musician, but wanted to create an equivalent artform for colour which she called nourathar (derived from the Arabic for the essense/flavour/influence of light).  Interestingly though, she came to the conclusion that colour wasn’t as important as brightness:

“In this art they, the darknesses and brightnesses, constitute the woof of the play.  They carry a chief burden of the transmitted feeling.  They also tend to make a oneness out of more than one colour, or colours, simultaneously produced.”

She was also quick to dismiss the idea of direct mappings between music and colour.

“… there is no octave to color.  color has no harmonics. … Its pristine strength is such that no two colors can fit together as identical.”

While she composed nourathar pieces to accompany music, she was against cross-domain mappings in general.

“To seek to fasten the form of one art on the form of another art, is, on the face of it, a mistake, if not an impossibility.  They are organically different things.  They will speak in different ways.”

I’m not sure if I agree with this strong claim, the human senses are integrated after all.  But I still think it insightful to reject the naive “colour scales” which others came up with — while synaesthetics can experience pitch as colour (or vice versa), I understand that no two synaesthetics experience the same scale.

An example of Hallock-Greenewalt's patented notation system

An example of Hallock-Greenewalt's patented notation system

All the quotes in this post came from Hallock-Greenewalt’s book “Nourathar: The Fine Art of Light-Color Playing”, which is a joy to read.  She was not the first colour organist, but from what I’ve seen she was the most insightful and interesting of the bunch.  Sadly however no video recordings can exist from back then, so we can only imagine what her performances could have been like, with only her notation to guide us.

I gave a quick dorkbot presentation about Mary Hallock-Greenewalt a couple of years ago, and one audience member jokingly accused me of inventing her to justify VJ culture with false history.  Well her work is well documented in her writing and patent applications, but she should certainly be better known — I recently saw a talk about colour organists which didn’t mention her, despite her huge contribution to the field.

I’ll finish this post with one last quote from the woman herself.

“Is there no expressing of fervor in the deepening of a rose to red? Can quality of ardor not be suggested in the quickness or slowness with which this transition is done?  Can zeal or eagerness not be expressed in the manner of change from blue to purple?  Are colors not “warm” or “cold”?  Is there not the fervid, the burning of intensity of feeling in the ray’s glowing into or embering back?  So much there is to choose from.”

Posted on the occasion of Ada Lovelace day 2009.

How we program

March 14th, 2009

I’ve always wondered how we do programming. Code can be so clean and straight-faced, but when you step back and try to think about how you write it, a darkness descends. It’s tempting to think that your brain is working like a computer program, transforming a symbolic problem into a textual answer as sourcecode. But I don’t think that’s what is going on at all — if problems came specified in formal language, then programming would be a very different experience. We instead start with a mess, and try to find all the problems in it through the process of designing and writing code.

There’s a lovely paper called Mental imagery in program design and visual programming by Marian Petre and Alan F. Blackwell, with many great quotes from programmers trying to introspect on their work. Here’s some tasters:

“ … it moves in my head … like dancing symbols … I can see the strings [of symbols] assemble and transform, like luminous characters suspended behind my eyelids … ”

Programming is a dance of symbols behind the eyelids. Write that into a QA standard.

“It buzzes … there are things I know by the sounds, by the textures of sound or the loudness … it’s like I hear the glitches, or I hear the bits that aren’t worked out yet … ”

This programmer is describing re-purposing their sense of hearing to produce computer software. Quick, strap them into an fMRI machine!

“values as graphs in the head … flip into a different domain … transform into a combined graph … (value against time; amplitude against frequency; amplitude against time) … ”

Hmm programming as relationships within abstract spaces, and relating those spaces to one another. A nice model for thought in general, perhaps?

“It’s like describing all the dimensions of a problem in 2D, and in the third dimension you’re putting closeness to a solution.”

Another, rather different spatial approach, where goodness of solution is somehow represented by something like height.

“ … oh, that happens over there … it’s on the horizon, so I can keep an eye on it,but I don’t really need to know … ”

Exasperating, and sums things up nicely. This kind of introspection is just too hard, so much of these thought processes are entirely sub-conscious. For example you try for hours to solve a tricky problem, give up, then the answer pops into your head while you’re cycling home, otherwise thinking about dinner.

That said, while the above evidence is purely anecdotal, it gives some hints about what might be going on. I like to think that programmers tap into a general human ability to organise a messy world into far tidier problem spaces, and find their way around such spaces in much the same way as they do when bumping around in a pitch black room…

Happy old year

March 13th, 2009

Hope your year has been good so far. I haven’t posted in a while, so here’s a quick update.

Got a nice gig coming up at strp festival in Eindhoven with Dave on the 10th April.

If you want evidence of me being alive then you can follow my twitter feed or my citeulike reading. Actually I’ve been trying to summarise my reading on twitter too although that can be tricky in 140 chars…

I’ve got a few things to turn into blog posts but that’ll do for the time being.