⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 erldemo.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 3 页
字号:
    if (file_exists(SINGLE_DEMO_FLAG)) /*don't bother resetting*/      break;    else {      set_flag_file(SINGLE_DEMO_FLAG);      if (file_exists(DEMO_RUNNING_FLAG)) {	/* reset the "Stop Continuous" button to "Single" */	xv_set(item, PANEL_CHOICE_STRINGS,	                "Single",	                "Continuous",	                0,	             NULL);	feedback_message("Demo will stop after current cycle.", 3);      }      if (file_exists(WAVES_RUNNING_FLAG)) 	feedback_message("For faster stop, click on QUIT from waves+.", 3);    }    break;  case 1: /*continuous*/    if (!file_exists(SINGLE_DEMO_FLAG)) /*don't bother resetting*/      break;    else {      remove_file(SINGLE_DEMO_FLAG);      if (file_exists(DEMO_RUNNING_FLAG)) {	/* reset the repeat button */	xv_set(item, PANEL_CHOICE_STRINGS,	                 "Stop Continuous",	                 "Continuous",	                 0,	             NULL);	feedback_message("Resetting to continuous play.", 3);      }    }    break;  }}voidselect_demo(item, event)     Panel_item item;		/* parameter panel item */     Event      *event;{  int item_value, demo_choices;  item_value = xv_get(item, PANEL_VALUE);  DEBUG(1) (stderr, "select_repeat: panel value is %d\n", item_value);  demo_choices = xv_get(item, PANEL_CLIENT_DATA);   if (demo_choices != 3) /* if both not allowed */ {    if (item_value != demo_choices) {      feedback_message("Sorry, that choice isn't supported on this system.",1);      xv_set(item, PANEL_VALUE, demo_choices, NULL);    }    return;  }  switch (item_value) {  case 1: /*waves+ only*/    set_flag_file(WAVES_DEMO_FLAG);    remove_file(SLIDE_SHOW_FLAG);    break;  case 2: /*slides only*/    remove_file(WAVES_DEMO_FLAG);    set_flag_file(SLIDE_SHOW_FLAG);    break;  case 0: /*none set, so reset to both*/    feedback_message("Must have one or both of live waves+ and slide show.",1);#ifdef SONY_RISC    fprintf(stderr,"after case 0 feedback\n");#endif    xv_set(item, PANEL_VALUE, 3, NULL);    /*fall through to next case*/  case 3: /*both waves+ and slides*/    set_flag_file(WAVES_DEMO_FLAG);    set_flag_file(SLIDE_SHOW_FLAG);    break;  }  return;}voidset_sparc_output(item, event)     Panel_item item;		/* parameter panel item */     Event      *event;{  int play_choice = xv_get(item, PANEL_VALUE);  switch (play_choice) {  case 0:    set_play_command(item, "play_scripts/play.none");     break;  case 1:    set_play_command(item, "play_scripts/play.int");     break;  case 2:    set_play_command(item, "play_scripts/play.ext");     break;  }}voidset_sun4_output(item, event)     Panel_item item;		/* parameter panel item */     Event      *event;{  int play_choice = xv_get(item, PANEL_VALUE);  switch (play_choice) {  case 0:    set_play_command(item, "play_scripts/play.none");     break;  case 1:    set_play_command(item, "play_scripts/play.vme");     break;  }}voidset_mc_output(item, event)     Panel_item item;		/* parameter panel item */     Event      *event;{  int play_choice = xv_get(item, PANEL_VALUE);  switch (play_choice) {  case 0:    set_play_command(item, "play_scripts/play.none");     break;  case 1:    set_play_command(item, "play_scripts/play.mc");     break;  }}voidset_sony_output(item, event)     Panel_item item;		/* parameter panel item */     Event      *event;{  int play_choice = xv_get(item, PANEL_VALUE);  switch (play_choice) {  case 0:    set_play_command(item, "play_scripts/play.none");     break;  case 1:    set_play_command(item, "play_scripts/play.sony");     break;  }}voidset_net_output(item, event)     Panel_item item;		/* parameter panel item */     Event      *event;{  int play_choice = xv_get(item, PANEL_VALUE);  switch (play_choice) {  case 0:    set_play_command(item, "play_scripts/play.none");     break;  case 1:    set_play_command(item, "play_scripts/play.net");     break;  }}voidset_sgi_output(item, event)     Panel_item item;		/* parameter panel item */     Event      *event;{  int play_choice = xv_get(item, PANEL_VALUE);  switch (play_choice) {  case 0:    set_play_command(item, "play_scripts/play.none");     break;  case 1:    set_play_command(item, "play_scripts/play.sgi");     break;  }}voidstart_demo(item, event)     Panel_item item;     Event      *event;{  Panel_item repeat_button;	/* handle for single/continous button */  if (run_demo(item) == -1)    return;  if (file_exists(SINGLE_DEMO_FLAG)) {    feedback_message("starting single demo . . . .", 2);  }  else {    /* turn the "Single" button into "Stop Continuous" */    repeat_button = (Panel_item) xv_get(item, XV_KEY_DATA, REPEAT_BUTTON_KEY);    xv_set(repeat_button, PANEL_CHOICE_STRINGS,	                    "Stop Continuous",	                    "Continuous",	                    0,	                    NULL);    feedback_message("starting continuous demo . . . .", 2);  }}voidtry_waves(item, event)     Panel_item item;     Event      *event;{  char *trywaves_com = (char *) xv_get(item, PANEL_CLIENT_DATA);  if (trywaves_com == NULL) {  /*no -T option was supplied*/    feedback_message("Sorry, waves+ tryout is not available on this system.",3);    return;  }  if (run_demo(item) == -1)    return;  feedback_message("starting waves+  tryout;  stop with quit from waves+.", 2);}intrun_demo(item)    Panel_item item;{  Frame owner;  char *demo_com = (char *) xv_get(item, PANEL_CLIENT_DATA);  char demo_command[100];  int status = 0;  int x,y;			/* coordinates of panel item */  owner = (Frame) xv_get((Frame) xv_get(item, XV_OWNER, NULL), 			 XV_OWNER, 			 NULL);  if (file_exists(DEMO_RUNNING_FLAG)) {    if (file_exists(WAVES_RUNNING_FLAG))      feedback_message(	      "waves+ intro already running; if not, exit and restart.",3);    else if (file_exists(SLIDES_RUNNING_FLAG))	feedback_message(	      "slide show already running; if not, exit and restart.",3);    else      feedback_message(	      "Demo already running; if not, please exit and restart.", 3);    return(-1);  }  if (file_exists(WTRY_RUNNING_FLAG)) {    feedback_message("Interactive waves+ is already running.", 2);    feedback_message("Click on QUIT from interactive waves+.", 2);    feedback_message("If it isn't running, please exit and restart.", 3);    return(-1);  }  sprintf(demo_command, "%s &", demo_com);  DEBUG(1) (stderr, "run_demo: running shell command: %s\n", demo_command);  status = system(demo_command);  if (status != 0) {    x = (int) xv_get(item, PANEL_ITEM_X, NULL);    y = (int) xv_get(item, PANEL_ITEM_Y, NULL);    (void)notice_prompt(owner, NULL,			NOTICE_MESSAGE_STRINGS, "Problem running demo.", NULL,			NOTICE_FOCUS_XY,        x, y,			NOTICE_BUTTON_YES,      "Continue",			NULL);    return(-1);  }  return(0);}voiddisplay_info(item, event)     Panel_item item;     Event      *event;{  Frame owner = (Frame) xv_get((Frame) xv_get(item, XV_OWNER, NULL));  char *textfile = (char *) xv_get(item, PANEL_CLIENT_DATA);#ifdef SG{  char Command[100]; /* big enough for known command and filename*/  sprintf(Command, "xterm -T \"More Information About Entropic Software\" -e more %s", textfile);  exec_command(Command);}#else  display_text(owner, "More Information About Entropic Software", textfile);#endif}voiddisplay_about(item, event)     Panel_item item;     Event      *event;{  Frame owner = (Frame) xv_get((Frame) xv_get(item, XV_OWNER, NULL));  char *textfile = (char *) xv_get(item, PANEL_CLIENT_DATA);#ifdef SG{  char Command[100];/* big enough for known command and filename*/  sprintf(Command, "xterm -T \"About The Entropic Demo\" -e more %s", textfile);  exec_command(Command);}#else  display_text(owner, "About the Entopic Demo", textfile);#endif}voiddisplay_text(frame, title, file)Frame frame;			/* owner of popup window */char *title;			/* popup title */char *file;			/* popup file */{  Frame popup;  Textsw textw;  DEBUG(1) (stderr, "Entered display_text, textfile is %s\n", file);  /*busy out the frame*/  xv_set(frame, FRAME_BUSY, TRUE, NULL);  if (!file_exists(file)) {    feedback_message("Sorry, can't open text file.", 3);    return;  }  popup = xv_create(frame, FRAME_CMD,		    XV_LABEL, title,		    XV_SHOW, FALSE,		    FRAME_SHOW_FOOTER, FALSE,		    FRAME_SHOW_RESIZE_CORNER, TRUE,		    FRAME_CMD_PUSHPIN_IN, TRUE,		    WIN_ROWS,     33,		    WIN_COLUMNS,  70,		    0);  textw = (Textsw) xv_create(popup, TEXTSW,			     XV_X,         0,			     XV_Y,         0,			     OPENWIN_SHOW_BORDERS, TRUE,			     TEXTSW_FILE, file,			     TEXTSW_BROWSING, TRUE,			     TEXTSW_DISABLE_LOAD, TRUE,			     TEXTSW_DISABLE_CD, TRUE,			     NULL);  if (do_color) {    (void) exv_init_colors(textw);    xv_set(textw, WIN_BACKGROUND_COLOR, CMS_CONTROL_COLORS + EC_GRAY,	   WIN_FOREGROUND_COLOR, CMS_CONTROL_COLORS + EC_BLACK,	   NULL);  }  xv_set(popup, XV_SHOW, TRUE, NULL);  xv_set(frame, FRAME_BUSY, FALSE, NULL); }voidfeedback_message(message, seconds)char *message;			/* message text */int seconds;			/* number of seconds to leave up */{  xv_set(feedback, PANEL_LABEL_STRING, message, NULL);  xv_set(mainframe, FRAME_BUSY, TRUE, NULL);   xv_set(mainframe, XV_SHOW, TRUE, NULL);  sleep((unsigned) seconds);   xv_set(mainframe, FRAME_BUSY, FALSE, NULL);   xv_set(feedback, PANEL_LABEL_STRING, " ", NULL);}intfile_exists(name)char *name;			/* name of file to check */{  FILE *tfd;  if ((tfd = fopen(name, "r")) == NULL)    return(0);  else {    fclose(tfd);    return(1);  }}voidset_play_command(item, play_command)Panel_item item;char *play_command;{/* this function copies the appropriate play_command to /tmp.  The  *  item handle is passed so that forced silence can be handled;  *  We assument that "None" is always the first choice on the Audio *  output list */  int silent_demo = xv_get(item, PANEL_CLIENT_DATA);   int play_choice = xv_get(item, PANEL_VALUE);   if (silent_demo && play_choice != 0) {    feedback_message("Sorry, audio output is not available.", 2);    xv_set(item, PANEL_VALUE, 0, NULL);   }  else {    link_file(play_command, "/tmp/play");  }  return;}voidlink_file(source, dest)char *source;char *dest;{  /* we use unlink and cp rather than just cp since a change in userid    * since a previous run of erldemo might result in cp failing for    * permission reasons   */  char path[50];  char fullpath[100];    sprintf(fullpath, "%s/%s", getwd(path), source);   DEBUG(2) (stderr, "link_file: linking %s to %s\n", fullpath, dest);  (void) unlink(dest);   (void) symlink(fullpath, dest); }voidset_flag_file(filename)char *filename;{  /* we use unlink and fopen since a change in userid    * since a previous run of erldemo might result in cp failing for    * permission reasons   */  FILE *tfd;  DEBUG(2) (stderr, "set_flag_file: touching %s\n", filename);  (void) unlink(filename);  tfd = fopen(filename, "w");  fclose(tfd);}voidremove_file(filename)char *filename;{  DEBUG(2) (stderr, "remove_file: removing %s\n", filename);  (void) unlink(filename);}voidsig_handler() {  /* ok to use NULL dummies, as exit_proc doesn't use the parameters*/  Panel_item dummy_item = NULL;  Event      *dummy_event = NULL;  exit_proc(dummy_item, dummy_event);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -