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 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 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.

Inkscape tutorial: text manipulation

I’ve been messing around with Inkscape a lot recently and have found a few cool tricks. This all originally started as an attempt to recreate an effect I saw on the Inkscape website but quickly evolved into something different.

Here’s an example of the output I achieved.

Something I did earlier

Something I did earlier

What’s interesting about this is that it’s mostly the work of filters. For this tutorial we’ll be working with text in Inkscape 0.47pre0. To illustrate things better use a font that is very think. Even Arial Black will do. Create two different text objects

The original unmodified text

The original unmodified text

The manipulations we’re going to apply to this text will be affecting paths, so we need to convert this text to a path. To do this go to either Path > Object to path or press Ctrl + Shift + C. This separates the text into individual paths as a group. Ungroup them (Object > Ungroup or Ctrl + Shift + G) and then combine them as a single path using Ctrl + K. Next, position the text wherever you want it.

We want to create an extrude between to the two paths. For this you need two separate paths (you created these when you created the text). Click on both of them and then go to Extensions > Generate from path > Extrude.

Extrude window

Clicking on Lines will attempt to link each node of one path to the node of another path with just lines, whereas clicking Polygons will do something similar but link them with shapes. Click on Polygons then press Apply.

Text with extrude effect applied

Text with extrude effect applied

With the new polygons selected pick a hue for it. The reason I specify hue is because we’re going to be modifying the colour next and the filters we will be using will work with the current hue and modify it. As far as I’m aware it can’t modify shades i.e. black or white.

Colour on the extrude effect

Click on Extensions > Color > Randomise.

Randomise extension window

Randomise extension window

From this window you have several choices. Randomising the Hue lets you have random colours. Randomising the Saturation will randomise the saturation i.e. if it’s a very vibrant colour or slightly dull. Randomising the Lightness will randomise the brightness i.e. if it is completely bright it will go white, if not it will go black. For this I recommend randomising the Saturation and Lightness. To get a preview of the output check the Live Preview option. If you’re not happy with the combination they’ve given you uncheck then recheck the Live Preview. Press Apply when you’re done.

Finished text

For a finishing touch add a background and change the stroke colour

Completely finished!

Completely finished!


What else can be done with this effect? Well, you know that you need two different objects for this to work, so why not work with one object but then split it into two. In the example below I split a rounded square into two shapes then repeated this procedure.

Stained glass square

Stained glass square

One thing to note is that the more nodes you have the more polygons that will be created

I hope this tutorial has been useful. To extend this try messing around with the Jitter Nodes effect under Generate from Path 😉 For more of my experiments feel free to check out my flickr stream.