home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / mt / mtrc1.c < prev    next >
C/C++ Source or Header  |  1989-01-13  |  8KB  |  203 lines

  1. /* mtrc1.c   recorder module for mt */
  2. /* `MIDI Sequencing In C', Jim Conger, M&T Books, 1989 */
  3.  
  4. #include <stdio.h>  /* compiler library headers */
  5. #include <conio.h>
  6. #include <string.h>
  7. #include <stdlib.h>
  8.  
  9. #include "screenf.h"
  10. #include "standard.h"
  11. #include "mpu401.h"
  12. #include "mt.h"
  13. #include "video.h"
  14. #include "mtdeclar.h"
  15.  
  16.  
  17. void
  18. record_menu(void)           /* runs MT's record menu */
  19. {
  20.     int i, ans, pick, lastpick, track, param, x, nevent;
  21.     int *enter_int;
  22.     char buf[80], nbuf[10];
  23.     
  24.     calc_pct_free();        /* update amount of free memory available */
  25.     enter_int = &x;
  26.     pick = 0;
  27.  
  28.     while (1){
  29.         init_track_str();               /* put track names, etc in menu */
  30.         clearscreen(g_norm_attrib);     /* clear screen and disp menu */
  31.         fdispchain(g_chain[2], 1, g_norm_attrib, g_text_mode);
  32.         
  33.                                                 /* put values at top */
  34.         finitscrn(mt2, 0, NPARAM2 - 1, g_emph_attrib, g_text_mode);
  35.         init_rec_val();                         /* put values at bottom */
  36.         
  37.         /* allow cursor movement to select a menu item, pick is item # */
  38.         lastpick = pick;
  39.         pick = movescrn(g_text_mode, mt2, pick, NPARAM2 - 1, g_emph_attrib,
  40.             g_cursor_attrib);
  41.         
  42.                             /* if at the top part of the record screen... */
  43.         if (pick >= 0 && pick < NTRACK * N_TRACK_PARAM){
  44.             track = pick % NTRACK;
  45.             param = (pick - track) / NTRACK;
  46.             switch (param){
  47.             case (0):           /* track name */
  48.                 ans = getstr(g_text_char_v - 1,"Enter track name (8 chars max)->", 
  49.                     buf, 8, g_norm_attrib);
  50.                 if (ans){
  51.                     strcpy(mt2[pick].content, buf);
  52.                     strcpy(g_trackarray[track].name, buf);
  53.                 }
  54.                 break;
  55.             case (1):           /* midi channel number */
  56.                 ans = getint(g_text_char_v - 1, 
  57.                     "Enter the MIDI channel number for this track (1-16)->",
  58.                         enter_int, 1, 16, g_norm_attrib, g_emph_attrib);
  59.                 if (ans){
  60.                     itoa(*enter_int, nbuf, 10);
  61.                     strcpy(mt2[pick].content, nbuf);
  62.                     g_trackarray[track].midichan = --*enter_int;
  63.                     change_channel(track, *enter_int);
  64.                 }
  65.                 break;
  66.             case (2):           /* track select toggle */
  67.                 if (g_record_track == track)
  68.                     g_record_track = -1;
  69.                 else
  70.                     g_record_track = track;
  71.                 break;
  72.             case (3):           /* play toggle */           
  73.                 if (g_trackarray[track].active){
  74.                     g_trackarray[track].active = 0;
  75.                 }
  76.                 else{
  77.                     g_trackarray[track].active = 1;
  78.                     if (track == g_record_track)
  79.                         g_record_track = -1;
  80.                 }
  81.                 break;              
  82.             case (4):           /* record toggle */
  83.                 if (g_record_track == track)
  84.                     g_record_track = -1;
  85.                 else
  86.                     g_record_track = track;
  87.                 break;
  88.             case (5):           /* MIDI volume */
  89.                 ans = getint(g_text_char_v - 1, "Enter MIDI volume (1-100)->", 
  90.                     enter_int, 1, 100, g_norm_attrib, g_emph_attrib);
  91.                 if (ans){
  92.                     itoa(*enter_int, nbuf, 10);
  93.                     strcpy(mt2[pick].content, nbuf);
  94.                     g_trackarray[track].midivol = *enter_int;
  95.                 }
  96.                 break;
  97.             case (6):           /* bytes */
  98.                 writerr("You can not change this value - automatically set.",
  99.                     g_text_char_v - 1, g_norm_attrib, g_emph_attrib);
  100.                 break;
  101.             }               
  102.         }
  103.         else{       /* must be at the bottom, command part of record screen */
  104.             switch (pick){
  105.             case (56):      /* RECORD */
  106.                 record();
  107.                 break;
  108.             case (57):      /* End Tracks */
  109.                 g_current_measure = goto_measure(32000);
  110.                 break;
  111.             case (58):      /* Erase Track */
  112.                 erase_track();
  113.                 calc_pct_free();
  114.                 break;
  115.             case (59):      /* MET ON/OFF */
  116.                 if (g_meton)
  117.                     g_meton = 0;
  118.                 else
  119.                     g_meton = 1;
  120.                 break;
  121.             case (60):      /* Fast Forward */
  122.                 g_current_measure = goto_measure(g_current_measure + 10);
  123.                 break;
  124.             case (61):      /* Clear Forward */
  125.                 clear_forward();
  126.                 g_block_on = 0;
  127.                 calc_pct_free();
  128.                 break;
  129.             case (62):      /* Beats/Measure */
  130.                 if (count_events() > NTRACK)
  131.                     writerr("You can only change meter if tracks are empty.",
  132.                         g_text_char_v - 1, g_norm_attrib, g_emph_attrib);
  133.                 else{
  134.                     ans = getint(g_text_char_v - 1,"Enter beats per measure ->",
  135.                         enter_int, 1, 20, g_norm_attrib, g_emph_attrib);
  136.                     if (ans == 1)
  137.                         g_meter = *enter_int;
  138.                 }
  139.                 break;
  140.             case (63):      /* PLAY */
  141.                 play();
  142.                 break;
  143.             case (64):      /* Forward */
  144.                 g_current_measure = goto_measure(g_current_measure + 1);
  145.                 break;
  146.             case (65):      /* Data Dump */
  147.                 data_dump();
  148.                 break;
  149.             case (66):      /* BPM */
  150.                 ans = getint(g_text_char_v - 1,
  151.                     "Enter metronome rate in beeps/min ->", 
  152.                         enter_int ,8, 200, g_norm_attrib, g_emph_attrib);
  153.                 if (ans == 1)
  154.                     g_metrate = *enter_int;
  155.                 break;
  156.             case (67):      /* Rewind */
  157.                 g_current_measure = goto_measure(g_current_measure - 1 < 0 ?
  158.                     0 : g_current_measure - 1);
  159.                 break;
  160.             case (68):      /* pitch bend toggle */
  161.                 if (g_pitchbend)
  162.                     g_pitchbend = 0;
  163.                 else
  164.                     g_pitchbend = 1;
  165.                 break;
  166.             case (69):      /* all notes off */
  167.                 if (g_trace_on)
  168.                     trace_header();
  169.                 all_notes_off();
  170.                 if (g_trace_on)
  171.                     wait_for_key();
  172.                 break;
  173.             case (70):      /* Fast Rewind */
  174.                 g_current_measure = goto_measure(g_current_measure - 10 < 0 ?
  175.                     0 : g_current_measure - 10);
  176.                 break;
  177.             case (71):      /*  Exclusive pass through on/off */
  178.                 if (g_exclusive)
  179.                     g_exclusive = 0;
  180.                 else
  181.                     g_exclusive = 1;
  182.                 break;
  183.             case (73):      /* Begin Tracks */
  184.                 g_current_measure = goto_measure(0);
  185.                 break;
  186.             case (74):      /* Data Trace */
  187.                 if (g_trace_on)
  188.                     g_trace_on = 0;
  189.                 else
  190.                     g_trace_on = 1;
  191.                 break;
  192.             case (-2):          /* ESC key */
  193.             case (72):   /* QUIT */
  194.                 return;
  195.             default:
  196.                 writerr("Use arrow keys to move cursor, ret to select.",
  197.                     g_text_char_v - 1, g_norm_attrib, g_emph_attrib);
  198.                 pick = lastpick;
  199.             }
  200.         }
  201.     }
  202. }
  203.