Print This Post Print This Post

A Code Idea

April 28th, 2010 by Jim Andrews | Filed under -NP-Experiments, Jim Andrews

From F8MW9

When I look/listen/interact with programmed works, I look for interesting ‘code ideas’. I want to write about one I’ve just had.

But first, here is my definition of  “interesting code idea”: the programming reveals the other side. By ‘the other side’, I mean the moment of art experience. And/or Ur intersects with the quotidian, the planets align, and yer there.

Here is a code idea I just had. That has kind of been years in the making.

If you visit F8MW9 at http://vispo.com/mw/mwb002.htm , you encounter a particular type of interactive audio cutup. The voice is that of Margareta Waterman, a poet from the west coast via New York–she has a strong voice. In any case, what you encounter, by default, are random, quite short (less than a second) samples of Margareta vocalizing in a sort of Slavic scat.

You see a toolbar at the bottom. There is a number you can change. This number represents the maximum length (in milliseconds) of the samples. The samples may be shorter than this number, but they won’t be longer.

Adjust this number from 1 on up to over a second. At 1, you do not hear a human voice. The samples are too short. At 50 you hear what almost sounds like scrambled radio voices. At 100 you hear fractured parts of phonemes. And so on.

Don’t worry, we’re getting to the code idea. If you listen to F8MW9, you hear that the samples aren’t quite random. There is some non-random repetition. Sometimes a particular sample plays more than once consecutively. Which, in itself, is not non-random behaviour. But the frequency of these repetitions is non-random. It isn’t particularly patterned, but you can hear that the repetition is not what you would expect were the samples drawn randomly from the entire waveform/sound.

We’re still not at the new code idea. But we’re into the notion of flexible structures built from random samples. In F8MW9, when it’s time to play a new sample, what happens is that the decision about where to start sampling (and the duration of the sample) are random decisions that, nonetheless, have structure.

What structure? In F8MW9, the sample starts randomly with probability .9 or so. Otherwise, the sample starts where it did last time. This means that about one time in ten, we will hear a sample loop. And sometimes it will loop again–and whether it does is differently conditional on whether it did last time.

OK, so we have a bit of structure. Looping sometimes changes the sound into something with more pleasing pattern and, consequently, variety than a purely random sampling from any sound. Clearly, however, that is just the tip of the iceberg in terms of what is possible with creating patterned–but not too patterned–sound from random samples.

And now we’re at the point where I can tell you the interesting code idea.

In the code for F8MW9, let us maintain a list of the last 8 samples. When it’s time to play a new sample, we do some conditional probability to make the decision as to which of the 9 possibilities goes next. 8 of the possibilities are those 8 previous samples. the other possibility is we draw randomly from the entire waveform/sound.

This way, the previous 8 samples form a kind of sonic scale, though the ‘notes’ are not arranged in pitch. And the patterns that  form, such as 2,4,6,8,6,8,4,2, can be probabilistically shaped.

And sometimes we will replace one of the ‘notes’ with a new sample.

Conditional probability is of course something that is oft used in programming to make decisions. And there’s a whole mathematical theory of conditional probability, and that’s useful to draw on. A sequence of events is said to be ‘stochastic’ when what happens next depends on what what is happening now–and possibly also on what has already happened. Markhov chains are such stochastic sequences of events, and there’s a whole well-developed mathematical theory for generating probabilistic sequences of events (notes) that depend on what is happening now–but not coercing the events so much that they become too predictable.

So that we can make interesting patterns from random sampling, but not so patterned that they slip into–and stay–in the quotidian.

This way, the planets may align for a moment, slipping into the moment of art, yer there, and it’s gone. The other side.

This is Insane
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
tag_icon

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a comment.

To leave a comment, please fill in the fields below.