### Audio Art Week 5: Expressive Potential of Pseudorandom Numbers

This week's Max/MSP patch. Click on the image for a larger screenshot. I'll post the patch itself later.

Computers are algorithmic machines. So, by definition, they can't generate true random numbers. There are, however, various ways of generating numbers that appear random—pseudorandom numbers. The Nintendo Entertainment System (NES), like a number of its contemporary computer systems, used a very simple device called a linear feedback shift register. In pursuit of an exploration of the expressive potential of pseudorandom noise, I implemented such a system in Max/MSP for my assignment this week.

Here's how it works: A shift register with some number of bits is initialized to a value, and shifted to the left. The values of two of the bits (stored before the shift) are XORed together and put in the slot left empty by the shift. One or more bits are then fed into a buffer (in order to generate bytes or words) or directly into a DAC. The process repeats indefinitely. An example (from my Max/MSP patch) is below.

Study #1 - 32kbit from buffer: Basic noise generated by a 15-bit linear feedback shift register. (Download)

Linear feedback shift registers are easy to implement (especially in hardware) and give numbers impressively similar to real randomness. They're not truly random, however, as they eventually produce repeating sequences. The number of bits before a sequence repeats is determined by the number of bits in the register and the precise bits XORed back into the register. The NES, for example, has two modes: one to produce a sequence that repeats every 32,767 bits, and another to produce a sequence that repeats every 93 bits.

The 93 bit mode, as you can imagine, produces a tone when played back at full speed. Example below.

Study #2 - 93 bit from buffer: Bits fed back into the shift register produce a repeating pattern of 93 bytes. (Download)

More after the jump, including my quick attempt to make a NES-like song.

The noise generation circuit in the NES was generally used for sound effects and percussion. Different timbres are achieved by changing the noise's playback frequency. (The NES limited noise frequencies to 16 different values.) In the following two examples, the noise from the linear feedback shift register is played through an envelope to create various percussive effects.

Study #3 - 32k noise: Percussive noises from the noise that repeats every 32k bits. (Download)

Study #4 - 93 bit noise: Percussive noises from the noise that repeats every 93 bits. Note how these are generally indistinguishable from the sounds in the 32kbit example above until you get into the higher frequencies. (Download)

Once I had the ability to make fairly authentic NES noise, I decided to try it out "in context." So I sampled the noises at various frequencies and with varying decay rates and sequenced a song. (The song also makes use of two square wave channels and a triangle wave channel—the only other voices that the NES supports.)

Study #5 - Quick song: Just a little demonstration of my NES noises, sampled from Max/MSP and sequenced in Schism Tracker. (Download)

Study #6 - SID noise: The Commodore 64 used a linear feedback shift register as well. According to these guys, it used a 23-bit shift register and sampled its output directly from eight bits in the register. I wrote a Perl script that simulates this kind of shift register, using the C code in the page linked above as a reference. This is an excerpt from the output of that Perl script. It's interesting to compare this to the NES noise in Study #1. (Download)

Study #7 - Audible randomness: I used my assignment from last week to make audible representations of some of the data in the examples above. The first segment in the clip is generated from the 93 bit repetition NES data; the second segment from the 32,767 bit repetition NES data; and the last segment is random values (generated in Perl). The repeating pattern of the 93 bit data is readily apparent. I don't know if the second two are all that distinguishable, however. (Download)

Part 2: Using regular expressions on audio files!

Peter suggested that we try editing sound files in text editors. I decided to be a little more programmatic and use regular expressions instead.

Study #8 - Oceans Abracadabra: This is a clip from an AIFF file of "Oceans," a song by Flying Saucer Attack. The original audiofile has been modified by a regular expression which replaced all occurences of the ASCII value 'a' with the string 'abracadabra.' A kind of interesting scratchy distortion results. (Download)

Here's the same clip from the original audio file, for reference. (Download)