Exemplo n.º 1
0
int main(int argc, char *argv[])
{
    char host_name[256], exp_name[32];

    cm_get_environment(host_name, sizeof(host_name), exp_name,
		       sizeof(exp_name));
    cm_connect_experiment(host_name, exp_name, "Compression", NULL);
    cm_get_experiment_database(&hDB, NULL);

    compress_load_all();

    if(argc != 2) {
      printf("Usage: mucap_optimize uncompressed_input.mid\n"); 
      exit(1);
    }

    FILE *fp = fopen(argv[1], "r");
    if (!fp) {
      printf("Unable to open %s\n", argv[1]);
      exit(1);
    }

    char *input_event = new char[MAX_EVENT_SIZE];
    char *output_event = new char[MAX_EVENT_SIZE];

    while (read_midas_event(fp, input_event) == SUCCESS) {
        EVENT_HEADER header = *((EVENT_HEADER *) input_event);

        int event_id = header.event_id;

        if (event_id == EVENTID_BOR || event_id == EVENTID_EOR ||
            event_id == EVENTID_MESSAGE) {

          continue;
        } 

        bk_init32(output_event);
        compress_event(input_event + sizeof(EVENT_HEADER), output_event);
    }

    compress_optimize_all();

    fclose(fp);

    cm_disconnect_experiment();
}
Exemplo n.º 2
0
int main(int argc, char **argv)
{
   char host_name[HOST_NAME_LENGTH], exp_name[NAME_LENGTH], fe_name[256], rpc_server[256];
   char cmd[256];
   INT i, status;
   BOOL debug, cmd_mode = FALSE;

   /* set default */
   host_name[0] = '\0';
   exp_name[0] = '\0';
   fe_name[0] = '\0';
   rpc_server[0] = '\0';
   debug = FALSE;

   /* get parameters */
   cm_get_environment(host_name, sizeof(host_name), exp_name, sizeof(exp_name));

   /* parse command line parameters */
   for (i = 1; i < argc; i++) {
      if (argv[i][0] == '-' && argv[i][1] == 'd')
         debug = TRUE;
      else if (argv[i][0] == '-') {
         if (i + 1 >= argc || argv[i + 1][0] == '-')
            goto usage;
         if (strncmp(argv[i], "-e", 3) == 0)
            strcpy(exp_name, argv[++i]);
         else if (strncmp(argv[i], "-h", 3) == 0)
            strcpy(host_name, argv[++i]);
         else if (strncmp(argv[i], "-f", 3) == 0)
            strcpy(fe_name, argv[++i]);
         else if (strncmp(argv[i], "-s", 3) == 0)
            strcpy(rpc_server, argv[++i]);
         else if (argv[i][1] == 'c') {
            if (strlen(argv[i]) >= 256) {
               printf("error: command line too long (>256).\n");
               return 0;
            }
            strcpy(cmd, argv[++i]);
            cmd_mode = TRUE;
         } else {
          usage:
            printf
                ("usage: mcnaf [-f Frontend] [-h Hostname] [-e Experiment] [-s RPC server]\n");
            printf("             [-c Command] [-c @CommandFile] \n\n");
            return 0;
         }
      }
   }

   if (rpc_server[0])
      status = cam_init_rpc("", "", "", "mcnaf", rpc_server);
   else
      status = cam_init_rpc(host_name, exp_name, fe_name, "mcnaf", "");
   if (status == SUCCESS) {
      status = cam_init();
      if (status == SUCCESS)
         status = cnafsub(cmd_mode, cmd);
   }
   cam_exit();
//  printf("status:%d\n", status);
   return status;
}
Exemplo n.º 3
0
int main(int argc, char *argv[])
{
   BOOL daemon = FALSE;
   INT status, i, ch;
   char host_name[HOST_NAME_LENGTH];
   char exp_name[NAME_LENGTH];
   char *speech_program = SPEECH_PROGRAM;

   /* get default from environment */
   cm_get_environment(host_name, sizeof(host_name), exp_name, sizeof(exp_name));

#ifdef OS_DARWIN
   strlcpy(mtTalkStr, "afplay $MIDASSYS/utils/notify.wav", sizeof(mtTalkStr));
   strlcpy(mtUserStr, "afplay $MIDASSYS/utils/notify.wav", sizeof(mtTalkStr));
#endif   

   /* parse command line parameters */
   for (i = 1; i < argc; i++) {
      if (argv[i][0] == '-' && argv[i][1] == 'D')
         daemon = TRUE;
      else if (argv[i][0] == '-') {
         if (i + 1 >= argc || argv[i + 1][0] == '-')
            goto usage;
         if (argv[i][1] == 'e')
            strcpy(exp_name, argv[++i]);
         else if (argv[i][1] == 'h')
            strcpy(host_name, argv[++i]);
         else if (argv[i][1] == 'c')
            speech_program = argv[++i];
         else if (argv[i][1] == 't')
            strcpy(mtTalkStr, argv[++i]);
         else if (argv[i][1] == 'u')
            strcpy(mtUserStr, argv[++i]);
         else if (argv[i][1] == 's')
            shutupTime = atoi(argv[++i]);
         else {
          usage:
            printf
                ("usage: mlxspeaker [-h Hostname] [-e Experiment] [-c command] [-D] daemon\n");
            printf("                  [-t mt_talk] Specify the mt_talk alert command\n");
            printf("                  [-u mt_user] Specify the mt_user alert command\n");
            printf("                  [-s shut up time] Specify the min time interval between alert [s]\n");
            printf("                  The -t & -u switch require a command equivalent to:\n");
            printf("                  '-t play --volume=0.3 file.wav'\n");
            printf("                  [-c command] Used to start the speech synthesizer,\n");
            printf("                              which should read text from it's standard input.\n");
            printf("                              eg: mlxspeaker -c 'festival --tts -'\n\n");
            return 0;
         }
      }
   }

   if (daemon) {
      printf("Becoming a daemon...\n");
      ss_daemon_init(FALSE);
   }

   /* Handle SIGPIPE signals generated from errors on the pipe */
   signal(SIGPIPE, sigpipehandler);
   signal(SIGINT, siginthandler);
   
   fp = popen(speech_program, "w");
   if (fp == NULL) {
      cm_msg(MERROR, "Speaker", "Unable to start \"%s\": %s\n",
             speech_program, strerror(errno));
      cm_disconnect_experiment();
      exit(2);
   }
   
   /* now connect to server */
   status = cm_connect_experiment(host_name, exp_name, "Speaker", NULL);
   if (status != CM_SUCCESS)
      return 1;

   cm_msg_register(receive_message);

   printf("Midas Message Speaker connected to %s. Press \"!\" to exit.\n", host_name[0] ? host_name : "local host");

   /* initialize terminal */
   ss_getchar(0);
   
   do {
      status = cm_yield(1000);
      while (ss_kbhit()) {
         ch = ss_getchar(0);
         if (ch == -1)
            ch = getchar();
         if (ch == '!')
            status = RPC_SHUTDOWN;
      }
            
   } while (status != SS_ABORT && status != RPC_SHUTDOWN);

   /* reset terminal */
   ss_getchar(TRUE);
   
   pclose(fp);

   cm_disconnect_experiment();
   return 1;
}