Jump to content





S.A.M. RAAKS YUW

Posted by Pack007, 13 July 2017 · 297 views

MIDI Arduino SAM
S.A.M. RAAKS YUW

I've added a third computer to the MIDI chain.  Computer #1 plays drums, and Computer #2 runs S.A.M. and Computer  #3 plays the lead,  .  Each computer had a specific BASIC program written to read data from the joystick ports. For this example, Queen's -" We Will Rock You" was arranged for the three computers. You can listen to the MP3 file and then decide if you want to read about the how.
 Attached File  SAM Rocks - mp3.zip (1.08MB)
downloads: 17
  
COMPUTER #0 - Control
The music was entered using the MIDI MUSIC SYSTEM software.  Voice 1 - Lead was assigned to MIDI channel 1, Voice 2 - SAM assigned to MIDI channel 3, and Voice 3 - Drums is Channel 10.  All the editing was done using the CASIO-481 keyboard.  Once the playback was acceptable, the rest of the computers were programed in BASIC and the Arduino interfaces were built.
 
COMPUTER #1 - MIDI Channel 10 - Drums
The same drum setup from the last two blog entries was used.  Only one computer was required for this simple drum pattern. 
 
Computer #2 - MIDI Channel 3 - S.A.M.
 
Attached Image
 
Getting SAM to sing the words was accomplished by activating the trigger button at the right time.  The Arduino would read the MIDI data stream. Whenever a 146(NOTEON+2) command was received by the Arduino the joystick state was changed to zero for 10 milliseconds.  When the Atari program detected the joystick status change, the next word is sung.
 
Before the Atari was programmed the phoneme spelling of the words were created using the SAM Word Editor(another previous blog entry).  Then a small test program was used to change the speed and pitch of the voices to meet the requirements of the music.
 
The BASIC program simply reads the joystick port and when it reads 0 the next word is sung.  This created a problem.  If SAM was speaking it couldn't detect that the next word needed to be sung and resulting in skipped words.  This problem was finally solved by changing the TEMPO in MMS from 175 to 160.     
 
Computer #3 - MIDI Channel 1 - Lead
 
Attached Image
 
If I had started the work on the this computer, the project may never have been finished.  Since the work on SAM was done I had to continue on.  Bad solder joints, program logic and a misunderstanding of the MIDI data from the Casio or MMS added to the confusion.
 
This was the first time a full 8bits were required to be received by the Atari8(A8).  Four additional optoisolators were added to the Arduino Uno.  This way the Atari could look for the MIDI command number for NOTEON or NOTEOFF.  When NOTEON was detected at PORTA(joystick address) the computer would wait till the note number was set and the joystick trigger logic state changed.  The note number was then used to calculate the index for an array holding frequency settings. The Arduino did most of the work decoding the midi data.
 
You would almost think that a NOTEON would be followed by the NOTEOFF command before the next NOTEON command.  NOTSO,  when the Casio Keyboard was being used to test the hardware and software.  Eventually the Casio was hooked up to the IBM running a MIDI Monitor.  Press a note key and a NOTEON command was sent. Release the key and a NOTEON command was sent.  The only difference was the velocity setting.  Setting a NOTEON at 0 velocity does stop the note from being heard.
 
You would almost think that a NOTEON would be followed by the NOTEOFF command before the next NOTEON command.  NOTSO,  when MMS was used to create the MIDI data stream.  Some times the NOTEON command was issued before the last note turned on was turned off.  So, the NOTEOFF command received by the Arduino was sent to the Atari only if the note matched the last note turned on. 
 
 A function to set the output pins on the Arduino was used instead of the "case" used in the drum software.  Each bit of the note byte is checked starting at bit 0.  When the 7th bit is turned on the A8 computer knows it is a command byte that starts the process of turning on or off a note.  The A8 then waits for the joystick trigger button to change state to indicate the note number is ready to be read. delay()s are used to give the A8 enough time to check the PORTA and the trigger.
 
Project Software
 
The ATRs and Arduino source code are in the zip file.  The computers in the midi chain have no monitor so the programs for the drums and lead will autorun the BASIC programs.  SAM would not allow the autorun code to execute the BASIC program when appended onto end of the AUTORUN.SYS file, so an easy name of "A" was used to reduce typing required to RUN "D:A". The Arduino source code for each of the instruments are in the folder. Also, an ATR containing the MMS music and info files is included.
 
Attached File  SAM Rocks - support files.zip (72.72KB)
downloads: 17
 
 
That should be enough information if I ever want to rebuild this setup.  Its been nice to be able to write custom programs and build Arduino interfaces for each voice but I have to start thinking about….
 
 1.  A polyphonic A8 program for general use.
 2. Two way communication between the Arduino and A8
 3. Using commands beyond NOTEON and NOTEOFF
 4. Programming using MAC/65
 5. An editor for SAM to include pitch and speed manipulation
 6. Getting a new furnace before winter sets in.






Recent Comments

Latest Visitors