Articles

Rewire 3: Subversion with ReWire

The ReWire concepts we've discussed in the previous ReWire articles were based on the typical needs of most users -- piping information between Max/MSP and a ReWire host or client application. However, ReWire can also be used to take otherwise upstanding audio applications and use them for unconventional purposes. The key to this is the hostcontrol~ object, which allows a Max patch to exert control over the transport of the ReWire host. Combining this with some common Max techniques can turn the most staid audio app into a subservient audio zombie.

Tutorials in this series:

I would be remiss if I didn't point out one important issue: different hosts will react differently to "interesting" ReWire manipulation. Some will take all data and either use it or ignore it. Others might choose to crash rather than accept your changes. If you are planning to use any of these techniques in military applications (or even a live show), you should test, test and retest to make sure what you want to do is acceptable to the host you are using.

Games with Transport and Location

I've become a Logic-head of late, so I will be using Logic as the example host for my ReWire manipulation. I've created a simple MIDI-based sequence, and I'm going to start my subversive behavior by using some random techniques to alter the start/stop and location information. The sequence is mostly short staccato notes with a few legato melody phrases, and uses Logic's built-in synthesizers to do playback. There is also a nice delay/reverb effect setup to keep things ringing for a while.

My first iteration of the patch will just randomly start and stop the transport based on some generated numbers. For this, we send the pause and resume messages. Rather than getting into extensive probability programming, I'll just randomize between 0 and 5, then only pay attention to the numbers 0 and 1. Any number other than 0 or 1 will be ignored by the patch - meaning that there will be no change in the transport state.

This is all great fun, but it is a pretty unsophisticated process. I would like the system to hop around the sequence as well as starting and stopping. This is where location support comes into play. The second iteration of my patch includes a change to the current location using the seek message.

In order to understand location manipulation, you need to understand the timing mechanism that our ReWire connection is using. Most sequencing systems use a PPQ (pulse-per-quarter note) mechanism, where some number of pulses (often called ticks) occur at regular timing over the duration of a quarter note. The timing that our ReWire driver uses is very simple - it uses only one pulse per quarter note as its most granular time reference. This means that we only have the opportunity to move through the host sequence in quarter note increments.

This is why the random range used for the seek message is 120 - because the sequence is 30 measures long, and in 4/4 time. With four quarter notes per measure, and 30 measures in the sequence, we have 120 quarter notes to work with. Since the beginning of the sequence is pulse 0, we really need to jump between 0 and 119. Using the random 120 object is perfect for exactly this range.

In order to get more jumping than starting and stopping, we extend the range of random number that are used, and also extend the range of numbers that will generate a seek message. We can also force any change in the location to generate a resume message, since we will want to hear the change in location even if the transport is pause. In this case, we will hear many more location changes than starts and stops.

Games with Loop Points

In order to add a little spice to our playback, we can also manipulate the loop range of the sequence. This works well with slower changes, and requires a little thinking ahead. We will want to set the loop start point within a useful range (0-116 pulses), and will want to have the loop end point to be greater than the start point. We do this by calculating the start point, then adding between one and four quarter notes to create a valid (but short) loop range.

We again change the probabilities of message generation by using different results from the random number creation. We also add a connection from the loop generator to the seek message. This forces a change in loop position to cause the playback location to move to the loop start point.

Games with Tempo

Playing the above patch, we find that the result is pretty interesting, offering some cycling without boring us with a too repetitive playback routine. However, the tempo is static, giving us sort of a four-square sound. It's time to add a little tempo manipulation to the mix using the bpm message.

A new random number range is used to generate useful tempos. In the case of Logic, there is some sensitivity to extremely fast and slow tempos, so I keep the range within sensible parameters (60 to 240 bpm). Also, I don't want the tempo to always jump from slow to fast, so I've used a line object to ramp the tempo as settings change. The result is a much more interesting result, with both tempos and notes moving around in an interesting manner.

Conclusion

In the above examples, we've used ReWire to take a simple (and boring) sequence and turn in into a sorta-living, kinda-breathing auto-ambient music generator. This is just one use of the ReWire subversion techniques - you could easily expand these ideas into other genres, and use them to perform mixing and performance ideas that would be impossible to do manually. While working with ReWire isn't always intuitive, seeing the possibilities for unusual sequence manipulation may offer options that neither your sequencer nor Max/MSP can do alone.

by Darwin Grosse on November 26, 2007

Creative Commons License