home *** CD-ROM | disk | FTP | other *** search
/ Chestnut's Multimedia Mania / MM_MANIA.ISO / midi / cmtcmu / recmain.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-28  |  4.2 KB  |  136 lines

  1. /*****************************************************************************
  2. *        Change Log
  3. *  Date        | Change
  4. *-----------+-----------------------------------------------------------------
  5. * 12-Mar-86 | Created
  6. *****************************************************************************/
  7. /*   Record: scan command line, call phase1, trans2 */
  8.  
  9. #include "cext.h"
  10. #include "stdio.h"
  11. #include "adagio.h"
  12. #include "phase1.h"
  13. #include "phase2.h"
  14. #include "atxt.h"
  15. #include "userio.h"
  16. #include "cmdline.h"
  17.  
  18. char score_na[name_length];    /* this will be available to phase1 and 2 */
  19. char outfile[name_length];    /* output file name used by trans2 */
  20.  
  21. /* Variables set by command line switches */
  22.  
  23. extern int musictrace;
  24. extern int miditrace;
  25. extern int IsAT;
  26. extern int debug_intr;
  27. extern int debug_rec;
  28. boolean poll = false;        /* true if poll, false if interrupt */
  29. boolean no_mpu = false;        /* true if simulated */
  30.  
  31. #define nswitches 15
  32. private char *switches[nswitches] = 
  33.     { "-debug", "-d", "-help", "-miditrace", "-m", "-trace", "-t", "-at",
  34.       "-metronome", "-met", "-simulated", "-s", "-xt", "-print", "-block" };
  35.  
  36. #define noptions 5
  37. private char *options[noptions] = { "-c", "-control", "-out", "-o", "-tune" };
  38.  
  39. #define nmsw 2
  40. private char *msw[nmsw] = { "-met", "-metronome" };
  41.  
  42. #define noopt 2
  43. private char *oopt[noopt] = { "-o", "-out" };
  44.  
  45. #define nssw 2
  46. private char *ssw[nssw] = { "-simulated", "-s" };
  47.  
  48. /****************************************************************************
  49. *    Routines local to this module
  50. ****************************************************************************/
  51. private void cmdline_help();
  52.  
  53. /****************************************************************************
  54. *                 cmdline_help
  55. * Effect: 
  56. *    Prints out command line help
  57. ****************************************************************************/
  58.  
  59. private void cmdline_help()
  60. {
  61.     fprintf(stderr,"adagio [options] filename [options]\n");
  62.     fprintf(stderr,"     Options are below.  Those with * are for wizrds:\n");
  63.     fprintf(stderr,"*       -at             PC/AT (secondary interrupt channel)\n");
  64.     fprintf(stderr,"       -block         disable MIDI thru\n");
  65.     fprintf(stderr,"       -debug (-d)         enable verbose debug mode\n");
  66.     fprintf(stderr,"       -help         this message\n");
  67.     fprintf(stderr,"       -metronome (-met) turn on MPU-401 metronome\n");
  68.     fprintf(stderr,"       -miditrace (-m)   turn on MIDI command trace\n");
  69.     fprintf(stderr,"       -print         print note data\n");
  70.     fprintf(stderr,"       -tune file         use tuning from file\n");
  71.     fprintf(stderr,"       -simulated (-s)   run with simulated MPU-401\n");
  72.     fprintf(stderr,"       -trace (-t)         trace music\n");
  73.     fprintf(stderr,"*       -xt             PC/XT (no secondary interrupt channel)\n");
  74. }
  75.  
  76. /****************************************************************************
  77. *                     main
  78. * Inputs:
  79. *    int argc: Count of arguments
  80. *    char * argv[]: Vector of argument pointers
  81. * Effect: 
  82. *    Runs record program.
  83. ****************************************************************************/
  84.  
  85. void main(argc,argv)
  86.    int argc;
  87.    char * argv[];
  88. {
  89.     FILE *fp = NULL;
  90.     char *s;    /* temp pointer to input and output file names */
  91.  
  92.     cl_init(switches, nswitches, options, noptions, argv, argc);
  93.  
  94.     outfile[0] = 0;    /* initialize file names to null strings */
  95.     score_na[0] = 0;
  96.  
  97.     if (cl_switch("-help")) {
  98.     cmdline_help(); 
  99.     return;
  100.     }
  101.  
  102.     IsAT = (ATXT() == ISAT);
  103.     if (cl_switch("-at")) {
  104.     if (!IsAT) { /* lie! */
  105.         fprintf(stderr,"-at but not running on PC/AT!\n");
  106.         return;
  107.     }
  108.     }
  109.  
  110.     if (cl_nswitch(msw, nmsw) != NULL)
  111.      metronome(true);
  112.  
  113.     s = cl_noption(oopt, noopt);
  114.     if (s != NULL) strcpy(outfile, s);
  115.  
  116.     if (cl_switch("-help")) {
  117.     cmdline_help(); 
  118.     return;
  119.     }
  120.  
  121.     if (cl_nswitch(ssw, nssw) != NULL) no_mpu = true;
  122.  
  123.     if (cl_switch("-xt")) {
  124.     if (ISAT) { /* lie! */
  125.         fprintf(stderr,"-xt but running on PC/AT!\n");
  126.         return;
  127.     }
  128.     }
  129.  
  130.     if ((s = cl_arg(1)) != NULL) strcpy(score_na, s);
  131.  
  132.     fp = fileopen(score_na, "gio", "r", "Name of Adagio score file");
  133.     phase2(phase1(fp));
  134.     return;
  135. }
  136.