Five Days of Pure Data – Randomise Text

In the years that I’ve been creating things in Pure Data I have amassed quite a collection of unfinished and messy patches. Over the next few days I’ll be releasing a few of these patches and techniques that I implement when programming in Pure Data.

Randomise Text

In the early 2010s I had quite an interest in zines. I had co-organised the Birmingham Zine Festival and was quite regularly reading this. As a result of this in 2011 I started collaborating with a friend, Rebecca Evans, on a collaborative zine. The concept is that we would interpret each others’ way of working using our regularly used tools. Rebecca specialises in textiles and has quite a skill at crocheting, amongst other things. I, on the other hand, can barely operate a sewing machine and feel much more at home using a soldering iron or computer.

For Rebecca this meant trying to create some sense of noise and randomness but using sewing. The results, even if only tests, looked quite awesome!

For my own take on this I wanted to continue the text based work that I was creating at the time. Rebecca two poems to work with, Lovesong by Ted Hughes and Lady Lazarus by Sylvia Plath.

I wanted to remix the works by jumbling the words and/or sentences. Looking at recent(ish) work you can see that this would become a bit of a theme in my work and references. spɛl ænd spik, Silver Screen Changeable, and my reinterpretation of Variations on a Themeby Casey & Finch by Erik Bünger each look at cutting up and rearranging words.

Cutting up words and rearranging them can be achieved in many languages using just a few lines of code. One method is to put each word or sentence into an array and then print those indexes in the array randomly. In Pure Data it isn’t as easy.

For most cases Pure Data has the [tabread] and [tabwrite] objects. To use [tabwrite] you specify the index and then write data to it. You then move onto the next index number and write more data to it. To read the data back you do the inverse but with [tabread]. This works great with numbers but not with text.

Y’see, Pure Data has several data types. Just like php, python and others have strings, numbers, text, etc, Pure Data has symbols, floats, integers etc. The character “6”, for example could be a number (default) or a symbol – using a combination of a number box, [floattosymbol] and then a symbol box. As a number it can be used in arithmetic operations, as a symbol it’s good for when you don’t want it to be treated as a number. The unfortunate thing for me/us is that [tabread/write] doesn’t accept symbols, only numbers. Damn! Enter [m_symbolarray] from rjlib.

Using this abstractions you can put symbols into an array in the same way as numbers. With that problem solved I now could decide whether I wanted to jumble words or sentences. In the former case it would be unlikely to return anything that makes sense, which is ok. In the latter case it could still produce interesting results that could fool some people into thinking it was as it should appear. So, it was important to have the option to do both.

Using [textfile] you can specify what a delimiter is. A delimiter specifies where one list item stops. By default [textfile] uses a space as a delimiter. By sending the message [read textfile.txt cr( to [textfile] I can tell it to use a carriage return (Enter key) as a delimiter. Unfortunately there isn’t great documentation on what the others are!

Using the [until] object and a carefully crafted series of operations I crafted a patch to do the following: Decide on delimiter, read the text file, output each list item to the m_symbolarray object, cycle through text file and do this until we reach the end of a text file.

With the table now populated here’s where the interactive part comes in. A user could decide to either dump the contents of the array into a text file or spit out each item to, say, a [text] object for displaying on a screen.

You can download the finished patch below:

Below are my remixes of the two poems for you to download:

it’s a shame that the zine was never finished but it was still a great learning experience.

I’m sure that by now the relatively new [text] object can solve many of the problems I had using [textfile] to read the file, so perhaps at some point in the future there will be an update.

Pure Data File Killer

On one of my frequent journeys on the information superhighway I stumbled across Little-Scale’s Mass JPG Killer. This handy little patch allows a user to load any binary file and “glitch” it by overwriting some of the original data with a repeating pattern of user-defined data.

Mass JPG Killer by Little-Scale

The only problem (for me and people like me) is that I don’t have Max/MSP and can’t install it on Linux, meaning I’ve never actually used it!

Little-Scale very kindly provided the internet at large with screenshots of the inner workings of the patch. I was able to to use a whole lot of science and maths to rewrite and reinterpret this patch of mass destruction in Pure Data, which is more easily available.

Pure Data File Killer

Click to download

Click to download

Usage

Usage of the patch is very simple and can yield some quite interesting results!

  • Click open to load a binary file. Pure Data may freeze for a moment if you’re loading in a large file. I don’t recommend loading in a file over 100MB
  • Set the byte offset. This number represents the starting point at which the patch will start “corrupting” the file. If you’re a glitchspert (glitch + expert) you’ll remember that you should avoid modifying the header. To avoid modifying the header set the offset to the 1000s.
  • Set the period value. This can be hard to understand, so here’s an example: If the period is set 1378 then at intervals of 1378 bytes from the offset it will modify the data.
  • Set the data value. This works in conjunction with the period value. Using the previous example, if the data is set to 102 then at intervals of 1378 bytes it will replace the current byte value with 102.
  • Press either random period or random byte data to populate these values with random values.
  • Press glitch it!. Guess what that does.
  • Write the files to save them to the same directory as the source file. The original file will not be overwritten.
  • To start again press the reset button. It will load the original byte data.

This patch is very similar to Little-Scale’s with a couple of exceptions:

  • The offset cannot be set for each instance. This is by design as I felt it was a bit redundant.
  • You no longer need to copy the hex data to a new file in order to view the results
  • It’ll work on any platform that can run a full version Pure Data Extended. This should include the Raspberry Pi version as GEM is not required.

Output

Although it was originally inspired by the JPG Killer you can get some very interesting results if you use other file formats and set the period data to a number less than 20.

Pure Data File Killer - Bliss (sgi)

Pure Data File Killer - Bliss (jpg)

Pure Data File Killer - Bliss (pix)

Pure Data File Killer - Bliss (pix)

From Digbeth With Hammers at BOYD 8

Since November 2011 I’ve been providing visuals for First Fold Records’ monthly Bring Out Your Dead (BOYD) events. This sees me working with the headline acts to create visuals tailored to their performance. I often do a recording of the sets, which you can see on my YouTube channel.

For BOYD 8 I did visuals for local band From Digbeth With Hammers. The band said they wanted any visuals that included “bricks and concrete and things that look like they’ve been hit with massive hammers.” So, I got them lots of videos of explosions, demolition sites and cranes 😉 Here’s a sample of the visuals that I did set to the “Collage” track available from their website

Their set on the night was much louder than this track and was overall really awesome. That night also saw me try out a few new techniques in Pure data.

From Digbeth With Hammers for BOYD 8

In addition to using the [newWave] object as my plane for displaying videos I utilised feedback loops and the red/green 3D display mode (made by sending [stereo 3( to [gemwin]).

From Digbeth With Hammers

Old-school 3D!

Perhaps the biggest change was my use of the keyboard for controlling visuals. The mouse is a great input device but it doesn’t lend itself to rapid responsiveness. In past performances I’ve often found myself reacting to the visuals a second later due to having to scroll my mouse over the patch to find the right button to press. Being able to press a key is so much quicker!

The next BOYD night is on 7th June

Feedback Loops in Pure Data

Recently I’ve been making a few video loops for Dreambait Recordings to use in their shows. The videos, made using video samples and Pure Data, focus on feedback loops. For BYOB Birmingham on Friday 16th March I decided to showcase these video feedbcak creations. Some photos of it in action:

BYOB Birmingham

BYOB Birmingham Flatpack Festival 2012

Photo by minuek

The Pure Data patch used to make these visuals, inspired by this patch is pretty simple: Put an object on screen, take a snapshot of the screen and then apply that snapshot as a texture to another object. You can download it below

Feedback Loops patch

Click to download

As a texture for the cube I used the Skin Cells video again. You could replace this with any video, image or webcam feed. The [pix_contrast] object is there purely to provide an over-saturated look (try bringing Saturation to a negative number). For BYOB I automated the controls by using random number generators (feeding [random] into [metro]). Here’s a render of what the audience saw:

All that is needed now is some cool audio to go with it! Thanks to all those that came to BYOB to see this and other awesome artworks!

Alpha Glitch

For my performance with Freecode as part of Network Music Festival I wanted to move away from producing visuals that consisted mostly of video playback and move towards generative art. Demos of this were posted on my Flickr site, and the first performance that utilised this new approach happened on 26th January

The feedback from people online and at the performance was really positive, with a lot of people were asking how to do something similar. The patch I made for it was very messy so I (albeit slowly) remade part of the patch that achieves that effect. It’s available for download below

Alpha Glitch

Click to Download

This isn’t strictly a generative patch as it still relies on an source image/video as a texture, but I think it’s more generative than it is video playback. The patch, made in Pure Data, works first by using [repeat] to generate many cubes which are zooming towards the screen. These, then, are textured with an image of your choice. The “magic” comes in the use of [pix_alpha]. The red, green and blue sliders remove a percentage of that colour from the image texturing the cubes, revealing the cube below. The green toggle button randomly removes a different percentage of each colour at different speeds. This, coupled with the constant movement of the cubes I think creates a sort of animated glitch using only a still image.

Sound confusing? Hopefully it’ll become clearer once you dissect the patch and view the help patches of each object. Here’s an example of the output from this patch using this image from my Skin Cells video:

If you know Pure Data well you can modify the patch so that it uses videos or a webcam feed instead of a still image. However, be aware that having that many objects on screen with a video stream can cause the output to be stuttery. This patch was made with Pure Data Extended 0.43 on Ubuntu 11.10.