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

  1. /* DrumKey.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 MidiGetDrumNum to retrieve
  8.  * the MIDI note number for a given General MIDI Drum Key name. When
  9.  * running the program, supply a defined Drum Key Name. The program
  10.  * will print the respective note number for that GM Drum Key name if a match is
  11.  * found. For example, "Kick 1" is note #36. Otherwise, a message is printed
  12.  * that the name is not found.
  13.  */
  14.  
  15. #define INCL_DOSPROCESS
  16. #define INCL_WINSTDFILE
  17. #define INCL_DOSMEMMGR
  18. #define INCL_DOSFILEMGR
  19.  
  20. #include <os2.h>
  21. #include <stdio.h>
  22. #include <conio.h>
  23. #include <string.h>
  24. #include "genmidi.h"
  25.  
  26.  
  27. /* ********************************* main() ********************************* */
  28.  
  29. VOID main(int argc, char *argv[], char *envp[])
  30. {
  31.     UCHAR    drum;
  32.  
  33.     /* Check if any parameters were given, if not, display some help info */
  34.     if (argc < 2)
  35.     {
  36.     _cputs("Displays the note number for a specified General MIDI Drum Key Name.\r\n\nSyntax is '");
  37.     _cputs(argv[0]);
  38.     _cputs( " key'.\r\n    where key is a Drum Key Name (use double quotes if it contains spaces).\r\n");
  39.     _cputs( "    For example, \"Kick 1\" is note 36.\r\n\n");
  40.     _cputs("Version 1.0\r\n");
  41.     exit(0);
  42.     }
  43.  
  44.     /* Find a match to the supplied Drum Key Name */
  45.     drum = MidiGetDrumNum(0, argv[1]);
  46.  
  47.     /* Is this a defined Drum Key? If so, then the returned note number isn't 0xFF */
  48.     if (drum == 0xFF)
  49.     {
  50.     printf("\"%s\" is not one of the defined names.\r\n", argv[1]);
  51.     }
  52.  
  53.     /* Print the note number (and also get the full Drum Key name in case the user supplied a substring) */
  54.     else
  55.     {
  56.     printf("\"%s\" is note number %u.\r\n", MidiGetDrumStr(0, drum), drum);
  57.     }
  58.  
  59.     exit(0);
  60. }
  61.