***Pachelbl.asm***   Alan Probandt   Portland, Oregon USA   Sept 2004    alan_probandt@yahoo.com


This is a program for the Atmel AVR Tiny11 that plays the chords of Pachelbel's Canon. 
It sends the MIDI Note-On messages out from Pin 7.

There is a burst of static and notes at the beginning. Possibly due to a wrong flag setting.
I don't have the time to debug it totally now.  It's just a demonstration and test program.

The timing uses a 4MHz crystal.  Change the value of 'clock' in the header of the assembly file
if you are using a different crystal.

Connect the Tiny11 pin 7 to a DIN 5 connector pin 5.  Connect the DIN 5's pin 4 to VCC through a 360 ohm resistor.
A schematic diagram is in file 'pachelbl.gif'.

*** From the program's documentation***

	This program plays the eight chords of Pachelbel's canon repeatedly.  Each four-note chord
  plays for 1.7 second, all notes are turned off, then the next chord plays.

	The program is completely interrupt driven.  Reset initializes the Timer interrupt and the structure,
  then loops endlessly.  The timer is set to the length of one MIDI baud length.  The interrupt routine keeps
  track of its position in a large data structure.
	
	1 Timer interrupt   = 32 microseconds - one MIDI baud length
	10 interrupts = one MIDI byte (1 start bit, 8 data bits, 1 stop bit)
	3 MIDI bytes  = one MIDI message.  The MIDI message is either Note-On or All-Notes-Off.
	5 MIDI messages = one chord.  One message for All-Notes-Off and four Note-On messages.
	1.7 second wait period after each chord = 55000 Timer interrupts; during which processor does nothing.

  The chords of Pachelbel's canon: D major, A major, B minor, F# minor, G major, D major, G major, A major.
  This music 'Canon in D major' was written by Johann Pachelbel (1653-1706) sometime around 1680.

	The three bytes of a MIDI message are all loaded at the same time into a register array.
  The first byte to be sent goes into high register 'MIDIout'.  The second into low reg 'NextOut' and
  the last byte of the message goes into 'Last Out'.  When the byte in 'MIDIOut' is finished transmitting
  (at the end of its stop bit), the data in 'NextOut' moves to 'MIDIout' and data in 'LastOut' moves to
  'NextOut'.  The sentinal value of 0xFF gets placed into 'LastOut'.  
       After the data move, the Timer IRQ checks 'MIDIOut' for the sentinal value.  If it is there, then
  the IRQ decrements the 'Note' counter and checks for zero.  If not zero, it increments the Note pointer
  to the next value in the Chord table.  This table has the MIDI Note values to make the eight chords of the
  canon. 'Note' starts each chord with a value of 4.  The IRQ sends four notes from the Chord Table to the
  synthesizer, waits 1.7 second, then sends the four notes of the next chord.  After eight chords it
  resets the note pointer to the beginning of the chord table.
	If the value in 'Note' is zero after a MIDI note-On message has been sent, the program waits
  for 1.7 second (55000 interrupts) while the chord plays on the synth.  Then it sends an All_Notes_Off
  message to turn off the previous chord and the four Note_On messages for the notes of the next chord.
