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

📄 xlabel.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 5 页
字号:
  get_color_depth();  setup_colormap();  *inputname = 0;	/* Don't get this directly from .wave_pro */  program = objlist = new_objects(av[0]);  objlist->methods = &base_methods;  color = MARKER_COLOR;  locx = (xlab_ctlwin_x >= 0) ? xlab_ctlwin_x : 700;  locy = (xlab_ctlwin_y >= 0) ? xlab_ctlwin_y : 0;  daddy = 	/* global reference in xprint_setup.c and xnotice.c */      frame = xv_create(NULL, FRAME,		        XV_X, locx,		        XV_Y, locy,		        XV_WIDTH, 400,			0);  /* set up communications with the host (xwaves) */  if (!setup_attach_comm(frame, server_name, "xlabel")) {      fprintf(stderr, "Failed to setup ipc communications\n");      exit(1);  }  if (is_chart())     sprintf(mess, "Chart Display and Labeler %s (%s)", Version, registry_name);  else     sprintf(mess, "Labeler %s (%s)", Version, registry_name);  xv_set(frame, XV_LABEL, mess, NULL);  if (debug_level)      fprintf(stderr, "registry name: %s\n", registry_name);  send_start_command(generate_startup_command(registry_name));  set_blowup_op();  window_wash(frame);  notify_interpose_destroy_func(frame, destroy_func);  panel = xv_create(frame, PANEL, 0);  window_wash(panel );  file_item = xv_create(panel, PANEL_TEXT,				PANEL_LABEL_STRING, "Label File:",				PANEL_VALUE, inputname,				PANEL_VALUE_DISPLAY_LENGTH, 30,				PANEL_NOTIFY_PROC, newFile,				   0);  window_wash(file_item );    object_item = xv_create(panel, PANEL_TEXT,				PANEL_LABEL_STRING, "Object:",				PANEL_VALUE, objectname,				PANEL_VALUE_DISPLAY_LENGTH, 8,			  PANEL_VALUE_STORED_LENGTH, 80,				PANEL_NOTIFY_PROC, newFile,				   0);    window_wash(object_item );  if(child_of_ensig()) {                 xv_set(object_item, PANEL_INACTIVE, 1, NULL);  }  if(!is_chart()) {    temp_item = xv_create(panel, PANEL_BUTTON,			PANEL_LABEL_STRING,	    "xlabel manual",		        XV_KEY_DATA,		         EXVK_HELP_NAME,	    FIND_WAVES_LIB(NULL,							   "xlabel.man"),			XV_KEY_DATA,			 EXVK_HELP_TITLE,    "xlabel manual page",			PANEL_NOTIFY_PROC,	    exv_get_help,			0);    window_wash(temp_item);  }  active_item = xv_create(panel, PANEL_TEXT,				PANEL_LABEL_STRING, "Active fields:",				PANEL_VALUE, active,				PANEL_VALUE_DISPLAY_LENGTH, 27,			  PANEL_VALUE_STORED_LENGTH, 80,				PANEL_NOTIFY_PROC, newFile,				   0);  window_wash(active_item);  if(is_chart()) {    temp_item = xv_create(panel, PANEL_BUTTON,			  PANEL_LABEL_STRING,	    "xchart manual",			  XV_KEY_DATA,			  EXVK_HELP_NAME,	    FIND_WAVES_LIB(NULL,							   "xchart.man"),			  XV_KEY_DATA,			  EXVK_HELP_TITLE,    "xchart manual page",			  PANEL_NOTIFY_PROC,	    exv_get_help,			  0);    window_wash(temp_item);  }  menu_item = xv_create(panel, PANEL_TEXT,				PANEL_LABEL_STRING, "Label Menu File:",				PANEL_VALUE, menufile,				PANEL_VALUE_DISPLAY_LENGTH, 20,			  PANEL_VALUE_STORED_LENGTH, 80,				PANEL_NOTIFY_PROC, newFile,				   0);  window_wash(menu_item );  temp_item = xv_create(panel, PANEL_BUTTON,				PANEL_LABEL_STRING, "  QUIT  ",				PANEL_NOTIFY_PROC, quit_proc,				0);  window_wash(temp_item );  if(is_chart()) {    chart_item = xv_create(panel, PANEL_TEXT,				   PANEL_LABEL_STRING, "Chart File:",				   PANEL_VALUE, chartname,				   PANEL_VALUE_DISPLAY_LENGTH, 30,				   PANEL_NOTIFY_PROC, newFile,				   0);    window_wash(chart_item);    top_word_item = xv_create(panel, PANEL_TEXT,				   PANEL_LABEL_STRING, "Top Word:",				   PANEL_VALUE, topword,				   PANEL_VALUE_DISPLAY_LENGTH, 30,			  PANEL_VALUE_STORED_LENGTH, 80,				   PANEL_NOTIFY_PROC, newFile,				   0);    window_wash(top_word_item);  }  if (is_chart())   	exv_attach_icon(frame, ERL_NOBORD_ICON, "xchart", TRANSPARENT);  else     exv_attach_icon(frame, ERL_NOBORD_ICON, "xlabel", TRANSPARENT);  identify_visual();  window_fit(panel);  window_fit(frame);  window_main_loop(frame);  }/*********************************************************************/set_blowup_op(){  char mess[MES_BUF_SIZE];  sprintf(mess,"set blowup_op %s",basename(thisprog));  mess_write(mess);}/*********************************************************************/Labelfile *get_label_level(ob,y)     Objects *ob;     register int y;{  Rect *rec;  register int n, at, yoffset, height;  register Labelfile *lf;  Wobject *wob;    if(ob && (lf = ob->labels)) {    n=1;    while ((lf = lf->next)) n++;    rec = (Rect*)xv_get(ob->canvas, WIN_RECT);    if(plotting_charts(wob = (Wobject*)get_wobject(ob))) {      yoffset = (wob->label_loc)? rec->r_height - wob->label_size : 0;      height = wob->label_size;    } else {      yoffset = 0;      height = rec->r_height;    }    if((y < yoffset) || (y > yoffset+height)) return(NULL);    if(n==1) return(ob->labels);    at = (n * (y-yoffset))/height;    if(at == n) at--;    lf = ob->labels;    while(lf && at--) lf = lf->next;    return(lf);  }  return(NULL);}/*********************************************************************/static void doit(canvas_pw, event, arg)     Canvas canvas_pw;     Event *event;     caddr_t arg;{  /* Event proc called on point window, not canvas itself. */  Canvas    canvas = xv_get(canvas_pw, CANVAS_PAINT_CANVAS_WINDOW);  Objects *ob;  Wobject *wob;  Labelfile *lf;  Label *l;  static double time, time0 = 0.0, ptime, ntime;   double get_next_time(), get_prev_time();  static int x, y;  int id;  Pixwin *pw;  Rect *rec;  Frame frm;  char mes[MES_BUF_SIZE];  void mark_window();    if(canvas && (ob = (Objects *)xv_get(canvas, WIN_CLIENT_DATA))) {    wob = (Wobject*)get_wobject(ob);    x = event_x(event);    y = event_y(event);    time = x_to_time(ob,x);    id = event_id(event);    global_canvas = canvas;      if(event_is_up(event)) { /* a button was released... */      Label *l;      switch(event_id(event)) {      case MS_MIDDLE:	if(((insert_mode == 2) || event_shift_is_down(event) ||	    event_meta_is_down(event))) {	  lf = ob->labels;	  remove_cursor(canvas, ob);	  while(lf) {	    if((l = lf->move_pending)) {	      if(unlink_label(l,lf)) {		waves_send(ob->name,"unmark",l->color,l->time);		l->time = time;		lf->move_pending = NULL;		waves_send(ob->name, "mark", l->color, l->time);		if(append_label(l,lf))		  rewrite_labels(lf);		else		  fprintf(stderr,"Error reinserting label after move in doit()\n");		plot_labels(lf);	      } else		fprintf(stderr,"Can't unlink label to be moved in doit()\n");	    }	    lf = lf->next;	  }	  add_cursor(canvas, ob, x, y);	}	return;      case MS_LEFT:	return;      }    }    switch(id) {    case MS_LEFT:      if(lf = get_label_level(ob,y)) {	if(event_ctrl_is_down(event)) {	  lf->time_t = time;	  do_labels(event,lf,"*EDIT*");	  return;	}	ptime = get_prev_time(lf, time);	ntime = get_next_time(lf, time);	if(ntime > 0.0) {	  mark_window(ob, ptime, ntime);	  send_play_seg(ob,ptime,ntime);	}      } else	play_chart_entry(wob,time,y);      break;        case LOC_MOVE:    case LOC_DRAG:      win_set_kbd_focus(canvas_pw,xv_get(canvas_pw,XV_XID));      {	char mess[MES_BUF_SIZE], *iop;	Chartfile *cf;	pw = canvas_pixwin(ob->canvas);	if((lf = get_label_level(ob,y)))	  sprintf(mess,"%s",lf->label_name);	else {	  if((cf = (Chartfile*)get_chart_level(get_wobject(ob),y)))	    sprintf(mess,"%s",cf->chart_name);	  else	    sprintf(mess,"%s","<no active file>");	}	switch(insert_mode) {	case 0:	  iop = "REPLACE MODE";	  break;	default:	case 1:	  iop = "INSERT MODE";	  break;	case 2:	  iop = "MOVE MODE";	  break;	}	sprintf(mes,"%30s  T:%9.5f  %12s",mess,time,iop);	pw_text(pw,0,xv_get(ob->canvas, XV_HEIGHT) - 8, 		PIX_COLOR(TEXT_COLOR)|PIX_SRC,def_font,mes);	send_cursor(ob->name,"cursor", time);	remove_cursor(canvas, ob);	add_cursor(canvas, ob, x, y);      }      break;    case LOC_WINEXIT:		/*get rid of cursor*/      remove_cursor(canvas, ob);      break;    case MS_MIDDLE:      if((insert_mode != 2) && !event_shift_is_down(event) &&	 !event_meta_is_down(event)) {	if((lf = get_label_level(ob,y))) {	  ptime = get_prev_time(lf, time);	  mark_window(ob, ptime, time);	  sprintf(mes,"%s play start %f end %f\n",ob->name,ptime,time);	  mess_write(mes);	}      } else {			/* MOVE MODE */	if(event_meta_is_down(event)) {	/* move boundaries in all tiers */	  lf = ob->labels;	  while(lf) {	    if((l = get_nearest_label(lf,time)))	      lf->move_pending = l;	    lf = lf->next;	  }	} else			/* must be shift is down... */	  if((lf = get_label_level(ob,y)) &&	     (l = get_nearest_label(lf,time))) {	    lf->move_pending = l;	  }      }      break;    case MS_RIGHT:      {	Chartfile *cf;	if((lf = get_label_level(ob,y))) 	  do_label_menu(lf, time, y, lf->color, event, arg);	else	  if((cf = get_chart_level(get_wobject(ob),y)))	    do_chart_menu(cf,event,NULL);      }      break;    default:      /* If ASCII event: get label level; find nearest label; if further	 away than one pixel, create a new label at time; append characters to	 last field; create new fields as delimiters are encountered; if id ==	 DELETE, remove characters from end of last field; cross fields as	 necessary; rewrite file when a RETURN is hit. */          if(((id == DELETE) || ((id >= ASCII_FIRST) && (id <= META_LAST))) &&	 event_is_down(event)) {/* if( event_meta_is_down(event)) {  fprintf(stderr,"meta:%c %c %d %d\n",id, id & 0x7f ,id, id & 0x7f);}*/	if((lf = get_label_level(ob,y))) {	  double dt = ob->sec_cm / PIX_PER_CM; /* min. resolvable time */	  int field = (insert_mode == 0)? replace_field : -1;	  if(id == '
') {	    rewrite_labels(lf);	    return;	  }	  l = get_nearest_label(lf,time);	  if(!l)	    if(!(l = new_label(time, lf->color))) {	      fprintf(stderr,"Can't make new_label in doit()\n");	      return;	    } else {	      append_label(l,lf);	      waves_send(ob->name,"mark",lf->color,time);	    }	  /* If in not in REPLACE mode, add a new label if cursor	     is not exactly on the old mark. */	  if(insert_mode != 0) {	    if(fabs(l->time - time) >= dt) {	      if(!(l = new_label(time, lf->color))) {		fprintf(stderr,"Can't make new_label in doit()\n");		return;	      }	      append_label(l,lf);	      waves_send(ob->name,"mark",lf->color,time);	    }	  }	  char_to_label(lf,l,id,field);	  remove_cursor(canvas, ob);	  plot_labels(lf);	  add_cursor(canvas, ob, x, y);	}      }      break;    }  }  return;}/*********************************************************************/void quit_proc(item, event)     Panel_item item;     Event *event;{  cleanup();  kill_proc();}/*********************************************************************/waves_send(name,command,color,time)     char *name, *command;     int color;     double time;{  char mes[MES_BUF_SIZE];    sprintf(mes,"%s %s time %f color %d\n",name,command,time,color);  mess_write(mes);  return(TRUE);  }/*********************************************************************/send_cursor(name,command,time)     char *name, *command;     double time;{  char mes[MES_BUF_SIZE];    sprintf(mes,"%s %s time %f\n",name,command,time);  mess_write(mes);  return(TRUE);  }/*********************************************************************/do_label_menu(lf, time, y, color, event, arg)     Labelfile *lf;     double time;     int y, color;     Event *event;     caddr_t arg;{  Event *ep;    if(!lf)    return(FALSE);  if(lf->menu) {    if(!event) {      event_x(&pseudo_event) = time_to_x(lf->obj,time);      event_y(&pseudo_event) = y;      ep = &pseudo_event;    } else      ep = event;    lf->color_t = color;    lf->time_t = time;    remove_cursor(lf->obj->canvas,lf->obj);    xv_set(lf->menu, MENU_CLIENT_DATA, lf, 0);    menu_show(lf->menu,lf->obj->canvas,ep,NULL);    return(TRUE);  } else    fprintf(stderr,"NULL lf->menu in do_label_menu()\n");  return(FALSE);}static int evrx = 0, evry = 0;#ifndef DEC_ALPHAstatic int evrw = 0;#elsestatic long evrw = 0;#endif	/*********************************************************************//* This is run when a label menu item is selected. */voidlabel_menu_proc(men, item)    Menu	men;    Menu_item	item;{  Labelfile *lf = (Labelfile*)xv_get(men, MENU_CLIENT_DATA);  char *str;  Event *evr;  if (debug_level > 1)     (void) fprintf(stderr, "entered label_menu_proc()\n");    if((evr = (Event *) xv_get(men, MENU_FIRST_EVENT))){    evrx = event_x(evr);    evry = event_y(evr);    evrw = event_window(evr);  }  if((str = (char*)xv_get(item,MENU_VALUE))) {    Label *label, *la;    Fields *fld;    Objects *ob = lf->obj;    char *c;    Event *ev = (Event *) xv_get(men, MENU_FIRST_EVENT);        if (debug_level > 1)       (void) fprintf(stderr, "menu item = %s\n", str);        if(!strcmp(str,"*SHELL*")) { /* Fork a process? */      char command[MES_BUF_SIZE];      if((la = get_nearest_label(lf,lf->time_t))) {	c = (char*)xv_get(item, MENU_STRING);	sprintf(command,"%s %s %s %f &\n",c,lf->label_name,la->fields->str,la->time);	system(command);      }      return;    }    do_labels(ev, lf, str);  }}/*********************************************************************/do_labels(ev, lf, str)     Event *ev;     Labelfile *lf;     char *str;{

⌨️ 快捷键说明

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