home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.lbl.gov / 2014.05.ftp.ee.lbl.gov.tar / ftp.ee.lbl.gov / bmd-1.0beta.tar.Z / bmd-1.0beta.tar / bmd-1.0beta / app / omtd / setting.c < prev    next >
C/C++ Source or Header  |  1991-01-27  |  3KB  |  122 lines

  1. /*
  2.  * Copyright (c) 1990 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that the above copyright notice and this paragraph are
  7.  * duplicated in all such forms and that any documentation,
  8.  * advertising materials, and other materials related to such
  9.  * distribution and use acknowledge that the software was developed
  10.  * by the University of California, Lawrence Berkeley Laboratory,
  11.  * Berkeley, CA.  The name of the University may not be used to
  12.  * endorse or promote products derived from this software without
  13.  * specific prior written permission.
  14.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  15.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  16.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  17.  */
  18. #include <sys/types.h>
  19. #include "readline.h"
  20. #include "setting.h"
  21. #include "etime.h"
  22.  
  23. struct setting s;
  24.  
  25. init_settings()
  26. {
  27.     bzero((char *)&s, sizeof s);
  28.     s.end = ~0;
  29.     pt_insert(&s.tempo, 0, (float)1.0);
  30. }
  31. void
  32. set_command(tp)
  33.     struct token *tp;
  34. {
  35.     int n;
  36.     char **p;
  37.     static char *set_names[] =  {
  38.         "start",
  39. #define SETX_START 0
  40.         "end",
  41. #define SETX_END 1
  42.         "tpb", 
  43. #define SETX_TPB 2
  44.         "bpb", 
  45. #define SETX_BPB 3
  46.         0,
  47. #define SETX_LI 4,
  48.         "li",
  49.  
  50.     };
  51.     
  52.     if (tp == 0 || tp->t_id != TK_STR)
  53.     {
  54.         error("set variable value");
  55.         return;
  56.     }
  57.     for (n = 0, p = set_names; *p != 0; ++n, ++p)
  58.         if (strcmp(tp->t_str, *p) == 0)
  59.             break;
  60.     if (*p == 0)
  61.     {
  62.         error("variable name %s unknown", tp->t_str);
  63.         return;
  64.     }
  65.     tp = tp->next;
  66.  
  67.     if (tp == 0) {
  68.         error("error");
  69.         return;
  70.     }
  71.  
  72.     switch (n)
  73.     {
  74.     case SETX_START:
  75.         tp = parse_time(tp, &s.start);
  76.         if (tp != 0)
  77.             error("trailing garbage ignored");
  78.         break;
  79.         
  80.     case SETX_END:
  81.         tp = parse_time(tp, &s.end);
  82.         if (tp != 0)
  83.             error("trailing garbage ignored");
  84.         break;
  85.         
  86.     case SETX_BPB:
  87.         if (tp->t_id == TK_INT)
  88.             s.beats_per_bar = tp->t_int;
  89.         else
  90.             error("bpb must be an integer");
  91.         break;
  92.         
  93.     case SETX_TPB:
  94.         error("tpb cannot be modified");
  95.         break;
  96.  
  97. /*    case SETX_LI:
  98.         if (tp->t_id == TK_INT)
  99.             s.lead_in = tp->t_int;
  100.         else
  101.             error("li must be an integer");
  102.         break;
  103. */
  104.     }
  105. }
  106.  
  107. setting_command(tp)
  108.     struct token *tp;
  109. {
  110.     printf("start: ");
  111.     ptime(s.start);
  112.     printf("\nend: ");
  113.     ptime(s.end);
  114.     printf("\n");
  115.  
  116.     printf("beats-per-bar: %d\n", s.beats_per_bar);
  117.     printf("ticks-per-beat: %d\n", s.ticks_per_beat);
  118.     printf("echo channel: %d\n", s.echo_channel);
  119. /*    printf("number of lead in bars: %d\n", s.lead_in); */
  120. }
  121.  
  122.