Magazine Archive

Home -> Magazines -> Issues -> Articles in this issue -> View

Technically Speaking

Another program to get MIDI dashing around between your DX21 and BBC micro. Crikey blimey.


Surging on with the software, Andy Honeybone goes conversational. This month's project for the BBC B is a MIDI Talker. Who he? Read on and discover...

MIDI spoken here. But what is a MIDI Talker you ask? A MIDI Talker is my name for a program that allows you to communicate to a MIDI device by simple entries at the computer keyboard and this is what is presented here this month. Is it useful? Most certainly. At an educational level it allows you to get to grips with MIDI commands and hear what they do at a pace that you can dictate. At a practical level the program can be used as a MIDI master clock with the benefits of on-the-fly tempo change capability.

Once again Acornsoft FORTH for the BBC 'B' comes in for a bashing in a program that would be quite short were it not for the constant declarations at the head and the majority of the MIDI spec crammed into a Teletext screen near the end. In operation a line of MIDI bytes is typed and then sent down the wire by pushing the red function key f0. Because drum machines like the Roland TR505 will only receive system real time messages when they are synced to MIDI, it is also necessary to include a MIDI clock as an interrupt driven background task. Now for the detail.

There are three machine code segments. One is the interrupt service routine and the other two are concerned with MIDI data transmission. The code for tx polls the status register of the ACIA chip to ensure that the last byte loaded has been sent. If the coast is clear, the byte held in the Y register is loaded for transmission. The code xmit provides an interface with FORTH such that tx can be called via FORTH and used as a machine code sub-routine. The interrupt routine duly saves all registers, transmits a MIDI clock byte, clears the source of interrupt and after restoring the registers, disappears from whence it came.

The T1 time in the user VIA chip is used in free running mode to provide an interrupt on terminal count. The count down value is calculated in the word TEMPO which prompts for an entry in beats per minute. The constant ppqn (pulses per quarter note) is set to the MIDI standard of 24 (&18) and the magic number 3938700 is the hex representation of 60 million which is the countdown clock rate (1MHz) multiplied by the number of seconds in a minute. The operating mode of the timer is selected by the routine set_timer and the clock started by loading the countdown value into the registers. Note that although it appears that only the low register is loaded, the ! command is a sixteen bit store and as the low and high registers are allocated contiguous memory locations, all is taken care of.

When the timer count reaches zero, an interrupt request is generated which causes the Beeb to scuttle off to find the source of this disturbance. The address of this routine is held in address &204 known as IRQ1V — Interrupt ReQuest 1 Vector. Should it be found that the Beeb's own hardware did not generate the interrupt, control is transferred to a user supplied routine, the address of which is stored at IRQ2V &206. In the case of this month's project, the address of int_handler is stored in IRQ2V and resultingly a stream of &F8 MIDI clock bytes is produced while leaving the computer keyboard live to receive your further commands.

FORTH is rather basic with a small 'b' when it comes to input statements and so you have to supply your own — or rather crib them from the manual, in this case the word NUMIN from 'FORTH on the BBC Microcomputer' by Dick de Grandis-Harrison.

So what else is there? The word reverse simply reverses the stack so that the entries you have made for transmission are sent in the correct rather than last-in-first-out order. No points for guessing that send does just that. Just so you don't forget the name of the mag, a window is created so that the title banner is left untouched when the screen scrolls up.

(Click image for higher resolution version)

MIDI commands are bytes which have the MSB set high. Channel voice messages are distinguished by having the address of their origin/destination encoded in the least significant four bits of the MIDI command (status) byte. In the program, CHANNEL prompts for a number from 1 to 16 indicating the range of MIDI devices that can be connected. The computer sees this as 0 to 15 and so 1 is subtracted from the user entry and the suitably reduced value is ORed with the head of the MIDI command by set_chan. A number of following data bytes is associated with each command. Each data byte must be less than 128 in value or else it would be interpreted as a command. For each of the channel voice messages, two bytes are expected with the exception of program change (PROG) and channel pressure/aftertouch (AFTER) which are satisfied with one apiece. System real time messages stand as they are with no trailing data and system exclusive is a free house as far as anything goes. This leaves system common which is a bit of a rag-bag. The song position pointer requires a lo and hi data byte, the song select needs one and tune request wants for nothing.

To leave you, a few examples of the program in action. Connect a drum machine, press function key f2 and enter 120 as a tempo value. Type START and push f0 and lo, the drums will lurch into action. Try typing STOP. When f0 is pressed the drums cease. Connect a DX21, type ON 4C 40 51 40 55 40, press f0 and hear instant A major (the numbers are in hexadecimal). You've also demonstrated running status whereby the last status byte remains in effect until replaced by another. There is more. Type CONTROL 7 30 and hit f0. The volume is turned down. By now you've probably sussed that f0 is the send key so I'll assume you'll terminate further examples by dabbing it. Entering CONTROL 1 7F turns the modulation full on and CONTROL 1 0 turns it off. Select a breath control voice and hear the effect of sending CONTROL 2 7F. Stop the drum machine and send SONG_PTR 40 0 and if you have a Roland TR505 or similar, the display will change to show measure 5. Exciting stuff.

A footnote: The TR505 does not appear to like driving the MIDI interface described in the first and second issues. The sensitivity of the interface can be increased by changing the opto-isolator for a CNY17 and the associated collector resistor to 1k.



Previous Article in this issue

July Calendar

Next article in this issue

Demology


Making Music - Copyright: Track Record Publishing Ltd, Nexus Media Ltd.

 

Making Music - Jul 1986

Topic:

Computing

MIDI


Feature by Andy Honeybone

Previous article in this issue:

> July Calendar

Next article in this issue:

> Demology


Help Support The Things You Love

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!

Donations for November 2021
Issues donated this month: 0

New issues that have been donated or scanned for us this month.

Funds donated this month: £46.00

All donations and support are gratefully appreciated - thank you.

Please Contribute to mu:zines by supplying magazines, scanning or donating funds. Thanks!

Monetary donations go towards site running costs, and the occasional coffee for me if there's anything left over!
muzines_logo_02

Small Print

Terms of usePrivacy