/* Example of using the 'midiroutines.a' from a C-language program */
/* Written by Teijo Kinnunen. */

/* linking info:
blink from lib:c.o+example1.o+midiroutines.o to example1 lib lib:lc.lib ND
*/

/* This simple example plays a C major chord using MIDI channel 1 */

#include "midiroutines.h"
#include <proto/dos.h>	/* eliminate the need of amiga.lib */

/* This is the Note On data we will send. We use separate Note On
   command (0x90) for each note to demonstrate that the automatic
   rsb-optimization really works. */
static UBYTE ondata[] = { 0x90,0x3c,0x40,0x90,0x40,0x40,0x90,0x43,0x40 };
/* And the Note Off data respectively. */
static UBYTE offdata[] = { 0x80,0x3c,0x40,0x80,0x40,0x40,0x80,0x43,0x40 };

void main()
{
	LONG fail;
	fail = GetSerial();
	if(fail) printf("Can't allocate serial port!\n");
	else {
		printf("Playing C Major chord...");
		AddMIDIData(ondata,9); /* length = 9 bytes */
		Delay(50); /* wait for about 1 second */
		AddMIDIData(offdata,9); /* turn off the notes */
		Delay(5); /* small pause for sending the note off msgs */
		printf("done.\n");
		FreeSerial();
	}
}
