Anatomy of a Reaktor Project, Part II
Welcome to the second instalment of Anatomy of a Reaktor Project. In this tutorial, I’ll begin to show some of the implementations I designed for the project I outlined last week.
MONOPHONIC MIDI HANDLER
Last week, I outlined the beginnings of a MIDI handler for the project. We need something that can provide us with 32+ voices of MIDI information in an instrument with only 4 voices. To get around this, I chose to create a monophonic MIDI handler and use it to control 8 polyphonic MIDI handlers with 4 voices each.
The monophonic handler must send data every time pitch and gate data are received (something that the built-in MIDI handlers will not do in mono mode). After trying several configurations, I settled upon a brute force method that is not exactly elegant, but it gets the job done:
This macro receives as inputs a value, N, which controls which pitch value will be sent whenever an event arrives at the other input, In. In is fed by a Selective Gate module with the Note set to the same value as N in properties. The outputs of the macro, N, P, and G, hold values for the next macros N input, and pitch and gate values, respectively.
I use the N value for one macro to compute the N value for the next macro for the sake of simplicity – it means I can create the macro once, duplicate it, and not have to define the index of each macro by hand.
A structure that gives an octave worth of MIDI notes looks like this:
I simply duplicated the macro 12 times and merged the pitch and gate outputs. We can’t do all 128 MIDI notes in a single macro even if we wanted to because Merge modules are limited to 40 inputs.
Then, the entire structure in the second picture can be encapsulated as well:
Unfortunately, I went to the effort of doing all of this work before noticing a bug. In this particular instance, the bug is not due to any coding error on my part, but rather a bug in Reaktor itself.
There is a problem with the Sel. Gate module, which is that it sends two events instead of one for every gate off event. This is the sort of bug that can be particularly insidious, since everything may seem to work fine, and in most instances it will cause no trouble at all (which is probably why they have not bothered to fix it yet).
This is an instance that really drives home my point in previous tutorials about always checking to make sure things do what you think they do before committing to them. When attempting to transform this signal into a polyphonic signal, I kept running into strange errors that I could not explain. It wasn’t until then that I hooked this early work up to EventWatcher to see what was happening.
Fortunately, the fix is simple:
However, since there are 128 of these macros, it is still pretty annoying.
POLYPHONIC MIDI HANDLER
I won’t have time to conver the entire polyphonic MIDI handler, but we can at least get started. The general idea is, on a new MIDI note, the ensemble will read through the MIDI setting of all visible ‘cells’ to see which, if any, are triggered by that note. The pitch/gate data is then sent to the polyphonic MIDI handler for the proper sound engine.
It’s our job to take that monophonic stream and convert it to polyphonic so we can have each sound engine playing multiple sounds at once. Since the structure will be duplicated 8 times, it’s also somewhat important to keep the CPU usage as low as possible.
When new data arrives to the polyphonic handler, we want to choose the voice that has been off for the longest period of time. Things get a little complicated here, but let’s start as small as possible.
This macro actually requires the output of our entire structure in order to function properly, but it is still a good starting point conceptually. The accumulator at the end of the chain counts the number of display clock ticks have occurred since the gate on that voice was last turned on.
When the gate is turned on (the On input), the display clock gets multiplied by 0, so the accumulator stops increasing. When the gate is turned off, the display clock begins accumulating again.
On either a gate on or gate off event (the G input) the accumulator is set back to 0. Essentially what this does is create a stream where the largest value among the voices is the note that has been off the longest.
Finally, the ‘LoadBang’ macro is a simple design of my own that outputs a value of 1 on a Global Reset Event, and at no other time. This is useful to make sure the accumulator starts counting when the ensemble is first loaded. This is the first step of our polyphonic MIDI handler. Unfortunately, it’s only a small piece of the finished product so we’ll have to cover the rest next time.
As you can no doubt see, re-configuring MIDI in Reaktor is quite complex and requires a lot of planning ahead. In the next tutorial, I’ll try to finish up talking about our MIDI handlers.
Have a Question or Comment About This Tutorial?
Want to ask a question about this tutorial or perhaps you have something to add?
Click through to our forum post about this tutorial and join the conversation!