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

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