Computer control for MIDI-equipped instruments
At last synthesiser manufacturers have come together and agreed on a specification which allows the latest processor-controlled equipment of different origins to be connected together. This system known as the MIDI (Musical Instrument Digital Interface), is implemented by transferring digital information, in serial format, between instruments.
Being digital it is a fairly simple matter to connect a microcomputer into the system and generate or process data relevant to particular instruments.
A detailed introduction to the MIDI is given elsewhere in this issue, so this article will mainly deal with the practical aspects of a computer interface.
To allow other circuitry to be connected into the system a parallel interface with 3 Input/Output ports has also been included.
The interface can be connected directly to any Z80 processor system and selected using IN and OUT instructions. However, the micro buss connections have been configured in a format suitable for direct connection to the Sinclair Spectrum.
Other processor systems such as those using the 6502 could be connected by decoding the address lines and treating the registers as memory locations.
MIDI connections are made to the board using the specified 5 pin DIN sockets.
The MIDI is operated at 31.25 kBaud, each data 'word' containing 10 bits; one start bit, 8 data bits (Do to D7) and one stop bit as shown in Figure 1. Each 'word' therefore takes 320uS to be transmitted. This high transfer rate is necessary to prevent noticeable delays between equipment.
In the MicroMIDI the serial conversion is handled by an ACIA (Asynchronous Communications Interface Adaptor) which essentially contains two registers, one for 'transmit' and one for 'receive'. The device is configured to produce a serial 'word' in the required format whenever the transmit register is loaded with data. Conversely, when serial data is detected on the receive input, it is converted and loaded into the receive register. The transfer rate is set by an external clock.
A complete circuit diagram of the interface is shown in Figure 2. IC2 is the ACIA, which is enabled via IC3 and IC1f. Transmitted data is buffered by IC1d & e and connected to the MIDI OUT socket. Incoming data is connected via an opto-isolator, IC6, which prevents ground loops corrupting the data and protects IC2 from potentially destructive signals. The external 2MHz clock is based around IC1a & b and is squared up by IC1c. This is divided down inside IC2 by either 16 or 64. Dividing by 64 gives the required transfer rate of 31.25KHz.
IC5 is enabled via IC4 and provides the 3 parallel I/O ports. Bit 8 of Port C has a 'user definable' switch connected which could be used as a break switch in machine code programs or to produce some other specific operation.
Decoupling is provided around the circuit by C2, 3 and 4.
Assembly should present no great problems as all the parts are mounted on the PCB. Using Figure 3 as a guide, first solder the 21 links into place. Next, locate and solder the resistors, capacitors and diode followed by the IC sockets. Since IC6 has only 6 pins, a cut down 8 pin socket should be used. The crystal, switch and sockets 2-6 can now be fitted. Socket 1 requires a bit of 'fiddling' and care should be taken to make sure that it lies parallel to the surface of the PCB. Firstly, bend the lower row of pins and insert into the board so that the body of the socket butts against the edge of the PCB. The upper row of pins should now be the right length to bend and insert through the board. Socket 1 can be left out if the board is to be used with Z80 systems other than the Sinclair Spectrum.
Eight registers in all are decoded from the address lines A0-A7. The Spectrum uses A0-A4 internally, so the 3 MSBs are used to select the required register.
The addresses are:
The best way to test the board is to connect a 5 pin DIN lead between the IN and OUT sockets.
After the computer has been switched on the ACIA must be reset. To do this the two LSBs of the control registers should be set. The clock divide is then selected (4-64) and the word length specified by loading the register with OUT 159,86 (56 Hex). A complete definition of the register contents are given in Table 1.
The status register can be read, by printing IN 223. It should contain the value 2 which shows that the Transmit register is empty. Loading the transmit register with any number eg OUT 191, 85 and then reading the Status register should now produce the value 3. This means that data has been transmitted and the receive register is now full. When the receive register is read, IN 255, it should contain the transmitted number 85.
A simple program which illustrates the possibilities of the MIDI is shown in Figure 4a. Firstly, the ACIA is reset and configured (lines 10 and 20). A program number is requested (line 30) which is variable 'n'. The number 192 (C0 Hex) is then output to the transmit register which is the code for a program change (see MIDI Data Format), and then the program number, n, is output which will change the program of the instrument connected. Line 60 makes the program jump back to line 30 for another selection. This illustrates how easily voice changes could be incorporated into a sequencer program or a string of voice changes could be stored and stepped with a footpedal.
A second example which demonstrates the exciting possibilities of the MIDI is shown in Figure 4b. This is a machine code routine which waits for a program dump from the Prophet 600 and then converts the incoming data from 32 four bit nibbles into 16 bytes of program data as shown in Table 3. This data could be displayed, edited or printed as required.
The routine checks for 240 (System Exclusive Status), then 1 (SCI's ID number) then 2 (Prophet 600 program dump) before loading the program number and program data. When an end of block code, 247, is detected the control returns to the basic monitor. The program number is written into location 32500 followed by 16 bytes of data.
Analogue synthesisers may be added to the system by connecting ADC and DAC convertors to the I/O ports as described in the MicroMusic articles November '82 and January '83.
Synchronising the system from an external clock is also possible using Port C and sending the required System Real Time codes when the relevant edge is detected.
Now that SCI, Roland, Korg, Yamaha and Moog have all agreed to adopt the MIDI we shall no doubt see some interesting software appearing for home computers. Now is the time to join the MIDI revolution.
The PCB for the MicroMIDI is available from E&MM, (Contact Details) at £4.25 inc. VAT and P&P. Please order as: MicroMIDI PCB.
Feature by Kenneth McAlpine
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!