Introduction to Logic
Author: Rob Hordijk
Basically there are four types of signals going around in a patch:
|
audio signals |
the red inputs and outputs |
|
modulation signals |
the blue ones |
|
control signals |
the yellow ones |
|
slave frequency signals |
the grey ones |
This workshop will mostly deal with the yellow ones.
So what’s logic and why would we want to apply it?
Similar to red signals that have to do with sound, the yellow signals have
to do with events. And music is all about (musical) events that happen at certain
moments in time with certain duration. On the occurrence of an event something
has to happen and several modules with yellow outputs are there to signal events
or generate them themselves to make musical things happen. E.g. the keyboard
module for example has a yellow output that signals the moment when a
key is pressed by making the gate output ON, that is the gate output gives a
value of 64. While the output is ON we know the key is still pressed.
And additionally we know the moment when the key is depressed when the
value changes from ON to OFF. With no key pressed the outputvalue is OFF or
0 units. If we forget to connect the gate output of the keyboard module
to the gate input of an envelope module, that envelope module will do nothing
no matter how many keys we press on the keyboard and the patch might remain
sadly silent.
So we can control things that happen at the start of when an event occurs
and things that happen while an event occurs and sometimes even when
it stops occurring. Many times we want to combine different events, e.g. we
want one event to occur only while another event is ON or delay it to the start
of another event. For example we might want a sequence to transpose at the tick
of the metronome signal or only at the restart of the sequence, instead of immediately
when a key is pressed, which is the Modular's default behaviour.
Applying logic is basically how you want to process and combine one or more musical events. If an envelope module needs to be triggered on a keypress you must of course connect the gate output of the keyboard module to the gate input of the envelope. But if you want the envelope to be set to on with a keypress and have it stay on until you press that key again, or if you want to delay the keypress until a clocksignal occurs, e.g. at the (re)start of a sequence from a sequencer module, you need to process the keyboard module’s gate signal to make it work that way. That’s when you apply logic.
So for the sake of simplicity let’s call logic a small part of a patch, consisting of one or more modules, that together perform some desired control function, like the examples mentioned.
The logic possibilities on the Modular are quite extensive compared to a standard modern preset synthesiser or even the old analog modular systems. On a preset synthesiser all logic is pre-programmed and there's mostly not much you can do about it, apart from maybe some sustain control by a footpedal or so. One of the beauties of a Modular synthesiser is that you can make very elaborate logic patchings, enabling you to do things totally impossible on a standard synthesiser. E.g. we could make an event to cause another event to cause a third event to cause a fourth event and that event might even restart the first event again. We can combine "digital logic" techniques with "analog computing" techniques, but with the ease of simply connecting cables between the virtual modules and no need to write extensive scripts or whatever. Logic is also very suited to make the Modular react on all sorts of real world events in a predictable way, that you can make as simple or complex as you want. All sorts of real world MIDI controllers can be used to give signals to the Modular and logic can assist in conducting these signals into a great live performance by setting the rules and boundaries for the patch's reactions. Only the player's imagination and creativity seems to set the limits.
Applying logic however will be new to lot's of you, so we will try to reveal some facts which are necessary to understand the behaviour of the logic modules and in the workshop section we will give simple examples to solve common situations.
The yellow outputs
A yellow output can only generate two values, 0 units or 64 units. A value
of 0 units is considered as an OFF state and 64 units are considered as an ON
state. These are regular values, so if you connect a yellow output to the input
of a control mixer module and you set the control mixer to linear behaviour
the value of 64 can be divided in half steps, giving any integer value between
0 and 64.
This also means that the signal at a yellow output can be used as a true yellow
signal with the two possible binary states, ON or OFF, or it can be considered
a blue or red signal with a value of either 0 or 64 units. The
yellow output shares the samplerate of 24 kHz as the blue ones.

Above is a simple example where a logic module’s output value is scaled in
the control mixer to a value of 32 units if the inputvalue of the compare module
is equal or greater than 0. But if that inputvalue is negative the value at
the output of the mixer is 0 units. The scale on the knob of the control mixer
is between 0 and 127, where value 127 actually means unity gain or no attenuation,
so a knobvalue of 64 means divide by two. The outputvalue of the ControlMixer1
module in the example will be exactly 32 units.
This is to emphasise that the signals from the yellow outputs can be processed
any way you like. Processing a yellow signal in a module with a blue output,
like the ControlMixer1 in the example will in fact turn the yellow signal into
a real blue signal.
The yellow inputs
For the yellow inputs it’s a different story. They always test
if a signal is greater than 0 units and it's the result of that test which is
used in the module's function. In the case of a signalvalue greater that 0 units
the incoming signal is considered to be an ON signal. If the incoming signal
is exactly 0 units or any negative value the signal is considered to be OFF.
Remember that a signal in the Modular is a floating point number, so if a yellow
input receives a value of 0.0001 units it will still consider this as greater
than 0 and accordingly consider it an ON signal.
Additionally, the yellow inputs can react on both the level of the input signal,
like a gate signal, or they can react on the moment when the input changes from
OFF to ON, like a trigger signal. This is called edge-triggered. If the input
is edge-triggered a little up-pointing arrow is displayed next to the yellow
input. Some inputs react on both the OFF/ON transition and the ON/OFF transition.
In that case a two-pointed arrow is displayed next to the input. See the example
where we see the two types of edge-triggered inputs on the clock divider module
and level dependent inputs on the logic inverter module.

To summarise:
If the input reacts to a level, any value, even from an audio signal, which
is greater than 0 is interpreted as ON. Is the level 0 or negative it is interpreted
as OFF. The module reacts while the event takes place.
If the input reacts to the OFF/ON transition, the module reacts on the moment
when the input becomes any value greater than 0 units from a value of 0 or less
units. The module reacts when the event starts.
If it also reacts to the ON/OFF transition, triggering occurs when the signallevel
becomes 0 or negative from a positive level. The module reacts both when
the event starts and when it stops.
|
Level ON |
any value greater than 0 units |
|
Level OFF |
any value equal or smaller than 0 units |
|
OFF/ON clock |
from zero or negative to any value greater than 0 units |
|
ON/OFF clock |
from any value greater than 0 units to 0 or any negative value |
The reason why we have these two basic types of yellow inputs, level dependant
or edge-triggered, is because a yellow ON signal will in many cases represent
a realworld event, e.g. a keypress. In the gate signal of a keypress there are
actually two types of information that we want to deal with, the event of the
actual keypress, signalled by the moment when the keypress gate signal changes
it state from OFF to ON or the "positive edge", and the length of the keypress
event, which is as long as the keypress gate signal is ON, until the "negative
edge" signals the release of the key.
The logic inputs with an edge-triggered behaviour, with the little arrows next
to their inputs, will normally be used at the start of some event, like e.g.
to Sample&Hold a signal or advance a sequencer module on a keypress or on
a metronome tick from a clock module.
The logic inputs which react on a level, so without little arrows next to them,
will be used to control a state of the module for as long as the input signal
is ON, e.g. like holding an envelope's sustainlevel or playing a sequence for
as long as a key is pressed.
So we can put two types of information into one single yellow signal with only
an ON and an OFF state!
Note that the gate input on the ADSR envelope module reacts to when the event starts, while the event lasts and when the event stops, and so it deviates a bit in behaviour from the rest.
Resolution of the signals in the Modular
To fully benefit from the yellow signal’s possibilities, we must understand the system of units Clavia chose to use. The value range of a red or blue output is, under normal conditions, somewhere between –64 and 64 units. If we amplify such a signal more than four times clipping occurs, so the full dynamic range for any processing of values is between –256 and 256 units (64 times 4 = 256). We can assume that the DSP’s work in 24 bit mode, what means that the total range of 512 units is subdivided into 2^24 discrete digital values or numbers. That’s pretty precise, in audio terms, it’s a dynamic range of 144 dB.
A yellow output gives only two possible values of 0 and 64 units, as mentioned before. But the 64 units can be subdivided in 2^21 discrete floating point values between 0 and 64 by e.g. a gain controller or a mixer. This gives us the possibility to use the yellow outputvalue in an ‘analog’ way, as it can be amplified, attenuated, filtered, etc. with a predictable and reliable result.
Why this ON value of 64 units?
Traditional analog synthesisers work with analog voltages to control module functions. In a digital machine those analog voltages are emulated. Where most analog counterparts use e.g. a voltage increase of 1 Volt to raise the pitch of an oscillator by one octave, Clavia chose to use 1 unit to raise the pitch of an oscillator by a semitone. So we need an increase of 12 units to increase the pitch by one octave on the Modular. Could we say of an analog synthesiser that it had a 1V/Oct behaviour, then the Modular has a 12 Unit/Oct behaviour. Gate signals on older analog machines could be more or less 5 Volts or 12 Volts or even be a current switch. There was mostly not very much more to do with these signals but triggering envelopes and sequencers. The Modular is however much more flexible and precise, a raw gate signal is always exactly 64 units, without also being dependent on the environmental temperature as so many old analog systems were!
The value of 64 units has to do with how the controllable amplifiers in the Modular work and not with the frequencyscale of oscillators. If the inputvalue on the controlinput of a gain controller module is 64, the amplification is 0 dB or unity gain. So the processed signal passes the module without being amplified nor attenuated. If the controlinput value is 0 however the signal is completely suppressed. By putting a value of –64 on the controlinput the processed signal is negated or inverted. This means a logic ON signal can be used to directly pass or block an audio signal with the help of only an additional gain controller module.
As the range of 0 to 64 units holds 2^21 values, one unit still contains 2^15 = 32768 discrete digital numbers and so we have 32768 times 64 amplification steps between unity gain and total attenuation.
Note that this will hold for red, blue and yellow signals. But it does not mean that one half note (1 unit on the logscale) has a range of 2^15 frequency steps on an oscillator input. This is because the units must be translated to a logarithmic scale to get the actual frequencynumbers on the grey inputs and outputs. E.g. applying a 1-unit change on a grey input might change frequency over much, much more than half a note. With some complex math we could figure out exactly what, but that’s neatly done in the master oscillator modules, so we won’t bother.
If we need to calculate a value, remember that multiplying by 64 units is actually arithmetically multiplying with 1 and 32 units is arithmetically 0.5. Here's a table that gives some relationships between a control value in units and the gain in dB for the gain controller module and the amplifier module. This table gives some rough indication about what to expect, but the real musical adjustments can of course best be done by ear.
|
Units |
Multiplication |
Gain |
Knobsetting |
Knobsetting ControlMixer (LIN) |
|
256 |
X 4 |
+12 dB |
X 4 |
- |
|
128 |
X 2 |
+6 dB |
X 2 |
- |
|
64 |
X 1 |
0 dB = unity gain |
X 1 |
127 |
|
32 |
X 0.5 |
-6 dB |
X 0.5 |
64 |
|
16 |
X 0.25 |
-12 dB |
X 0.25 |
32 |
|
8 |
X 0.125 |
-18 dB |
- |
16 |
|
4 |
X 0.0625 |
-24 dB |
- |
8 |
|
2 |
X 0.03125 |
-30 dB |
- |
4 |
|
1 |
X 0.015625 |
-36 dB |
- |
2 |
|
0.5 |
X 0.0078125 |
-42 dB |
- |
1 |
|
0 |
X 0 |
Total silence |
- |
0 |
Relation between knob positions and units
Any knob can be set to one of 128 positions. This exactly matches the MIDI specification, where e.g. a CC signal, or a note number with its velocity value, can have values from 0 up to 127. As MIDI CC’s are used to control the position of knobs on synths, how does the knobsetting or a CC value, if it’s assigned to a knob, relate to the effect that setting has in a module? Do some experimenting with knobs with different control curves until you fully understand what’s happening.
Note that some knobs that control a value between –64 and 64 miss the value of 63. Test this with a Constant module. If the Uni button is depressed the value of 63 is missing and if the Uni button is pressed the value of 63,5 is missing. This is as there are only 128 possible positions, between –64 and 64 are 127 integer values, adding –64 and 64 to this collection of values would mean 129 knobpositions. But MIDI has only 128 possible knobpositions and so have the module's knobs. Rescaling the –64 up to 64 range to 128 equal values would mean that all values except the –64 and 64 would become fractional numbers and 0 would disappear from the collection. As the value of 0 and 64 are so important (total silence or unity gain), Clavia chose to simply skip the 63 value and use 64 in it’s place. This also means that a knobsetting of 127 must actually be considered a setting of 128 instead of 127 if that knob has a linear behaviour!
To summarise:
It’s not the physical position of the knobs that defines what happens if we
scale down an ON state of 64 units but the underlying system that couples the
knob position with the arithmetic value to be used in the calculation.
It is important to only use knobs with linear behaviour if we want to have a
predictable result. That's why there’s that Lin button on the ControlMixer module.
The knobsetting 64 (and not 63) on the control mixer will exactly halve the
signal, but the knobsetting 127 will mean unity gain, so although the arithmetic
is linear the relation between the knob’s physical position and the underlying
arithmetic is slightly irregular, compensating for a small deficiency in the
MIDI specification.
The modules we can use in logic
There are several types of modules that can be used in logic, but they don’t necessarily have to be the modules that are under the 'Logic' tab in the editor. These last modules perform clear logic functions, but as you must have understood by now, logic is not only using these last modules, but instead it is how we handle events.
Here’s a list of modules that can be used for logic in the V3 software. It’s possible that Clavia will add new types in the future.
|
Modules that signal real world events |
|
|
Keyboard voice module |
Gate signal for a voice note |
|
Keyboard patch module |
Gate signal for any key pressed |
|
Midi global module |
External sequencer play/stop (active) |
|
Note detector |
Gate signal for a particular key |
|
Modules that can generate timing pulses for another module's yellow input |
|
|
Midi global module |
Midi clock pulses |
|
Clock generator |
Clock pulses |
|
Any type of LFO |
Logic will react on whether the outputlevel is greater than 0 -> ON, or 0 or less -> OFF |
|
Most audio oscillators |
Logic will react on whether the outputlevel is greater than 0 -> ON, or 0 or less -> OFF, useful with frequencies up to at least a few kHz |
|
Envelope follower |
For testing if an external audiosignal is present or absent, e.g. for use in a noise gate. |
|
Any sequencer module |
The event sequencer is the most suited, but the control sequencer's outputlevel can be checked on greater than 0, or 0 or less. The notesequencer can be checked on a note being higher than E4, or E4 or lower. |
|
Modules that can process trains of timing pulses |
|
|
The clockdivider modules |
Decrease the amount of clockpulses in a regular or irregular train of clockpulses by a whole number ratio |
|
The pulse delay modules |
Shift the pulses or one of the edges in time |
|
Modules that process or combine logic levels |
|
|
Logic inverter |
Flip a level from ON to OFF and vice versa, or make a edge-triggered input on another module react to the negative edge instead of the positive edge |
|
Logic processor |
Combine ON/OFF levels |
|
Mixer modules |
Combine (ON/OFF) levels (by what is called ‘Mickey Mouse’ logic for another module's logic input |
|
Modules that can be used to switch between signals |
|
|
On-Off switch |
Pass or block a signal by frontpanel control |
|
4-1 switch |
Choose a signal by frontpanel control |
|
1-4 switch |
Distribute a signal by frontpanel control |
|
Gain controller |
Controllable On-Off switch for any kind of signal |
|
X-fade mixer |
Controllable 2-1 switch for any kind of signal |
|
Pan module |
Controllable 1-2 switch for any kind of signal |
|
Note and Vel scaler |
Pass or block signals in a specified range |
|
Modules that can generate a fixed level or store a level |
|
|
On-Off switch |
If the input is unconnected it generates an output value of 0 or 64 units depending on the button being On or Off |
|
Constant module |
A value of greater than 0 is logic ON, and equal or negative is logic OFF |
|
S&H module |
This module can be conveniently used as a storing cell, also for a logic level. The S&H is a kind of ‘jack of all trades’ module with lot’s of other uses as well. |
|
Modules that can be used to synchronise events to other events |
|
|
Logic processor module |
Conditional passthrough for clockpulses |
|
S&H module |
Extracting synchronised pulses from another train of clockpulses |
So you see that logic has more to do about how you interpret signals, than
that it always should be just using yellow cables. This is very important to
fully understand. A yellow input reacts on any kind of signal, but in a ‘logic’
way. And yellow signals can be processed in other modules like they were red
or blue signals.
E.g. when adding yellow signals in an eight input mixer overflow can easily
occur. The highest level that the Modular can handle is 256 positive or –256
negative units. So if mixing five yellow ON signals they would sum up to a value
of 320 units, but that value is clipped in the mixer to a value of 256 units
and the clipping led of the mixer will be bright red. Such a value is on a yellow
input simply interpreted as greater than 0 so logic ON. Doing this kind of thing
will in no way harm your Modular or burn out your module, as maybe a real analog
module would. It is absolutely safe within the Modular.
Only! Don’t connect such a signal to an audio output module, as
such a level might harm your speakers and ears. It’s a sudden sharp pulse at
twelve dB above standard loud audio outputlevel, enough to rip the conus of
your speaker if you have your power all the way up.
Propagation delays
There is one very important thing about logic that you should be aware of once you start to make somewhat more complex logic patches. Logic modules are calculated 24000 times a second. That’s very fast, but within a calculation period they are calculated one after another. The order in which the modules are calculated however is obscure. The output of a module is only available after it is calculated, so modules that are calculated after this module can use the right outputvalue if that value changed during the calculation, but the modules that were calculated first could not! ! The small delay between the arrival of a signal at the input of a module and the presence of the result at the output is called the propagation delay of a module.
If you’re not aware of the existence of these delays, you might assume a value that’s not really there yet. E.g. if a yellow or blue signal goes through a series of four modules, only after four calculationrounds of the DSP can we be reasonably sure that we have the right outputvalue. So the more modules you use to process an event or signal, the more the output result will be delayed, relative to the start and end edges at the beginning of the chain. This can give trouble when combining the processed event with the original event's edge with e.g. an S&H module. The S&H might not sample the new calculated value, which we would want, but the old value instead, as the calculation might not be ready yet. So to be sure, we simply always take into account that a module has a delay of one blue system sample period. To have that S&H module from the previous example sample the right value, we should delay the trigger signal at least 4/24000 of a second. Of course we will look at the best way to solve these kinds of problems later on.
Also, if you would want to do a thing commonly known as "analog computing", e.g. to create patterns using iterations of mathematical functions where the computation is done by several modules in parallel and series, we need to wait for the computation to settle, to wait until the moment when we can be sure the result is correct, taking into account the accumulation of the propagation delays of the modules that are in the chain.
To avoid the mentioned "timing" problems we can use a technique that’s called
"double clocking". In this technique we use two clockpulses, one to sample the
input value(s) of the computation and one to sample the output value(s) of the
computation. The only thing of importance is to be sure that the computation
has enough time to "settle" between the sampling of the input(s) and the sampling
of the output(s).
If this doesn’t mean anything to you yet, don’t worry, we shall explain this
simple but effective technique later.
Binary operations
There are two modules that need some more explanation, as they do ‘binary’ operations. These are the logic inverter module and the logic processor module. The logic inverter is actually very simple, it changes an ON state in an OFF state and an OFF state in an ON state. This can be clarified with what is called a ‘truth table’, a simple table that gives the outputvalues for all combinations of inputvalues.|
Output |
|
|
ON |
OFF |
|
OFF |
ON |
Table 1: Truth table for inverter
To understand what the logic processor does we will take a look at the three
truth tables for the functions AND, OR and XOR.
We see that there are four combinations of OFF/ON states for the two inputs.
Each combination results in a specific output state. You can look up the combinations
in the truth tables, where all possible combinations are listed.
|
Input A |
Input B |
Output |
|
OFF |
OFF |
OFF |
|
ON |
OFF |
OFF |
|
OFF |
ON |
OFF |
|
ON |
ON |
ON |
AND means that if both inputs comply with the rules for an ON level (anything greater than 0 units), the output will give a value of 64 units. In all three possible other cases the output will be 0.
AND in practice behaves as a controllable switch. If one input is OFF, the other input will be blocked. But if one input is ON the output will simply follow the other input. It doesn’t matter which input you use, they can be freely interchanged. So it’s more how you interpret the input signals. So think of the AND function as a controllable gate or controllable switch for logic signals useful to suppress gate- and triggerevents depending on another gate signal.
|
Input A |
Input B |
Output |
|
OFF |
OFF |
OFF |
|
ON |
OFF |
ON |
|
OFF |
ON |
ON |
|
ON |
ON |
ON |
OR means that if at least one input complies with the rules for an ON level (anything greater than 0) the output will give a value of 64 units. Only if both inputs are OFF the output is OFF.
OR in practice behaves like a mixer, it ‘overlays’ the two input signals over each other and output the ‘overlay’. So think of the OR function as a sort of mixer for logic signals. The two gates will blend into one gate if both gates are on at the same time.
|
Input A |
Input B |
Output |
|
OFF |
OFF |
OFF |
|
ON |
OFF |
ON |
|
OFF |
ON |
ON |
|
ON |
ON |
OFF |
XOR means that if only one of the two inputs complies with the rules for an ON level (anything greater than 0) the output will give a value of 64 units. XOR stands for ‘eXclusive OR’. It is used to test if two yellow signals have the same logic state or if they are different. If they are the same, that is both are ON or both are OFF, the output is OFF. If they differ, one of them is ON and the other is OFF, it's only then that the output is ON.
The XOR function is useful for varying purposes. In a way it's comparable to what a ringmodulator or multiplier does to an analog signal. It can be used to conditionally invert one input, depending on the state of the other input, e.g. to change a train of gatepulses from on-beat to off-beat by a gate signal. But we will mostly use it to compare two logic levels to check if one of them is ON in the somewhat more complex logic patchings.
In digital logic there are some more possibilities, like NOR, NAND and XNOR functions. These are simple OR, AND and XOR functions where the output is additionally inverted by an inverter module. The logic states ON and OFF are also interpretations that could be reversed, we could consider every ON state as an OFF state and vice versa. In that case an AND function would work as a NOR function. This is called negative logic, but I consider this to be a little bit out of the scope of this workshop. The S&H module can in most cases be used as a D-type flip-flop if we don't need a reset input.
Only for those of you who feel very comfortable with logic it must be said that
the basic functions are available to build all types of logic, like negative
logic, majority logic and fuzzy logic. The only very important thing to keep
in mind when building real complex logic patchings is the propagation delays
of the modules, as the patchings will certainly give wrong results if these
delays are not taken into account.