home *** CD-ROM | disk | FTP | other *** search
/ Millennium Time Capsule / AC2000.BIN / disks / ac11disk / midiseq / drawmenu.c next >
Encoding:
C/C++ Source or Header  |  1998-06-10  |  3.4 KB  |  137 lines

  1. /*
  2.  *    'interface' code for MIDI sequencer
  3.  *
  4.  *    this code draws the on-screen menu, as well
  5.  *    as handling most of the text redraws, and the
  6.  *    Atari keyboard input for editing settings...
  7.  *    it's all pretty self-explanatory!
  8.  *    
  9.  *
  10.  */
  11.  
  12. #include "globals.h"
  13.  
  14. extern TRACK     trk;
  15.  
  16.  
  17. void     draw_menu(void);
  18. void    move_cursor(int, int);
  19. int     keybd_input(char, short);
  20.  
  21.  
  22. void draw_menu(void)
  23. {
  24.     int x;
  25.     printf("\033H\033f\n Mini-MIDI sequencer");
  26.     printf("\n ----------------------------------------");
  27.     printf("\n tempo      : %3d bpm       [-]/[+]", trk.tempo);
  28.     printf("\n play mode  : stopped       [f]/[b]/[r]");
  29.     printf("\n transpose  : %3d semitones [1]/[2]", trk.transpose);
  30.     printf("\n channel    : %3d           [3]/[4]", trk.channel+1);
  31.     printf("\n program    : %3d           [5]/[6]", trk.patch);
  32.     printf("\n ----------------------------------------\n");
  33.     printf("\n track note data:");
  34.     printf("\n ----------------------------------------\n ");
  35.     for(x=0;x<8;x++)    printf(" %3d", trk.note[x]);
  36.     printf("\n\n ----------------------------------------");
  37.     printf("\n other controls:");
  38.     printf("\n [x]... exit program\n [a]... send all-notes off");
  39.     printf("\n [s]... stop sequencer\n [d]... delete note");
  40. }
  41.  
  42.  
  43. int keybd_input(char k, short ctr)
  44. {
  45.     switch(k)
  46.     {
  47.         case 'x':    return 0;
  48.         case 'a':
  49.             all_notes_off();
  50.             break;
  51.         case 'd':
  52.             trk.note[ctr] = trk.vel[ctr] = 0;
  53.             move_cursor(12, ctr*4 + 1);
  54.             printf(" %3d ", trk.note[ctr]);
  55.         case '=':    
  56.             if(++trk.tempo > 300)    trk.tempo = 300;     
  57.             move_cursor(3, 14);    
  58.             printf("%3d", trk.tempo);
  59.             break;
  60.         case '-':    
  61.             if(--trk.tempo < 40)    trk.tempo = 40;        
  62.             move_cursor(3, 14);
  63.             printf("%3d", trk.tempo);
  64.             break;
  65.         case 'f': 
  66.             if(((trk.playmode&0x02)>>1) == ON)    break;
  67.             trk.playmode = 0x02;
  68.             move_cursor(4, 14);
  69.             printf("forwards ");
  70.             break;
  71.         case 'b':
  72.             if(((trk.playmode&0x04)>>2) == ON)    break;
  73.             trk.playmode = 0x04;
  74.             move_cursor(4, 14);
  75.             printf("backwards");
  76.             break;
  77.         case 'r':
  78.             if(((trk.playmode&0x08)>>3) == ON)     break;
  79.             trk.playmode = 0x08;
  80.             move_cursor(4, 14);
  81.             printf("random   ");
  82.             break;
  83.         case 's':
  84.             if((trk.playmode&0x01)==ON)    break;
  85.             trk.playmode = 0x01;
  86.             move_cursor(4, 14);
  87.             printf("stopped  ");
  88.             all_notes_off();
  89.             break;
  90.         case '2':
  91.             if(++trk.transpose > 24)    trk.transpose = 24;
  92.             move_cursor(5, 14);
  93.             printf("%3d", trk.transpose);
  94.             break;
  95.         case '1':
  96.             if(--trk.transpose < -24)    trk.transpose = -24;
  97.             move_cursor(5, 14);
  98.             printf("%3d", trk.transpose);
  99.             break;
  100.         case '3':
  101.             if(--trk.channel < 0)    trk.channel = 0;
  102.             move_cursor(6, 14);
  103.             printf("%3d", trk.channel+1);
  104.             send_program_change(trk.channel, trk.patch);
  105.             break;
  106.         case '4':
  107.             if(++trk.channel > 15)    trk.channel = 15;
  108.             move_cursor(6, 14);
  109.             printf("%3d", trk.channel+1);
  110.             send_program_change(trk.channel, trk.patch);
  111.             break;
  112.         case '5':
  113.             if(--trk.patch < 0)        trk.patch = 0;
  114.             move_cursor(7, 14);
  115.             printf("%3d", trk.patch);
  116.             send_program_change(trk.channel, trk.patch);
  117.             break;
  118.         case '6':
  119.             if(++trk.patch > 127)    trk.patch = 127;
  120.             move_cursor(7, 14);
  121.             printf("%3d", trk.patch);
  122.             send_program_change(trk.channel, trk.patch);
  123.             break;
  124.         default:
  125.             break;
  126.     }
  127.     return 1;
  128. }
  129.  
  130.  
  131.  
  132. void move_cursor(int x, int y)
  133. {
  134.     /* redraw cursor in the new screen position */
  135.     printf("\033Y%c%c", (char)(32+x), (char)(32+y) );
  136. }
  137.