Forums > MaxMSP

coll / text: randomly placing blanks among words

Jul 21 2010 | 9:10 am


I want to randomly place blanks among words (eventually used as prints for an art campaign) – which, of course, would take ages if taken care of manually:

julien donkey boy
j ulien don key boy
julien donke y b oy
juli en d onkey bo y
ju lien donkey b oy
julie n don key boy


my approach doesn’t work out at all. any better solutions?



— Pasted Max Patch, click to expand. —
Jul 21 2010 | 12:19 pm

To fix the [pack] problem in your patch you would have to string together multiple [zl join] objects but this doesn’t scale well if you want to use more and more words.

Here’s an example which does some of the string processing in javascript via [jstrigger] which will work for any number of words. It will either leave the word unchanged or put in one random space, just like in your example. It would be possible to have some sort of "extra spaces per letter" setting where longer words might contain more spaces than shorter ones. I hope it helps.


-- Pasted Max Patch, click to expand. --

Jul 21 2010 | 12:48 pm

sheesh, thanks a bunch, luke..!

haven’t worked with java objects yet -only used to jam some java back when I had a website-, so your approach is fairly new to me (and exciting)..!

the last hour I worked on a quite more cumbersome way of dealing with the blanks: "automation" in letting my blanks wander amongst my words from left to right, separating two letters at a time, taking care of the actual work in my initial patch

thanks for taking your time & sharing.. (concise and effective patches give me goose bumps)

all the best!


— Pasted Max Patch, click to expand. —
Jul 21 2010 | 1:09 pm

I was thinking if this it can be possible to do it in ina sound file? Add silences in a waveform~…..


Jul 21 2010 | 2:15 pm

The Jasch object library has some great externals for modifying strings. They might be worth looking at.


Jul 23 2010 | 4:51 pm

Another way to do it:

-- Pasted Max Patch, click to expand. --

Jul 23 2010 | 5:06 pm

thanks for your attempt, stefan! I wish it’d been that easy..

but what I was looking for was 1 blank per word (at most) for each cycle/bang.. so luke’s version does exactly suite my purpose..

in your patch, with each bang you’ll possibly find several blanks in a word

but thanks anyways..! (for I’m still curious about wether this can be achieved without java – although I have NOTHING against java..!)

all the best


Jul 23 2010 | 6:11 pm

Download the Jasch bundle I linked to and you can use [strlen] and [strrcut] to replace the javascript bits.


-- Pasted Max Patch, click to expand. --

Jul 23 2010 | 7:07 pm

@ritmloco: silences in a waveform~ can be done with peek~, but how you determine where to put them is up to you (as is everything!)

@flim: java != javascript
so js != mxj in Max.

javascript is a confusing nickname for the language, which is an implementation of "ECMAScript", and is unrelated to Java. But everyone knows it as "Javascript", so there you go…

more info, found on the best Web-programming resource site I’ve ever seen:

Jul 23 2010 | 7:18 pm

alright! :)

Jul 24 2010 | 12:05 am

Ok guys! thanks luke and seejayjames for your advice!!

Aug 09 2010 | 1:45 pm

oops. how do I cope with sentences (respectively with the usage of punctuation marks as comma)?

I’ve tried it with
"sentence" (message)
[sprintf symout %s]

but only got "weird" results.



Aug 12 2010 | 10:34 am

in the end I went for your version, Luke, for Jasch’s [strlen] and [strrcut] generate spaces even at the beginnings and at the ends of my words (causing double spaces between words).

I’m still seeking for a solution when it comes to the usage of punctuation marks as commas etc (going for sentences).. hence I’m torn between Stefan’s approach, when using quotation marks (allowing commas etc – although its adjacent letters appear sticky) and Luke’s nicely working js solution (which does exactly what I asked for)..

hybrid hints appreciated..!

all the best


-- Pasted Max Patch, click to expand. --
Aug 22 2010 | 7:19 pm

My proposal was meant as a starting point. In Max you can achieve anything you need…
Another attempt:

-- Pasted Max Patch, click to expand. --

Viewing 14 posts - 1 through 14 (of 14 total)

Forums > MaxMSP