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.

Text on multiple lines in Pure Data

For my set for From Digbeth With Hammers at BOYD 8 I was required to display their logo on screen. This sounds like it should be a relatively easy task, but their logo consisting of four lines of text presented some interest problems.

From Digbeth With Hammers

In Pure Data there’s three objects you can use to display text on-screen: [text2d], [text3d] and [textextruded]. They have different ways of receiving text input, which I’ll get onto later, but one of the common methods that I often utilise in this scenario is by using a symbol box. In addition to receiving symbols Symbol boxes can be used to input text by just clicking on the box and typing text. Hitting Enter sends that text to its outlet. This presented a slight problem.

If you follow conventions from word-processing programs usually Enter is used to start a new line (carriage return). So, with Enter being used to send the text I had to find another solution to display text on multiple lines. Due to time contstraints I had to resort to the very messy solution of using multiple [text3d] objects.

Very messy!

This solution worked except for two things:

  • It isn’t scaleable. If I wanted to change the text by adding or removing lines I’d have to adjust the amount of text3d objects, change the spacing between each object and ensure that the size of the text still fitted on-screen. All of this is nearly impossible to do in a live setup unless you have a patient and forgiving audience!
  • It occasionally crashes. Occasionally when I would change the [depth( setting or move the whole text using [translateXYZ] the whole of Pure Data would crash. My suspicion is that the extra processing power needed to render and alter the text caused it to crash. Luckily this didn’t happen during my performance but it did result in me avoiding text manipulation.

So, what I needed was a way to insert carriage returns in Pure Data. I consulted the Pure Data mailing list and they informed me that [text3d] and [textextruded] accept ascii text as well. In ascii everything you see on-screen, from blank spaces to foreign characters and, most importantly, carriage returns, have a numerical value (10 is a carriage return). I was promptly provided a solution to my problem by typing out the band’s logo in ascii.

This worked except that, for every situation I wanted to have text, I would have to type out the text in ascii beforehand. I had no way to dynamically type out ascii. Even a suggested “asciifyer” abstraction suffered the same problem of not recognising Enter as a carriage return.

Awhile later Jonathan Wilkes showed me a solution that utilised [makefilename] to insert the carriage return! After a bit of modifying I finally had a patch that could have text on multiple lines using only one [text3d] object.

Click to download

And a video of it in action:

There still is, to my knowledge, no way of inserting a carriage return in Pure Data using only the keyboard. Also, this solution requires you to type of your text on three different symbol object boxes. Also, a space is added each time you add a new line, which is probably the result of using [add2 $1(. With that said, this solution is a step in the right direction!

Now if only I could go back in time and use it when I needed it…

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!

Voila!

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.

Vacant – Illustration Friday

This is my submission for the Illustration Friday topic, Vacant

I interpreted vacant to mean blank and with that came the image of a blank piece of paper. A blank paper is very daunting to many artists and it’s no different with me. However if I start at a paper and think long enough usually ideas just start to come out at me. I portrayed this by using very light colours for the lettering and scenery.

You may have noticed that it’s a very minimal style than what I usually do. Probably not something that will stick, but I’ll develop ways of using it.

Trash

56|400

Under some very handy advice from some wise people I’ve gone back and given all of my pieces names. Seems only right that I should name them, afterall I wouldn’t name my child ‘Untitled’! Only three more of these to go, then you’ll see some work that’s more akin to graffiti.

Untitled 5

Completed this one recently

51|400

I’m liking the way this style is going, but I want to incorporate people and other objects into it, rather than just abstract objects and text. It’s proving challenging to make the two work together, but it’ll happen with more practice 😉

Untitled 1

Completed this today.

49|400