MIDI Sequencer

Hardware:

This project was built on a STK-200. We used parts necessary to connect the RS-232 port to a MIDI plug. We used a female MIDI plug, an optoisolator and several resistors. In our attempts to fix the MIDI input we also used transistors and Op Amps to try to boost and invert the signal.

The board has three forms of output:

  1. The connection to the other board which used four, one-hot lines and one line used for handshaking.
  2. The beat LED which counts which beat the user is on (1 to 8), and blinks a dot indicating beat.
  3. The beat LEDs which show the user what beats are where when they are recording.

For input the system uses a keypad, which is more conveniently spaced than the pushbuttons.

Software:

Communications' Processor - Agent C

The task of Agent C can be summarized as a communication link between the user and syntthesizer. Agent C stores recorded sound in memory. It sycles through its protion of memory continuously combining stored data with user inoput and outputting to the synthesizer.
Agent C operates in two modes:

  1. Record: The input of the user is combined with the stored input and output to the syntesizer and stored to memory.
  2. Play: The input of the user is combined with the stored input and sent to the synthesizer, however nothing is written back to memory

The modes are stored in a data register named mode. Mode uses a 1 hot assignment where bit 7 means play mode and bit 6 means record mode. Agent C detects push button presses from the user on push button 6 (connected to PD6) to go in to record mode, and push button 7 (connected to PD 7) to go into play mode. It also detects push button 5 (connected to PD5) to slow the tempo and push button 4 (connected to PD4) to speed up the tempo.

The user input interface is all palced in the Timer 1 Compare Match A ISR. Our music piece consists of 2 measures with 4 beats per measure and 32 ticks per beat. We start with an initial tick time for entry into the ISR by controlling the contents of OCR1A. This value is changed by the tempo buttons and is stored in two data registers (beatH and beatL). The ISR first checks for change of mode from any of the highest three push buttons and changes the mode accordingly. Next, it checks for the the beat buttons and updates the tempo. The ISR, then toggles the beat LED, beat number and debugging LED's on PortB. Lastly, the ISR gets the data value corresponding to the current beat from memory and combines it with the user input and stores it a data register called memread. If Agent C is in play mode, it simply increments the memory pointer. In record mode, Agent C sves the comined input and memory read back to memory using postincrment.

Agent C uses one byte of memory per beat which is active low to correspond to the push button inputs and debugging LED's on Port B. Only the lower nibble of each byte is used since we are only storing one hot data assignments for four instruments. Given the specs for ticks, beats adn measures we end up with 256 ticks corresponding to 256 bytes of memory starting at 0x60. WE use the Z pointer to get and store data to memory. To prevent the Z pointer from overshooting, we use a subroutine called CheckZ to reset it back to 0x60 when it hits the end 256 bytes.

Agent C communicates with teh synthesizer board through PortC. The main loop of the program does that by waiting for a a signal from the synthesizer baord to go high. The output to Port C is the lower nibble of the data in data register emread complemented to become active high.