Home -> Magazines -> Issues -> Articles in this issue -> View
Adventures In MIDILand (Part 5) | |
Article from Sound On Sound, December 1990 |
Part 5. The adventure continues - the master of MIDI manipulations, Martin Russ, does the time warp!
In all the science fiction novels and short stories dealing with time travel, they always mutter something about the Laws of Time, usually to avoid any plot problems which might arise if a character goes back and kills off their ancestors. My own theory is that making rules like that is rather like expecting music to be popular because it is good - fine in theory, but unfortunately the world does not work like that. In this adventure we go well beyond the charted territory into a land where we can do some ridiculous things with time itself! You might be expecting a corny reference to the Rocky Horror Show at this point, so let's get it over with now: you could call this episode 'Let's do the Time Warp again!'.
MIDI time (or that in any synchronising system) is purely relative, which means that it works to whatever source you give it, regardless of real time. This even applies to a system which is synced to Linear Time Code (SMPTE, EBU etc) or MIDI Time Code, since if you want to you can do stupid things like stripe a tape at one speed and play it back at another.
But the most obviously relative MIDI time message is the MIDI Clock, and it is this which will form the basis of all the manipulations with time in this adventure. Because MIDI Time Code and the other Time Codes are usually used in situations where the actual timing is important, it is wise to leave well alone: 'If it ain't broke, don't fix it'.
Since MIDI Clocks happen at a fixed rate of 24 clock messages per quarter note, you may be wondering what could possibly be done to change time. A bar's-worth of MIDI clocks in 4/4 time always contains 96 messages, and I do not intend to change that yet. Instead, I will start by altering the relationship between the MIDI clock messages and real time in a special way. Ordinarily, MIDI clock messages tick away at a fixed tempo and the number of ticks can be mapped to the song position in bars and beats, as well as to real time. If you change the tempo then the bars and beats stay the same but real time will be different. What I intend to do is show you how to change the timing of the beats but leave the bars and real time alone.
You may be wondering why I would want to do this, but there is method behind the apparent madness, and what follows is a powerful technique which ought to be explored by more people. Much of the 'feel', 'drive' and 'rhythm' of a piece of music depends on subtle timing differences between the component parts of the rhythm section. Most software sequencers allow you to slide tracks back and forth in time to provide correction for slow attacks, and also to enable small changes to be made in the relative timing of tracks. Try it and see.
In a similar way, real drummers do not necessarily work to a fixed tempo, either long-term or short-term. Over a bar's length, the actual timing of drum events may not fall exactly as you would expect (or would program into a drum machine), but instead show the same sort of timing variation. Some commercial drum machines have built-in 'humaniser' functions which attempt to mimic this 'slightly off-beat' drumming, and the first program in this part does much the same thing, except it will work with almost any MIDI drum machine (or sequencer).
I will assume that a 'bar' is four beats long for the following description, although the program also caters for 3/4 time signatures and could be altered to any other ratio. The MCLOCK program produces a MIDI Clock output at the standard rate of 24 $F8 messages per beat, and 96 per bar, but it enables the timing between beats to be altered, so that the rigid 'on the beat' timing feel of drum machines can be avoided. The program uses a series of timing loops, one for every 12 MIDI clock messages, so that you can alter the timing eight times in the bar. The range of alteration in each of these eight time segments is variable over a wide range, so you can make both subtle and very obvious modifications. The larger the number entered for each of the eight periods of time, the longer each segment will be delayed, so entering the same value in each segment will produce no overall change.
Note that the timing variation is the same for each set of 96 beats - the program does not 'humanise' in quite the same way as some drum machines, which concentrate on timing variations on a larger scale than individual bars. Instead it concentrates on providing access to the moments in time just before and after the rigidly fixed beats of most drum machines. You may be surprised at how different rhythm patterns sound with only slight changes to important beats. The actual theory behind the psychoacoustic effects of these minor timing changes is beyond the scope of this series, but it is a fascinating subject, well worth further investigation. Keyboard players may also like to try using the MCLOCK program to drive their favourite sequencer and explore the possibilities of micro-time alterations, since it is not restricted to just drums.
The following program segment illustrates the important part of the program - the individual timing loop for a single segment:
Part of the MCLOCK program:
SUB segment(time_delay_value)
FOR midi_beat=0 TO (time_signature*3)-1
OUT 3,&HF8
FOR t = 1 TO time_delay_value:NEXT t
NEXT midi_beat
END SUB
This segment is a subroutine which is called for each of the eight time segments. The parameter 'time_delay_value' is passed to the routine so that each segment can have its own individual timing. 12 MIDI clock messages are output in the 4/4 version when the 'time_signature' variable is equal to 4. The 'OUT 3, &HF8' line actually outputs the MIDI clocks themselves.
Warping time is OK, but how about speeding it up and slowing it down? The two programs MCLKDB and MCLKHA double or halve the rate of MIDI clocks which are passed through the ST. This means that you can run time faster or slower depending on which side of the ST you connect things. Possible applications include running two drum machines at different time signatures to give a more complex compound result, or even apparently doubling (or halving) the resolution of the time quantisation. On a simplistic level, the MCLKDB program doubles the tempo itself, since by turning every MIDI clock into two MIDI clocks, the drum machine is fooled into thinking that the tempo is twice what it should be.
The following program segment waits for a MIDI clock and then outputs two MIDI clocks.
MIDI clock -> 2 x MIDI clocks
Part of the MCLKDB program:
start:
n = INP(3) AND &HFF
retest:
a = n AND &HF0
escape$ = INKEY$
IF escape$ <>"" THEN GOTO leave
IF NOT(n = &HF8) THEN
GOTO start
END IF
OUT 3, &HF8
FOR ty = 1 TO 1000:NEXT ty
OUT 3, &HF8
GOTO start
The FOR... NEXT loop is used to introduce a slight time delay between outputting the two MIDI clock messages. The timing between the clocks is not the same as half the time between the incoming clocks. It would need a much more complex program to interpolate two clocks evenly into the spaces between incoming clocks.
Song position pointers are not affected by the doubling or halving of MIDI clock messages, which means that since the position in the song is determined by the number of MIDI clocks since the start, then the position information would be wrong relative to the processed MIDI clocks. I can't think of a serious use for this feature, and so the program does not pass any other messages through it.
Going back to mapping, the MCLKDB program maps each incoming MIDI clock to two outgoing ones, and so we could use the same underlying program to make other clock mappings...
The strangest message I could think of to map to MIDI clocks was Active Sensing! Normally sent out at a maximum rate of three per second, the active sensing message is designed to mute expanders which lose contact with a remote keyboard. However, variations in interpreting "at least every 300ms" mean that manufacturers use very different rates of sending the messages. The MASCLK program converts $FE Active Sensing messages into MIDI clock messages, which means that you can 'listen' to the speed of any equipment which sends active sensing messages by connecting the ST's MIDI output to a drum machine or sequencer.
Active Sense -> MIDI clock
Part of the MASCLK program:
start:
n = INP(3) AND &HFF
retest:
a = n AND &HF0
escape$ = INKEY$
IF escape$ <>"" THEN GOTO leave
IF NOT(n = &HFE) THEN
GOTO start
END IF
FOR ty = 1 TO 16
OUT 3, &HF8
NEXT ty
GOTO start
As promised, this program segment is very similar to the clock doubler, except that the program waits for an incoming active sense message, and then outputs a series of MIDI clocks. The rate of three active sense messages per second translates to a very slow tempo, and so by outputting 16 MIDI clock messages the program multiplies the active sense rate to one which works well as a tempo:
120 beats per minute = 2 beats per second
2 x 24 = 48 MIDI clocks per second
So, for three active sense messages per second to correspond to 120bpm, each active sense message needs to trigger 48/3 = 16 MIDI clock messages.
Another possible application which uses the idea of interpolating beats and mapping would be to convert pedalled bass notes from the lower end of a keyboard into MIDI clocks, using a similar program to MASCLK (bass notes -> MIDI clocks). This would give a tempo which tracked any changes in the playing of the performer (and not the other way around!). You may like to experiment with modifying the MASCLK program to do this sort of thing...
The unification of MIDI clocks and tempo leads to another useful program, MCKBPM, which counts the number of MIDI clock messages in a set time, and displays this as a tempo:
time -> tempo
Part of MCKBPM program:
DO
count=-1
t!= TIMER
DO
n = INP(3) AND &HFF
escape$ = INKEY$
IF escape$ <>"" THEN GOTO leave
IF (n = &HF8) THEN
INCR count
END IF
LOOP UNTIL (TIMER-t!)>2.49
PRINT "BPM :_"_+STR$(count)+" "
leave:
all_notes_off
IF (escape$="Q") OR (escape$="q") THEN
GOTO tidy_up
LOOP
This program segment uses two loops, the outer one displays the results of the timing calculation, whilst the inner loop actually does the timing itself. The time for which the MIDI clocks are counted is chosen so that the count translates directly to a tempo - the program specifies a time slightly less than the theoretical value of 2.5 seconds to take account of the time it takes to go around the inner loop. (For a tempo of 120 beats per minute, there are 120/60 = 2 beats per second. 2 beats equals 48 MIDI clocks, and so 48 MIDI clocks will be counted in 1 second. So for a timing period of 2.5 seconds, 96 MIDI clocks will be counted in the first 2 seconds, and a further 24 will be counted in the remaining half a second, giving a grand total of 120 MIDI clocks, which is the correct tempo! Magic numbers like the 2.5 used here are a whole topic on their own...)
A display of tempo in beats per minute can be used to verify the accuracy of the readout on drum machines and hardware sequencers which have a tempo display, although usually the readings will agree. The program is more useful for calibrating equipment which does not have a control marked in tempo readings, or for monitoring the changes in tempo which can occur when you are syncing to events on video or film.
After some programs of dubious usefulness, the final mapping in this adventure is actually very useful, and neatly rounds off the topic of clocks and timing:
Note -> Start / Stop
The MKN2D program uses a trigger note to send Start and Stop messages to control a drum machine or hardware sequencer. This means that you can control devices without having to move your hands away from the keyboard. The program is similar to previous trigger note examples.
Part of the MKN2D program:
st=0
start:
n = INP(3) AND &HFF
a = n AND &HF0
escape$ = INKEY$
OUT 3, n
IF escapeS <>"" THEN GOTO leave
IF NOT((a = &H90)) THEN GOTO start
n = INP(3) AND &HFF
v = INP(3) AND &HFF
OUT 3, n
OUT 3, v
IF ((n=add) AND (v<>0)) THEN
IF st=0 THEN
OUT 3, &HFA
st=1
ELSE
OUT 3, &HFC
st=0
END IF
END IF
GOTO start
The current status of the drum machine is stored in the 'st' variable, and this is used to toggle between sending Start and Stop messages. In this way the first time you press the trigger note the drum machine starts playing, whilst the second time you hit the note the drum machine stops.
That completes the roll-call of programs given in part 2 of this series. The majority of the programs have now revealed their most intimate secrets and the adventure is almost over. The concluding part next month tries to put the program examples into the wider context of what they show about MIDI itself, instead of concentrating on the programming aspects.
PROGRAM DISKS
All the programs mentioned in this series can be found on the MIDILand Programs disk set (order code S101) which is available from SOS Software, price £7 inc postage.
SOS Software, (Contact Details).
Read the next part in this series:
Adventures In MIDILand (Part 6)
(SOS Jan 91)
All parts in this series:
Part 1 | Part 2 | Part 3 | Part 4 | Part 5 (Viewing) | Part 6
MIDI Timing Delays - Software & Hardware Thrus |
Software Support - Hints, Tips & News From The World Of Music Software |
General MIDI - Who? What? Why? When? |
The Strange Case of the Singular Digit |
Technically Speaking |
MIDI Theory and Practice |
MIDI Matters - Song Position Pointers (Part 1) |
Virtual or Reality |
MIDI and the Micro |
The Performing Art (Part 1) |
The MIDI 1.0 Specification |
Adrift On An MTC - MIDI Time Code |
Browse by Topic:
Topic:
Series:
Part 1 | Part 2 | Part 3 | Part 4 | Part 5 (Viewing) | Part 6
Feature by Martin Russ
Previous article in this issue:
Next article in this issue:
mu:zines is the result of thousands of hours of effort, and will require many thousands more going forward to reach our goals of getting all this content online.
If you value this resource, you can support this project - it really helps!
Please note: Our yearly hosting fees are due every March, so monetary donations are especially appreciated to help meet this cost. Thank you for your support!
New issues that have been donated or scanned for us this month.
All donations and support are gratefully appreciated - thank you.
Do you have any of these magazine issues?
If so, and you can donate, lend or scan them to help complete our archive, please get in touch via the Contribute page - thanks!