home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / genmidi.zip / drumnum / drumnum.c next >
Text File  |  1995-07-19  |  2KB  |  84 lines

  1. /* DrumNum.c
  2.  *
  3.  * An example of using GENMIDI.DLL, a DLL that has functions to retrieve
  4.  * General MIDI Patch names, Drum Key names, and Controller names from
  5.  * their respective MIDI values, and vice versa.
  6.  *
  7.  * This example shows how to call the DLL function MidiGetDrumStr to retrieve
  8.  * the General MIDI Drum Key name for a given MIDI note number. When
  9.  * running the program, supply a number from 0 to 127 inclusive. The program
  10.  * will print the respective GM Drum Key name for that note number. For
  11.  * example, note #36 is "Kick 1".
  12.  *
  13.  * Typing a number > 127 causes all defined Drum Key names to be displayed.
  14.  */
  15.  
  16. #define INCL_DOSPROCESS
  17. #define INCL_WINSTDFILE
  18. #define INCL_DOSMEMMGR
  19. #define INCL_DOSFILEMGR
  20.  
  21. #include <os2.h>
  22. #include <stdio.h>
  23. #include <conio.h>
  24. #include <string.h>
  25. #include "genmidi.h"
  26.  
  27.  
  28. /* ********************************* main() ********************************* */
  29.  
  30. VOID main(int argc, char *argv[], char *envp[])
  31. {
  32.     ULONG    drum;
  33.     UCHAR * str;
  34.     UCHAR     i;
  35.  
  36.     /* Check if any parameters were given, if not, display some help info */
  37.     if (argc < 2)
  38.     {
  39.     _cputs("Displays the General MIDI Drum key Name for the specified note number.\r\n\nSyntax is '");
  40.     _cputs(argv[0]);
  41.     _cputs( " note'.\r\n    where note is a note number from 0 to 127 inclusive.\r\n");
  42.     _cputs( "    For example, note 36 is 'Kick 1'.\r\n");
  43.     _cputs( "    Specifying a number > 127 displays all defined Drum Key Names.\r\n\n");
  44.     _cputs("Version 1.0\r\n");
  45.     exit(0);
  46.     }
  47.  
  48.     /* Get the note number (as a binary value) */
  49.     drum = atoi(argv[1]);
  50.  
  51.     /* See if he wants all defined Drum Key Names displayed. If so, print 3 upon each line */
  52.     if (drum > 127)
  53.     {
  54.     i=0;
  55.     for (drum=0; drum<128; drum++)
  56.     {
  57.         if (i && !(i%3))
  58.         {
  59.         _printf("\r\n");
  60.         i=0;
  61.         }
  62.  
  63.         str = MidiGetDrumStr(0, drum);
  64.  
  65.         /* Is this a defined Drum Key? If so, then the returned string isn't null */
  66.         if (*str)
  67.         {
  68.         printf("%3u %-16s", drum, str);
  69.         ++i;
  70.         }
  71.     }
  72.     }
  73.  
  74.     /* Print just the 1 GM Drum Key Name */
  75.     else
  76.     {
  77.     str = MidiGetDrumStr(0, drum);
  78.     if (!(*str)) str = "is undefined.";
  79.     printf("%u %s\r\n", drum, str);
  80.     }
  81.  
  82.     exit(0);
  83. }
  84.