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

  1. /* PgmName.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 MidiGetPgmNum to retrieve
  8.  * the MIDI program number for a given General MIDI Program name. When
  9.  * running the program, supply a defined Program Name. The program will
  10.  * print the respective program number for that Program name if a match
  11.  * is found. For example, "Grand Piano" or "Piano" is program #1 (ie, actually
  12.  * program 0). Otherwise, a message is printed 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 pgm;
  32.  
  33.     /* Check if any parameters were given, if not, display some help info */
  34.     if (argc < 2)
  35.     {
  36.     _cputs("Displays the program number for a specified General MIDI Program Name.\r\n\nSyntax is '");
  37.     _cputs(argv[0]);
  38.     _cputs( " name'.\r\n    where name is a Program Name (use double quotes if it contains spaces).\r\n");
  39.     _cputs( "    For example, \"Grand Piano\" is program 1 (actually program 0).\r\n\n");
  40.     _cputs("Version 1.0\r\n");
  41.     exit(0);
  42.     }
  43.  
  44.     /* Find a match to the supplied Program Name */
  45.     pgm = MidiGetPgmNum(argv[1]);
  46.  
  47.     /* Is this a defined Program name? If so, then the returned program number isn't 0xFF */
  48.     if (pgm == 0xFF)
  49.     {
  50.     printf("\"%s\" is not one of the defined names.\r\n", argv[1]);
  51.     }
  52.  
  53.     /* Print the program number (and also get the full Program name in case the user supplied a substring) */
  54.     else
  55.     {
  56.     printf("\"%s\" is program %u. (%u if 0 is considered the first patch).\r\n", MidiGetPgmStr(pgm), pgm+1, pgm);
  57.     }
  58.  
  59.     exit(0);
  60. }
  61.