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

📄 xmethods.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 5 页
字号:
  extern Panel_item	newControl_item;  extern int command_line;  if(debug_level)    fprintf(stderr,"exec_waves() entered with |%s|\n",cmd);  if (!cmd || !*cmd)    return(null);      strip_trailing_spaces(cmd);  if (*cmd != '@') {    char *nextcom, *comstore, *rval;    comstore = savestring(cmd);    cmd = comstore;    while (nextcom = separate_wcommands(cmd)) {      dispatch(receiver_prefixed(cmd));      cmd = nextcom;    }    rval = dispatch(receiver_prefixed(cmd));    free(comstore);    return(rval);  } else {    if(!*(cmd + 1))      return(null);    if(push_command_file()) {      strcpy(commandname, cmd + 1);      fp_command = fopen_command_file(commandname, "r");      if (!fp_command)	pop_command_file();      else {	command_line = 0;	panel_set_value(newControl_item, cmd);	/* command_proc(newControl_item, EVENT_NULL); */      }      return(ok);    } else {      if (fp_command)	fclose(fp_command);      strcpy(commandname, cmd + 1);      fp_command = fopen_command_file(commandname, "r");      if (!fp_command) *commandname = '\0';      panel_set_value(newControl_item, cmd);      command_proc(newControl_item, EVENT_NULL);      return(ok);    }  }}/***********************************************************************/char *meth_return_from_script(o, str)     Object *o;     char *str;{  extern FILE *fp_command;  extern int command_line;  char tmp[500];  extern Panel_item newControl_item;  CHECK_QUERY(str,NULL)  if(pop_command_file())    return(ok);  else    return(null);}/***********************************************************************/char *menu_op_access_proc(o, str)     Object *o;     char *str;{  if(o && str && *str) {    Signal *s;    Canvas canvas;    View *v;    int failed = FALSE;    extern Object program;        if(o == &program) {      sprintf(notice_msg, "Unknown command sent to xwaves:\n%s.", str);      show_notice(1, notice_msg);      return(null);    }    if((s = o->signals) && (v = s->views) && (canvas = s->views->canvas)) {      view_do_op(v,str);      return(ok);    }  }  sprintf(notice_msg, "Bad args to xwaves command processor:\n%s.", str);  show_notice(1, notice_msg);  return(null);}/***********************************************************************/install_dispatch_hook(){  install_default_execute_proc(menu_op_access_proc);}/***********************************************************************/push_command_file(){  extern FILE *fp_command;  extern int command_line;  extern Panel_item newControl_item;  if(*commandname && fp_command) {    Com_stack *ct;    if((ct = (Com_stack*)malloc(sizeof(Com_stack)))) {      if(fp_command != stdin)        fclose(fp_command);      else	command_line = 0;      fp_command = NULL;      strcpy(ct->name,commandname);      ct->line_num = command_line;      command_line = 0;      ct->next = command_stack;      command_stack = ct;      *commandname = 0;      panel_set_value(newControl_item,commandname);      return(TRUE);    } else      fprintf(stderr,"Can't allocate memory in push_command_file()\n");  }  return(FALSE);}/***********************************************************************/char *meth_close_frame(o, str)     Object *o;     char *str;{  static char file[MAXPATHLEN];  static int invisible = 0;  static Selector a1 = {"file", "%s", file, NULL},                  a2 = {"invisible", "%d", (char*)&invisible, &a1};  View *v;  Signal *s;  Frame fr;    invisible = 0;  CHECK_QUERY(str, &a2)    get_args(str, &a2);  if(*file && apply_waves_input_path(file,file)     && (s = find_signal(o,file)) && (v = s->views) && v->canvas) {            fr = (Frame)xv_get(v->canvas,XV_OWNER);      xv_set(fr, FRAME_CLOSED, TRUE, 0);      if(invisible)	xv_set(fr, XV_SHOW, FALSE, 0);      return(ok);  }  return(null);}/***********************************************************************/char *meth_auto_plotlims(o, str)     Object *o;     char *str;{  extern double       plot_max;	/* forced max and min for every trace */  extern double       plot_min;  char *meth_set_attr();  CHECK_QUERY(str, NULL)  return(meth_set_attr(o,"all t plot_max 0 plot_min 0"));}/***********************************************************************/char*meth_print_graphic(o, str)     Object *o;     char *str;{  static char file[MAXPATHLEN];  static Selector a1 = {"file", "%s", file, NULL};  View *v;  Signal *s;  Frame fr;    CHECK_QUERY(str, &a1)    get_args(str, &a1);  if(*file && apply_waves_input_path(file,file)     && (s = find_signal(o,file)) && (v = s->views) && v->canvas) {	e_print_graphic(v->canvas, (Event *)NULL, (caddr_t)NULL);  }  return(null);}      /***********************************************************************/char *meth_print_ensemble(o, str)    Object  *o;    char    *str;{    CHECK_QUERY(str, NULL);    do_print_ensemble(o);    return null;}      /***********************************************************************/char *meth_open_frame(o, str)     Object *o;     char *str;{  static char file[MAXPATHLEN];  static Selector a1 = {"file", "%s", file, NULL};  View *v;  Signal *s;  Frame fr;    CHECK_QUERY(str, &a1)    get_args(str, &a1);  if(*file && apply_waves_input_path(file, file)      && (s = find_signal(o,file)) && (v = s->views) && v->canvas) {    fr = (Frame)xv_get(v->canvas,XV_OWNER);    xv_set(fr, FRAME_CLOSED, FALSE, 0);    xv_set(fr, XV_SHOW, TRUE, 0);    return(ok);  }  return(null);}void reset_color_maps(){  extern Object program;  extern use_static_cmap;  setup_colormap();  if (!use_static_cmap)     install_colormap(&program);  cmap_spect(NULL);}/***********************************************************************  This list defines procedures to be called when any of the named items  are changed via a "set" command.***********************************************************************/static Menuop   si1 = {"colormap", reset_color_maps, NULL, NULL},                si2 = {"image_range", reset_color_maps, NULL, &si1},                si3b = {"image_clip", reset_color_maps, NULL, &si2},                si3 = {"options", distribute_options_settings, NULL, &si3b},                si4 = {"inputname", update_control_panel_names, NULL, &si3},                si5b = {"objectname", update_control_panel_names, NULL, &si4},                si5 = {"name", update_control_panel_names, NULL, &si5b},                si6 = {"overlayname", update_control_panel_names, NULL, &si5},                si7 = {"outputname", update_control_panel_names, NULL, &si6},                si8c = {"old_sphere_format", set_old_sphere_format, NULL, &si7},                si8b = {"def_header", set_default_header, NULL, &si8c},                si8 = {"blowup_op", menu_set_blowup_op, NULL, &si8b};/***********************************************************************/post_set_process(){  Selector **mo = get_changed_items();  while(*mo) {    Menuop *mo2 = &si8;    while(mo2) {      if(!strcmp((*mo)->name,mo2->name)) {	mo2->proc((*mo)->dest);	break;      }      mo2 = mo2->next;    }    mo++;  }}    /***********************************************************************/char *meth_set_attr(o, str)     Object *o;     char *str;{  extern Selector gm1;  extern Object program;  static char do_all[20];  /* Put things in this list that you don't ever want to see printed out! */  static Selector  a0 = {"all", "%s", do_all, &gm1};  char tmp[500];  char *set_view_attributes();  *do_all = 0;  if(o == &program) {    CHECK_QUERY(str,&a0)      if(get_args(str,&a0)) {      post_set_process();      if(*do_all)	change_objects_globally(get_changed_items());      return(ok);    }  } else { /* it's a set command directed to a particular ensemble */    return(set_view_attributes(o, str));  }  sprintf(notice_msg, "Problems in set( %s ).", str);  show_notice(1, notice_msg);  return(null);}/***********************************************************************/char *  meth_call_operator(o, str)Object *o;char *str;{  static char file[MAXPATHLEN], op[MES_BUF_SIZE];  static double yval, time;  static int chan;  static Selector a1 = {"c_time", "%lf", (char*)&time, NULL},  a2 = {"c_yval", "%lf", (char*)&yval, &a1},  a3 = {"c_chan", "%d", (char*)&chan, &a2},  a4b = {"op", "#strq", op, &a3},  a4 = {"command", "#strq", op, &a4b},  a5 = {"file", "%s", file, &a4};  Signal *s;  View *v = NULL;    *file = *op = 0;  time = yval = -1234.5;  chan = -1;  CHECK_QUERY(str, &a5)    if(get_args(str, &a5) && *op) {    if( ! (*file && apply_waves_input_path(file, file) &&	   (s = find_signal(o,file)))) {      s = o->signals;      while(s) {	if((v = s->views) && v->sig && v->canvas) {	  strcpy(file, v->sig->name);	  break;	}	v = NULL;	s = s->others;      }    } else      v = s->views;    if( !( s && v && v->sig && v->canvas)) {      sprintf(notice_msg,  "Bad command sent to meth_op: %s.", str);      show_notice(1, notice_msg);      return(null);    }    if(chan >= 0)      v->cursor_channel = chan;    link_views(v);    view_do_op(v,op);    return(ok);  } else {    sprintf(notice_msg,  "Bad arguments sent to meth_op: %s.", str);    show_notice(1, notice_msg);  }  return(null);}/***********************************************************************/char *  meth_overlay(o, str)Object *o;char *str;{  static char onfile[MAXPATHLEN], file[MAXPATHLEN];  static Selector a1 = {"on_file", "%s", onfile, NULL},  a2 = {"file", "%s", file, &a1};  Object *o2;  Signal *s;    *onfile = 0;  *file = 0;  CHECK_QUERY(str, &a2)    if(get_args(str, &a2) && *file) {    (void)apply_waves_input_path(file,file);        if (*onfile)       (void)apply_waves_input_path(onfile,onfile);        setup_overlay(o->name,file,onfile);    return(ok);  }  return(null);}/***********************************************************************/char *  meth_kill(o, str)Object *o;char *str;{  static char object[100], file[MAXPATHLEN];  static Selector a1 = {"name", "%s", object, NULL},  a2 = {"file", "%s", file, &a1};  Object *o2;  Signal *s;  int killed = FALSE;  *object = 0;    CHECK_QUERY(str, &a2)    if(!get_args(str, &a2)) {    while(o = program.next)      kill_object(o);    return(ok);  } else {    View *find_and_destroy_overlay_views();    if(! *object) return(null);    if((o = find_object(object))) {      if(*file) { 	(void)apply_waves_input_path(file,file); 	while((s = (Signal*)find_signal(o, file))) {	  killed = TRUE;	  if(s->views) {	    Frame fr = (Frame)xv_get((Canvas)s->views->canvas, XV_OWNER);	    xv_set(fr, FRAME_NO_CONFIRM, TRUE, 0);	    dt_xv_destroy_safe(9,fr);	    break;	  } else {	    View *vh0 = NULL, *vh;	    vh = find_and_destroy_overlay_views(s);	    if((s->file == SIG_NEW) &&	       ((s->type & SPECIAL_SIGNALS) != SIG_SPECTROGRAM))	      put_waves_signal(s);	    unlink_signal(s);	    free_signal(s);	    if(!vh0)	      vh0 = vh;	    if(vh0)	      redoit(vh0->canvas);	  }	}      } else	killed = kill_object(o);      return((killed)? ok : null);    } else      return(null);  }}/***********************************************************************/char *meth_quit(o, str)Object *o;char *str;{  CHECK_QUERY(str,NULL)  quit_proc();  exit(0);}/***********************************************************************/char *meth_print_setup_cover(o, str)     Object *o;     char *str;{  CHECK_QUERY(str,NULL)  return(meth_print_setup(o, str));}/*********************************************************************/mopup(){  extern Object program;  Object *o;  extern Display *X_Display;  extern char *registry_name;    while(o = program.next)    kill_object(o);    Close_X_Comm(X_Display, registry_name);  exit_lm();}/*********************************************************************/exit_lm(){#ifndef NO_LIC  extern void lm_quit();    stop_da(NULL);  lm_quit();#endif    exit(0);}/*********************************************************************/kill_proc(){  char mess[100];  extern int child;  extern char *host, funcname[];  do_ipc_response_if_any(in_a_ipc_dispatch(), ok);  if(child) {    sprintf(mess,"%s disconnect\n",host);    xwaves_ipc_send("all", mess);  } else    terminate("all");  meth_disable_server(NULL,NULL);  mopup();}/*********************************************************************/cleanup(){

⌨️ 快捷键说明

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