## Patterns are the time of numbers

Ok this post is going to look quite dry, but is actually very exciting, at least for users of TidalCycles. So first here’s a video demonstrating the simplified syntax the below blurb will allow in a future version (version 1.0, which will probably be released soon after the upcoming 0.9).

If you want to see more videos like this check the playlists on the TidalCycles youtube channel.

Anyway.. Something I’ve noticed at Tidal workshops is that beginners have problems with this sort of code:
`density 2 "1 2 3 4"`
There’s the pattern `1 2 3 4`, denoted by quotes, and the number `2` without quotes. This says ‘make the pattern twice as dense’, so you end up with this every cycle: `1 2 3 4 1 2 3 4`.

Fairly straightforward, but why is the `2` a number, not a pattern? With more complicated, higher-order patterns this becomes increasingly unclear. There are ways to treat that number like a pattern:

`spread' (density) "2 5" \$ "1 2 3 4"`
or ..
`do n <- "2 5"`
`   density n "1 2 3 4"`

… but now you’re converting between numbers and patterns of numbers instead of engaging with the music you’re making.

So I asked about this on haskell-art, in particular how to make it so a function like `density` could take either a number, or a pattern of numbers. One suggestion from Henning Thielemann was surprising – that Tidal’s `Pattern` type could be defined as a Haskell `Num`ber.

To cut this short it turned out that simply by evaluating a small amount of very simple code[1], Tidal’s syntax suddenly becomes far more expressive.

`d1 \$ sound "bass3" # speed "1.2"`

you can just do
`d1 \$ sound "bass3" # speed 1.2`

`d1 \$ sound "bass3*4" # speed (scale 1.2 3.2 \$ ((+) <\$> (slow 4 tri1) <*> sine1))`
you can just do:
`d1 \$ sound "bass3*4" # speed ((slow 4 tri1) + sine1 * 2 + 1.2)`

`d1 \$ up (every 3 ((+12) <\$>) "1 8 [7 ~ 4]") # sound "bd"`
it’s simply:
`d1 \$ up (every 3 (+12) "1 8 [7 ~ 4]") # sound "bd"`
and with a quick re-jig of the definition of functions like `density`:

`d1 \$ n ((+) <\$> ((+) <\$> "1 2 3" <*> slow 3 "0 1") <*> slow 2 "3 1") # sound "voodoo"`
it’s:
`d1 \$ n ("1 2 3" + slow 3 "0 1" + slow 2 "3 1") # sound "voodoo"`

and much more…

By redefining `density` and friends, e.g.:

`let density tp p = unwrap \$ (\tv -> withResultTime (/ tv) \$ withQueryTime (* tv) p) <\$> tp`

It’s then possible to fulfil my original aim:

`d1 \$ density "1 [2 3] [1 3]/2" \$ sound "bd [sn:2 mt]/2"`
while still supporting the original syntax:
`d1 \$ density 1.5 \$ sound "bd [sn:2 mt]/2"`

Basically, it turns out that if you let Haskell treat patterns of numbers as numbers, it provides extremely expressive means for working with them. This makes sense — patterns of numbers are numbers, just numbers which are polyphonic, and vary over (rational) time.

Lovely. This is a huge and unexpected win, which greatly simplifies pattern combination and manipulation, in the process greatly extending the possibilities that are within reach of a few keystrokes. This renews my suspicion that Haskell is full of much wondrous stuff just waiting to be discovered..

[1] Here’s that ‘small amount of very simple code’, if you want to try this at home:

```instance Num a => Num (Pattern a) where negate = fmap negate (+) = liftA2 (+) (*) = liftA2 (*) fromInteger = pure . fromInteger abs = fmap abs signum = fmap signum```

```instance (Fractional a) => Fractional (Pattern a) where fromRational = pure . fromRational (/) = liftA2 (/)```

## Pattern Recognition

Text from an interview in the March 2016 issue of The Wire magazine with Emily Bick. I encourage you to subscribe!

The scene at an algorave is often what you’d expect from any good techno night – a dark room, engaging visuals, a decent, bass-heavy speaker set-up, and lots of people ready to dance. Except instead of a DJ up in a booth, or a producer tapping away behind a glowing Apple logo, performers at algoraves respond to each other and the audience in real time, often projecting the lines of code onto the walls as they type. lt’s coding as improvisation and experiment, and over the last decade and a half this kind of live coding has become increasingly visible, popping up at dedicated club nights and festivals around the world including Sonar, Ars Electronica and Transmediale.

Now Alex McLean, a research fellow in human/technology interfaces at Leeds University and one of the instigators of algoraves, has been chosen as the Open Data Institute’s first sound artist in residence, in association with Sound And Music. He had been working with live coding since 2000, when he met Adrian Ward, one of his partners in the long-running live coding ensemble Slub. “We didn’t really know what we were doing, we just had this idea of somehow wantıng to make music with programming languages. We all llstened to Autechre, and at the time the idea of the creative coder wasn’t…” he shrugs, continuing, “programmers were seen as people who implemented designs.”

Ward was doing a media arts course in Plymouth where he was introduced to generative music, “He started making his own software to generate his music, and just leaving it running on stage.” says McLean, “but when we met up in London, and started first talking about bringing this live, there was a new version of [the computer music language] Supercollider which allowed live coding, and also a new language. ChucK, came out in the States. It just seemed like there was a moment where everyone – OK, not everyone, a really small group of strange people – thought it would be a really good idea to start making systems for writing live code to make music.”

Tidal – unrelated to a certain Jay-Z connected music streaming service – is the open-source language that McLean created to allow quick- response improvisation, now used by hundreds of musicians around the world. “I felt the need to develop something that was more immediate, because I was working with percussionists and finding that it would take several minutes before I could make a sound.” Tidal uses simple, one-word commands to apply functions to a pattern, and can link several computers over a local network to sync to a control pulse.

Watching him work, chopping and changing the lines of code that controls his loops by changing a number or adding a word to change a function, is like watching a graphic designer who has memorised keyboard shortcuts and can transform an image in seconds. Complexity emerges from simple instructions. With a few keystrokes, McLean transforms an arpeggio and a simple set of beats into complex polyrhythms that pan in decaying arcs across speakers. He granulates sound patterns and reverses them, and creates blobby, queasy Aphex Twin-style textures before switching up samples to produce something nasty and sputtering, like the filthiest work of The Bug. It’s pure concentration and flow, and in an algorave setting it can throw up quite a few surprises.

As well as other coders. McLean performs with musicians who play traditional instruments, as well as live artists and choreographers. But successful improvisation depends on communication between players – and how does this square with the concentration needed to live code? He describes watching a video of a performance with collaborator Matthew Yee King, in their group Canute: “We’re next to each other on the stage, and there’s quite a lot of points where I’m iooking at him, and that performance was, I think, quite possibly the best I’ve done. There’s a lot of points where we both finish at the same time, just somehow communicate an episode so we time it and change, which has been quite rare for me.”

This kind of rapport becomes more difficuit when working with choreographers or performance artists.  He did another piece with the performance artist Suzanne Palzer, where she stepped on and off a platform. Her movement off the piatform caused the screen showing his code to go biank, and it would light up again when she stepped back on. She was, McLean says “trying to interrupt and interfere – and I was trying to remember where my code was! Suzanne’s work is about digital art but without computers, just these off and on movements.”

Apart from its use in improvising music. Tidal can be used to apply functions to patterns of any kind, not only sound. McLean will be working with the Open Data Institute to take aspects of large public data sets and represent them in new ways. In one of his academic papers that explains the pattern functions of Tidal, McLean uses visual representations – coloured blocks layered in rows to demonstrate the effects of functions on the code.

His examples look like knitting patterns, and another of his collaborative projects explores weaving. “The idea is to try to represent the weaves with code – and there are all of these problems.” he says, discussing everything from the three-dimensional nature and tactile properties of different materials to the ‘edge problem’ – many commercial textile software programmes ignore the edge of the fabric. “People think of code as being really complicated, and weaving as really simple and repetitive, but when you actually look at weaving, it’s incredibly complex.” He gives workshops to introduce non-coders to Tidal, and “people who haven’t programmed anything before start making music together in a couple of hours”, he says, smiling. “It’s kind of on the level of understanding knitting patterns or something like that.”

Emily Bick

## Miserablism

(a thought in progress..)

Like many I’ve been preoccupied with thoughts about the writing of Mark Fisher, and his untimely death. As Nathan Jones put it, “Mark Fisher was a giant. Such a cruel irony that the man who so eloquently and honestly articulated the links between mental health, politics and economics would be taken from us like this, at this time.”

It’s OK to be unsatisfied with the way things are going, culturally, politically.

I’m starting to think about the next AlgoMech festival, and Peter Rollings got in touch about his Experimental Sonic Machines. He doesn’t have a website, but intrigued, I searched out this documentary someone had made about his machines and street performances:

I can’t really summarise this, it has to be watched. The work with found materials, the open, reflective approach to creativity, the machines, the self-deprecation against the startling, edgy music.. I love it.

There’s more videos on youtube, footage of some pretty amazing looking performances and constructions.. and also Rollings appearing on Britain’s got talent. From the start it’s stomach churning, childish playground bullying, mocking someone because they don’t fit with sickly, oppressive norms. After the previous video, it’s a miserable experience. Adds something to the classically-Guardian headline “Is Simon Cowell to blame for the end of western civilisation?

How can we strip away this awful, retrogressive misery, and make space for genuinely new culture+ideas to emerge? On this tip, it’s good to hear that Alexandra Cardenas is taking her live coding to street performances, like Rollings, finding public space to try new things out.

I’ll leave you with this from Fisher:

## Algorave article on MixMag.net w/ yaxu mix

Here’s a thing, a lovely article on Algorave on mixmag.net, by Steph Kretowicz..

Among interviews with a range of nice folks it includes some words by me as well as this mix that I mentioned in an earlier post:

I really enjoyed making the mix – a real pleasure to get close to the music, and although I am very rusty (and last time was mixing vinyl), it still felt like a different way of listening, I’ve missed it. It was good also to bring such nice music together, looking forward to doing more of these.

## Yaxu + Rituals @ Idle Chatter

Another video I forgot to post here, this one from Idle Chatter back in October 2016, with RITUALS aka Dan Hett on visuals

## Live coding

I’m starting to blog on Medium, here’s a crosspost of an introductory post:

### Live coding

From around the year 2000, musicians, visual artists and choreographers have been popping up around the world to form a community of live coders. This community uses programming languages to create live work, predominantly in the performing arts. This idea appeared from different places in various flavours, such as just-in-time programming and on-the-fly programming, although the term live coding has became standard.

Patchwork portrait of seminal live coding band Powerbooks Unplugged (2004-),
film by Jonas Hummel (2010)

But, liveness and code form an unlikely friendship. On one side, liveness is about direct, unmediated connection, in the moment. On the other, code is about abstraction, generalisation, procedures to be replayed across different timespans and media. From this perspective live coding is almost oxmoronic — liveness is about now, code is about whenever. It is no wonder that many live coders purposefully embrace error and failure — their practice runs against our understanding of what code is for.

ALGOBABEZ at Algorave Leeds, 2016

But when we write code not to make reuseable software, but to create in the moment, it takes on a very different quality, something closer to the embodied experience of speech. Live coders can work across networks or across disciplinary boundaries, pushing against the distinction between natural and computer languages.

Shared Buffer (Alexandra Cardenas, David Ogborn, Eldad Tsabary, Alex McLean)
@ Pikselfest Norway, 2014

Live coding has developed and grown over the past 17 years into a thriving, international community, meeting to create symposia [1,2], festivals [1,2], conferences, concerts and long nights of techno. All these performances involve the act of computer programming as performance: instructions are written and modified by a human while a computer executes them. Proclaiming “show us your screens”, live coders open up the developing structure and movement behind their work by projecting their screens, so the audience can experience the code grow alongside the development of its output.

Study in Keith, Andrew Sorensen

The experience of live coding is a strange one. Locked in a state of creative flow, working in a world made entirely of symbols, words and text, while simultaneously hyper-aware of the passing of time, and of the sound generated from the composition of those symbols. Hearing is a sense of touch, a way to feel the code. This is amplified further by the presence of others in the room, whose expectations you play with and respond to.

Kindohm @ ICLC 2016, Hamilton

Live coding isn’t a genre, or a set of tools, but a community of diverse practices, rolling back history to look for paths not taken — stripping back the graphical user interface to find the language machine underneath. Then, not using the language to describe already-made designs but to explore live thought, externalised through language.

REPL Electric — The Stars

I’ve ‘deactivated’ my facebook page, for the usual reasons – the inability to actually share things with people without being filtered out, privacy concerns, general lack of transparancy and annoyance. It’s a pretty strange process, a bit like changing your ADSL provider, where the site proposes various arguments for why you should stay, puts you on guilt trips about the people who will miss you, etc.

Then when it’s finally done it turns out that all you’ve really done is the equivalent to blocking all your friends. If they go to your page it will pretty much look like you’ve blocked them, harsh! There’s no way of leaving a ‘I’m taking a break’ message or anything like that. So this is the main reason for this (fairly boring, sorry) blog post, to let you know that I haven’t blocked you on facebook!

It’s also extemely easy to re-activate your account – you just log back in and you’re insta-restored.. So quite a lot of friction to leave, and none whatsoever to return.

There are alternative ways of deactivation, as kindohm pointed out on the twitter, you can just unfollow everyone and everything. I found some tips here that make this easy, it’s a nice way of deactivating on your own terms, not facebook’s.. But still it wasn’t quite enough for me, so I’ve gone the official route.

I haven’t decided whether I’ll return or not, but in the meantime you can find me on the TOPLAP slack, twitter, send me an email, or drop by to chat in person either at Access Space labs on Fitzalan Square in Sheffield UK, or Deutsches Museum in Munich DE, or somewhere between..

Update – started getting people asking why I’d unfriended them so reverted to the Hodnick method, reactivated but not following anything. Harumph.

## Cyclic visualiser

Something I did ages ago on a residency, made a video a while back but forgot to put it here, here it is:

## Tidalbot

On xmas eve I made a bot

The source is here. It’s been a little unstable (any tips for running the jack audio subsystem on a virtual server?) but generally works well. There have been some nice patterns coming up, a random selection:

Then some mystery person (or bot) made a bot called tidalbotbot that is generating patterns for tidalbot, e.g.:

We’ve been meaning to include examples in the tidalcycles docs for a while, should get around to this.. Also planning on a tidal pattern sharing website, which could interface nicely with tidalbot. More soon!

## Musicbox controller

For upcoming collaborations with musicbox maestro David Littler, and to explore data input to Tidal as part of my ODI residency, I wanted to use one of these paper tape-driven mechanical music boxes as a controller interface:

You can see from the photo that I have quite a messy kitchen. Also that I’ve screwed the musicbox onto a handmade box (laser cut at the ever-wondrous Access Space). The cable coming out of it leads to a webcam mounted inside the box, that is peeking up through a hole underneath the paper as it emerges from the music box. With a spot of hacked-together python opencv code, here is the view from the webcam and the notes it sees:

Now I just need to feed the notes into Tidal, and use them to feed into live coded patterns. Should be good enough for upcoming performances with David tonight at a semi-private “Digital Folk” event at Access Space and another tomorrow in London at the ODI lunchtime lecture.

By the way the music in the above was made by my Son and I clipping out holes more or less at random. The resulting tune has really grown on me, though!

UPDATE – first live coding experiment: