home *** CD-ROM | disk | FTP | other *** search
/ Audio 4.94 - Over 11,000 Files / audio-11000.iso / msdos / midi / syskey / sysx.cpp < prev   
Encoding:
C/C++ Source or Header  |  1993-03-28  |  1.2 KB  |  64 lines

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <iostream.h>
  4. #include <math.h>
  5. #include <string.h>
  6.  
  7.  
  8. void write_file(char *filename, int channel,int value)
  9. {
  10.   int check;
  11.   FILE *fp;
  12.  
  13.   fp=fopen(filename,"wb");
  14. //header info
  15.   putc(0xf0,fp);
  16.   putc(0x41,fp);
  17.   putc(0x10,fp);
  18.   putc(0x42,fp);
  19. //commnad
  20.   putc(0x12,fp);
  21. //data address
  22.   putc(0x40,fp);
  23.   putc(0x10+channel,fp);
  24.   putc(0x16,fp);
  25. //data itself
  26.   putc(value,fp);
  27. //checksum
  28.   check=256-(0x40+0x16+0x10+channel+value);
  29.   putc(check,fp);
  30. //end of sysx marker....
  31.   putc(0xf7,fp);
  32.   fclose(fp);
  33. }
  34.  
  35.  
  36. main()
  37. {
  38.   char filename[15]="key";
  39.   char target[15]="";
  40.   int channel,value;
  41.   for(int i=1; i<17;i++)
  42.   {
  43.     channel=i;
  44.     if(i==10)
  45.       channel=0;
  46.     if(i>10)
  47.       channel=i-1;
  48.     for(value=0x28; value<=0x58; value+=4)
  49.     {
  50.       strcpy(filename,"");
  51.       strcat(filename,itoa(i,target,10));
  52.       strcat(filename,"key");
  53.       if((value-64)<0)
  54.     strcat(filename,"n");
  55.       else
  56.     strcat(filename,"p");
  57.       strcat(filename,itoa((abs(value-64)),target,10));
  58.       strcat(filename,".syx");
  59.       cout<<filename<<'\n';
  60.       write_file(filename,channel,value);
  61.     }
  62.   }
  63. }
  64.