Jump to content
  • entries
    97
  • comments
    63
  • views
    74,554

MIDI Computer Blues: Note On - Note Off


k-Pack

839 views

The Arduino is receiving data from the 850 and can send data to a MIDI device. The trick now is to get the MIDI command data from the 850 and send it to the MIDI device.

There was nothing but silence from the synthesizer during the first day of programming. I would have had a sleepless night but decided to go to bed and skim the 850 manual for possible fixes. Fell asleep within 5 minutes.

The Arduino sketch seems simple enough. Read 3 bytes - Write 3 bytes. Just be sure the pin assignments are correct when defining the SoftwareSerial RS850 port.

/*RS232 to MIDI
* Pack007 9/2/2016
*
* Program reads any 3 byte MIDI command from an RS-232 port
* and re-transmits it to a MIDI device.
*
*/
#include <SoftwareSerial.h>

SoftwareSerial RS850(5,6);

void setup() {
RS850.begin(9600);
Serial.begin(31250);
}

void loop() {
int cmd;
int note;
int velocity;
while(RS850.available()<3){}//wait for data from Atari
cmd = RS850.read();
note = RS850.read();
velocity = RS850.read();
Serial.write(cmd);
Serial.write(note);
Serial.write(velocity);
}


The BASIC test program can play middle C over and over and over……,again. This required the use of 2 MIDI commands, Note On and Note Off. Both commands consist of 3 bytes.

The first byte is made of the 4 bit command plus the channel voice number(MIDI channel -1) . Note On - 1001, Channel 1 - 0000 = 10010000 binary = 144. Note Off Command + channel number is 128. The Second byte is the MIDI Note Number (0 - 127), 60 is middle C and third is the velocity(0-127).

MIDI Message Chart-
https://www.midi.org/specifications/item/table-1-summary-of-midi-message




MIDITEST.BAS

10 REM MIDI TEST - PACK007 9/2/2016
20 REM
30 REM STROBES A NOTE ON NOTE OFF
40 REM COMAND TO A RS232 IN/MIDI OUT-
50 REM ARDUINO SETUP.
60 REM
100 CLOSE #1
110 OPEN #1,9,0,"R2:":REM OUTPUT
120 XIO 36,#1,14,0,"R2:":REM 9600
130 XIO 38,#1,32,0,"R2:":REM NO TRANS
200 CMD=144:REM NOTE ON - CHANNEL 1
210 MIDINOTE=60:REM MIDDLE C
220 VELOCITY=45:REM RANGE 0-127
230 GOSUB 1000
240 FOR X=1 TO 100:NEXT X
250 CMD=128:REM NOTE OFF - CHANNEL 1
260 MIDINOTE=60
270 VELOCITY=0
280 GOSUB 1000
290 FOR X=1 TO 25:NEXT X
300 GOTO 200
990 REM OUTPUT ROUTINE
1000 PUT #1,CMD
1010 PUT #1,MIDINOTE
1020 PUT #1,VELOCITY
1030 XIO 32,#1,0,0,"R2:":REM FORCE SHORT BLOCK
1040 RETURN

It was rather exciting when I heard that note sound, then turn off, then turn on and then……….. I could talk about what it took to get the program to work but it would take from the magic. I do suggest rereading about the XIO 32 command in the 850 manual. There's magic in them words.

Try this. Delete line 260 and 290. Then Input "210 MIDINOTE = INT(RAN(0)* 13)+60".

Then I had to remind myself that the point of this exercise is to modify the Computer Blues program not to tweak this one. I'll also need to digitize the audio so that we can all enjoy the music.

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...