/* GMON sends General MIDI ON message  MPU-401/SB MIDI */

#include <stdio.h>
#include <ctype.h>
#include <midi.h>
#include <sbc.h>
#include <chkblast.c>

void (*ifputl)();

int iface;
#define MPU 0
#define SB  1

char gmon[] = {0xf0,0x7e,0x7f,0x09,0x01,0xf7};

main(int argc, char **argv)
{
       if(argc > 1)
       {
               switch(toupper(argv[1][0])) {
                       case 'S': iface = SB;
                                                ifputl = sbmidi_putl;
                                                break;
                       case 'M': iface = MPU;
                                                ifputl = mpu_putl;
                                                break;
                       default : printf("Incorrect parameter! Use 'm' or 's'\n");
                                                exit(1);
               }

               printf("Sending GM ON...\n");

               if(iface == MPU)
                       mpu_init();
               else
               {
                       if(! Check_Blaster())
                               sbmidi_init(ct_int_num);
                       else
                               exit(1);
               }

               (*ifputl)(gmon,6,1);

               if(iface == MPU)
                       mpu_exit();
               else
                       sbmidi_exit();
       }
       else
       {
               printf("GMON  Sends General MIDI ON message\n");
               printf("usage: gmon <iface>    iface: m = MPU-401  s = SB MIDI\n");
       }
}