ReWire and Reason
Using Max with Reason
In the ReWire Essentials tutorials (linked at the bottom), we used Max as both a mixer (hosting application) and "device" (controlled application). These are the two sides of the ReWire connectivity equation, and Max can work equally in both modes. In order to dive into ReWire at a deeper level, let's look at a connection to one of the most-used ReWire packages there is: Propellerheads Reason.
In order to have the most fun with our Max/Reason combination, we are going to do some sequencing and audio processing in Max, and use Reason as a synth/sampling and mixing device. What we *won't* do is run the Reason sequencer or use its recording capabilities. In this way, we'll get to do goofy and interesting Max sequencing and processing (something Max is really good at...), and let Reason handle the synthesis (something Reason is damned good at).
Let's start by creating a very basic connection between Max and Reason. Here's the patch that I created:
Unlike what you see in most of the ReWire help files, I'm using the rewire~ object with a named device. This allows me to state explicitly that this is a connection to Reason, and I don't have to mess around with application selection or other confusing UI elements. I connect the outputs of the rewire~ object to an audio chain (live.gain and ezdac~), and I create two message for the input: "openpanel" and "closepanel".
Different ReWire clients work differently, and even the same application not work the same on Windows vs. Mac. In my case (Max OS X, Reason 6.5), clicking on the "openpanel" message will actually launch the Reason application in ReWire client mode, and will be completely active with no other interaction. If I create a Reason instrument (Kong, in this case), I can play that instrument and receive the audio within my Max patch.
Send MIDI Messages to Reason
The next thing we want to do is to fire notes into the Kong instrument using MIDI messages from Max. To do this, we have to send a specially formatted message into the rewire~ object. The format of the message is:
midi <timestamp> <bus number> <MIDI message> <note value> <velocity value>
Since we don't care about sequence timing or routing, our timestamp and bus number are always 0. Since we are sending notes, our MIDI message is always 144. The note number and velocity information is created by a makenote object, which will take our incoming note information and turn in to MIDI note pairs (noteon and noteoff messages).
The basic note-playing patch will look something like this:
In order to virtually "play" any of the Kong's pads, just click on one of the message boxes (numbered 1-16).
Sequencing in Max, Playing in Reason
The next step is to create some way to do an interesting sequencing system in Max. Let's start by making a simple drum matrix sequencer that is run off the transport:
In this case, we have a transport-based timing system that uses a counter to output a step position. This goes into a live.grid object (set to matrix mode), then the output is split apart and sent to our input keys. These keys are used to send the MIDI messages from the previous patch to the Kong drum machine. This creates a basic grid-style drum sequencer that can play back Kong without having to mess around with pad programming.
But why program the grid at all. By watching for the first step of the sequence and randomizing the grid, we can have Max do the hard work for us! In this updated patch, I have a compound message that is activated whenever the first step is seen:
At that first step, the message will clear and randomly place one note in each column. But I also want a four-on-the-floor kick drum, so I'm using the setcell message to force the kick to fire on every downbeat. While this is really simple generative stuff, it also is surprisingly good-sounding. In fact, some of the patterns are so good that I don't want an immediate change to the next pattern, so I placed a switch at the output of the generator to allow me to "hold" a pattern until I'm sick of it.
Here it is as a copy-compressed patch:
<code> ----------begin_max5_patcher---------- 2118.3oc2b01aaaCD9yI+JHLFv9vb036TpnXX6uv951PghMqCaskLjjS51v5 u8wWjbjarnncsXSLJpcjDMycO2Cu6Huy4eu8lY2U9YY8LvaA+A3la92au4F6 sL23l1quY1l7OuXcdscXyZJWsZsb1b2iVbubwmjKWTttrxMKnD3b.b+K5KA+ U6f2l2r3dUwp2WIWz3FMgmkjkwQL1b.ARRv52orj1W2+IUKs+tKu6iugimse 5px2HajUuWVjemVlzCA19rhcaTEqkMVYF8zMK207028txpkxpvz.2Gu4u2Jc CclpPqH+k4g+2s2ZdYdfv3p5GUZzX1vPCkIRvzVnIkXDEpUzH3dRTejAcxHC wKx7Ls87T0Eka1H03T6r1H+biiIcuD7i0xlEx0q+QvFYcc9JIXWsrFXdzGJq 17VP6yAuSaf9Ev6pJeT+J5mg+R2zsVUHWTtqnou9bD3jIxLfGNKyvtPLpEPE GGJoYcS+GJKZJzfo8Q+VkJe8LeTLyvqU+ic3Hscp61UqtyZDRfGEwgmAr1BX OCVWrVlWMGTkWrrby78.Hx7umtjc3kYGdIhXt9nPLyCiUCwcL1VbNytDRL.i kJNQXF6GlmTZbg7QsL+L3tVtFflEHnvwFPgvsLQ3wAER5TBJ3g.k6xKVMa9E FbzNgpJAHdA3WyWzndP5Gpn3DZav.Tpv57Ei7gUb32EBjEqtn9BKJaju051a sFkRVUoVBT0.UA3O0SPSk5y+4LvlxkRevmdwVG7Q0gJLDNH0G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yNeaGHkOy3WqVUXXW8+oCph5ZUcyD WjFXf0fomIZrhvLzP2UnZpa9amofdjArQSbrk1JAdzmprVq2HfG84J8zqbkw yZHbqr91pDzvs2YYsbadgzaIoccFhvxW4o9b9bMbzKkakEiAItUxs0M00+LC V5iW+4BVIeTUI+B32k40kE.73.iqCyQPl2v5SYKEwOUmU8Jl7YfbFeX6T9.l dkLSSXrGDAB6seJwWV7wHhtt6QtYaYei76eTsr4dKpASXPRJk8sv1rJisOu+ puKHVXwb+CAx5xcUK5lptuUFfdchfrtQUrOJ2e7zWPgdC5d0xkxC5UgkpZS7 xkCGvOX4AEf7fim3.CPbLklKVxS.hiHpRCJ.oAEEogEBU1zNFQBcXgPchlzP EgtPGGG4IDpLEFO7wXtPzwnOnHKPrwDnXiP3w7MmEYAhLl.kFYAZznWhHKPi 4hFyiq.kNl7vhq7jMl7Piq7vGSdHwUdDiIO33JOi4jFGYmzi4iFGYezi4hFE YWzi4gFEaOziIOQ1A8nIIFQ+yunxYkjFRNhwyZQDur1gAgDB9DQ4IjcfghH+ IjCSfLVzqMpkaKUEMsmvBQj8zW1Yg6OJAYzjtq58k53hoFvIPMnPZBosS6Qb t6qgfSMLWMEpwKJeKe09TtPbCbVhnsOriB0.mNEZAilva6u93PMvhIPMvovD XWCOGGqAeJrF5EpYscxdjrFrovZPfZ+MtVKNNFC5TnELVBtsiwijwfLApARu zf21EuwwXfmBiAjoiD6ZN6HYLlhDJLeity5ZX13XMlhDJzIDoi84ZD5HYMBI 623s2IzTjQQJR6uosWYiB2.MEYTffZFPaKPGGtAZJxnfw0gvb8oajzhIIgBT Rz7zfBJ5U7N+mfjm3cblnfbgEOwIjvan3cZlnfp9NNtxCJD4INU7NDyUDi+E .3vOSrw0mK4a29frptcJsBxrM4ez8mwGaWHo80U3tzNiypjl+1Q3Fu3Vyr8e 29+Ps7lFK -----------end_max5_patcher----------- </code>
Adding a Second Instrument
Jumping back to Reason, I've now added a second instrument: a SubTractor analog-ish synth. When you create a new instrument, it makes a new track in the sequencing area of application:
If you start our grid-based sequencer, you will hear that the MIDI stream is not routed; rather, the MIDI input is used by whichever track is currently selected. This isn't optimal, so we want to find a way to force our sequence to be routed to a chosen instrument. Performing this sort of routing magic will require two things: MIDI routing setup within Reason, and manipulation of the midi message that we are sending to the rewire~ object.
Let's start with the Reason MIDI routing setup. If we go to the top of our instrument rack, our basic Hardware Interface display doesn't even have anything related to MIDI showing. Clicking on the Advanced MIDI will reveal a MIDI router, which is where we do our dirty work.
In this case, the MIDI Interface shows "No MIDI Input" (because I didn't set it up in Reason's preferences), but that doesn't matter - we will access these devices directly. For the first channel, we set the MIDI routing to the Kong 1 Input; for the second channel, we set the MIDI routing to the Subtractor 1 In (make sure you are selecting the In option as opposed to the Mixer connection). Now, within Max, if we can access the MIDI Bus A device, we should be able to send MIDI to the individual devices - either individually or simultaneously.
Next up is the changes to our Max patch. We need to change the contents of our midi message to route the message to the correct MIDI channel of Reason's interface device. Luckily, the changes are pretty simple using a few extra inputs and some message formatting.
We now use the bus number value of the midi message to choose a MIDI bus: #1 is Bus A (in the Reason Advanced MIDI interface), #2 is Bus B, #3 is Bus C and #4 is Bus D. We also have to adjust the MIDI channel by changing the message number (144 in the earlier example) to the range from 144-159; we do this using a "+ 143" after a channel input to set the channel number. Now, if we select a device number of 1 and switch between midi channels 1 and 2, we can switch the MIDI output between the Kong and Subtractor devices.
Here's the updated version of the patch:
<code> ----------begin_max5_patcher---------- 2513.3oc2bsziiaiD9b2+JH71.YWDGshukFDDrK1bIG1K60IKFHKywMyXKYH I28jDj42d3CIY4tkrdXa1JCFL1sjnIq5qJ9whEI0ue+cKVk9YQ9Bv6.uGb2c +982cm4V5abW402sXWzmi2FkaJ1hDwyoq9kEKsOpP74Bys+V.jfqta5ghshh hecuvVyKjIpR8+Kepbs4Wnpku63O4ioIEIQ6L+fE+6LYz1pmrOpH9QYxlOjI hKr0Gh66QYALFcI.Cwd9KADn9Sjumec6jbXmLQIGF4F0ncxk+locfH0uotrV g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zD.ZzTbudgpaNl+E .bj.KGlO8JtikXS.4zbXGjirSzzhhlxBqWQMkGiIOEFcY.5u1j9gmkqKdznn 9dTeb.YT64gppRqw1MTjX29zEMvLiHX1K3u37.aTF88OEHySOjEWgTUGlWvQ MYsHuPlTOLx6ONGD.ttPOJWuVbx1dXsLWOL05tGvenxi9fL1q77Bg9MWdzqu qijmWzTsKOuPnuo3CYn9OH2fOng3+3Nyk+PgGGJOvgHOPmHOrgXtzG3JGgOu noZWdbm4hMH2G2wFxFf3vcpz.Gfz3FWY5PbkwtajhgLPg65XQ3CsitaFmfLD WYhu6vGs4BR5y8A5XAh1m.4ZDB0G2bniEHbeBTfiEndG8h6XApOJZDysBTPe xC0sxSXexCwsxCqO4A6V4g2m7fbq7zGIMxwjz8wQibLGceTzPGSQ2GCMz0Lz 8IONlft2fDcH+7rJlUbvPhQzcVKLedMCC7PhgFSlW4hB6NuY7PxsJwg1qgLC UnC6eMjjsf6az8cx06SkIEkI.GygGeCSvsunXzuhXpN7T5a03L7c0zE+agtD x7vkGwIHyb1SOQWz25VnKyJVXT3s.YQPOd4ofwcNInfagpPXdrxi3jCcRP7a ftneKU5WcvSbncgcKzEUm2vxiUjKsKzagtfPJhH6g8vglExsPUTBNp7f73Ry B9FnKPU2EV4IrvglEzsPUB4pgssmdFWZVtEgfn2MxgUGqAGZWtEgfnEbdPCi firKCIxY2EIO7VDCBGqHhJOaCtyKAdKhAILvyu7Xq3PmD3sHDDRfZjN6Arvk pxMIBDy6uGW5aMnA4bW51Fj73vMewPFrA5tr0NDwg4ToAN.oYJqlucaxEse+ Shr7xpzHHK1E8K12EXl2JN5W2z1KM03hLg90Sis776001eb+eBboQs5E -----------end_max5_patcher----------- </code>
Adding a Second Sequencer
At this point, we can directly access individual Reason devices, so we probably want to have sequencers for each device that match their capabilities. The grid device that we created is perfect for a percussion synth (like Kong), but doesn't really work that well with a standard synthesizer like Subtractor. In order to deal with this, let's reformat our patch a little (in fact, we'll hide some of it inside of an encapsulation to free up some on-screen room), and create a second sequencer that will produce basslines suitable for Subtractor.
You will notice quite a few changes in this patch. First, we've hidden much of our logic within subpatchers (named timing-and-randomize and different-timing-and-randomize) to free up a little space. Since the two sequencers are of different types (live.grid and live.step), we need somewhat different timer/randomizer functions, so peering inside these subpatchers might be useful as you create your own, personalized version of this patch. The other place where we've tucked in some interesting logic is in the formatter subpatchers. Here is where we format the MIDI messages that properly route the data to the correct devices. It is important that you either make this logic very flexible, or you make sure you are always using the same Reason setup, since the MIDI message formatting is specific to the Advanced MIDI setting of the Reason device set that you use.
Modulation of Reason Parameters
As cool as it is to generatively fire off notes to Reason, we can take Reason even farther if we can automate the parameters of our Reason devices. Not surprisingly, this can also be accomplished by sending MIDI messages (in this case, MIDI CC messages), but we need to know which MIDI controller messages to use, and we need to properly format the messages for the ReWire connection. This first part of this is provided by our friends at Propellerheads; the Reason 6.5 MIDI Implementation Chart gives us MIDI CC mappings for virtually every knob, slider and switch of the devices available. We will be referring to this manual extensively in the next section, so it is probably wise to download it now...
This is a work in progress...