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

📄 xwaves.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 3 页
字号:
  }  return(NULL);}/*********************************************************************/void doit(canvas_pw, event, arg)    Pixwin  *canvas_pw;    Event   *event;    caddr_t arg;{/* Event proc called on paint window, not canvas itself. */  Canvas      canvas = xv_get((Xv_opaque)canvas_pw, CANVAS_PAINT_CANVAS_WINDOW);  View	      *v;  double      time, freq;  static int  x;  int	      i, id;  void	      (*e_proc)();  extern Event *last_event;  last_event = event;  v = (View *)xv_get((Xv_opaque)canvas, WIN_CLIENT_DATA);  id = event_id(event);  /* This section handles events in the scrollbar region. */  if(event_y(event) < v->readout_height + v->scrollbar->height) {    if(v->handle_scrollbar)      v->handle_scrollbar(v,event);    return;  }  /* This code segment handles interruption of d/a conversion. */  if(event_is_down(event) && (event_id(event) == MS_LEFT) && (!da_done)) {    handle_da_interruption(v);    return;  }  switch (id) {  case LOC_DRAG:    if (event_left_is_down(event) &&	v->left_but_proc && v->left_but_proc->proc)      v->left_but_proc->proc(canvas, event, v->left_but_proc->data);    else      if (event_middle_is_down(event) &&	  v->mid_but_proc && v->mid_but_proc->proc)	v->mid_but_proc->proc(canvas, event, v->mid_but_proc->data);    break;  case LOC_MOVE:    win_set_kbd_focus(canvas_pw,xv_get((Xv_opaque)canvas_pw,XV_XID));    transform_xy(v, event_x(event), event_y(event));    if(v->move_proc && v->move_proc->proc) {      v->move_proc->proc(canvas, event, v->move_proc->data);    }    break;  case MS_LEFT:    if(v->left_but_proc && v->left_but_proc->proc)      v->left_but_proc->proc(canvas, event, v->left_but_proc->data);    break;  case MS_MIDDLE:    if(v->mid_but_proc && v->mid_but_proc->proc)      v->mid_but_proc->proc(canvas, event, v->mid_but_proc->data);    break;  case MS_RIGHT:    if(v->right_but_proc)      v->right_but_proc(canvas, event, arg);    break;  default:    if((id >= ASCII_FIRST) && (id <= META_LAST)) {      keymap_command(canvas, event, arg);      if(debug_level) {	if(id == '
') id = '\n';	printf("%d %c", id, id);	fflush(stdout);      }    }    break;    }  return;}/*********************************************************************/move_view_to_loc(v, da_loc)     View *v;     int da_loc;{  extern int da_stop_pos_view;  if(da_stop_pos_view && v && (da_loc > 0)) {    double t, size;    Signal *s;    Signal *get_playable_signal();    if(debug_level)      fprintf(stderr,"move_view_to_loc: da_loc %d\n", da_loc);    if((s = get_playable_signal(v))) {      size = ET(v) - v->start_time;      t = (s->start_time + ((double)da_loc)/s->freq) - (0.5 * size) - REACT_TIME;      if(t < s->start_time) t = s->start_time;      page(v,v->sig,t);    }  }  return;}/*********************************************************************/handle_da_interruption(v)     View *v;{  int     da_loc = 0;  extern int play_pid;  Signal *get_playing_signal(), *s;  if (use_dsp32 && play_pid == 0) /* means that an external play was not used */     da_loc  = da_location - da_samps_remaining();  if(debug_level)     fprintf(stderr,"da_done %d  da_loc %d\n", da_done, da_location);  if((s = get_playing_signal()) && (s->views))    v = s->views;  if(stop_da(v))     move_view_to_loc(v,da_loc);  return;}/*********************************************************************//* If a command file is open and paused and the command file name   has not been changed, resume reading from the (already open)   stream.  If the name has been changed, close the open file, if   any, and open and begin reading the new file.*/void command_proc(item, event)    Panel_item	item;    Event	*event;{  extern char	commandname[];  extern int	command_paused;  extern char	*dispatch();  char    string[501];  if (debug_level)     (void) fprintf(stderr, "command_proc: function entered\n");   if((!command_paused) && fp_command) {    fclose(fp_command);    fp_command = NULL;    commandname[0] = 0;  }  strcpy(string, (char*)panel_get_value(item));  if(*string != '@') {		/* it's a direct command */    if(*string)      (void) dispatch(receiver_prefixed(string));    /* Need to restore the actual command file name       (because of a direct command during pause)? */    if(command_paused && *commandname) {      sprintf(string,"@%s",commandname);      xv_set(newControl_item, PANEL_VALUE, string, 0 );    }    return;  }  if(!command_paused) {    strip_newline_at_etc(commandname,string);    if(strcmp(commandname,"stdin")) {      char *cmd_res;      cmd_res = FIND_WAVES_COMMAND(NULL,commandname);      if (cmd_res == NULL) {	sprintf(notice_msg, "Couldn't find readable command file %s", 		commandname);        show_notice(1,notice_msg);	fp_command = NULL;      } else {	strcpy(commandname,cmd_res); 	sprintf(string,"@%s",commandname);	xv_set(newControl_item, PANEL_VALUE, string, 0 );	fp_command = fopen(commandname,"r");	free(cmd_res);      }    }    else       fp_command = stdin;    command_line = 0;  } else {			/* it WAS in the paused state */    if(strcmp(string+1,commandname)) { /* start a new file? */      char *cmd_res;      if(fp_command) {	fclose(fp_command);	fp_command = NULL;	commandname[0] = 0;      }      strcpy(commandname,string+1);      cmd_res = FIND_WAVES_COMMAND(NULL,commandname);      if (cmd_res == NULL) {	sprintf(notice_msg, "Couldn't find readable command file %s", 		commandname);        show_notice(1,notice_msg);	fp_command = NULL;      } else {	strcpy(commandname,cmd_res); 	sprintf(string,"@%s",commandname);	xv_set(newControl_item, PANEL_VALUE, string, 0 );	fp_command = fopen(commandname,"r");	free(cmd_res);	command_line = 0;      }    }    command_paused = FALSE;	/* toggle on (in either case) */  }  if(fp_command) {    char *tst, *fgets(), *clobber_cr();    while((tst = clobber_cr(fgets(string,501,fp_command))) ||	  (fp_command == stdin)) {      if(tst) {	command_line++;	if(*string != '#')	  (void) dispatch(receiver_prefixed(string));	if(!fp_command) {	    command_paused = FALSE;	    return;	}	if(command_paused) return;      } else {	meth_sleep(&program,"seconds .2");	return;      }    }    if(!command_paused && (fp_command != stdin)) {      fclose(fp_command);      fp_command = NULL;      commandname[0] = 0;    }  }  command_paused = FALSE;}/*********************************************************************/intpause_proc(item, event)    Panel_item	item;    Event	*event;{    extern int	command_paused;    command_paused = TRUE;    return XV_OK;}/*********************************************************************/int resume_proc(item, event)     Panel_item item;     Event *event;{  resume_ipc_if_stepping();  command_proc(newControl_item, NULL);    check_ipc_response_pending("ok");  return XV_OK;}/*********************************************************************/void quit_proc(item, event)     Panel_item item;     Event *event;{  cleanup();  check_ipc_response_pending("nogood");  kill_proc();}/*************************************************************************/void newText_proc(item, event)     Panel_item item;     Event *event;{  FILE *fdt, *fopen();  char name[MAXPATHLEN], next[MAXPATHLEN], *get_output_file_names(), *cp;  int n;  /* Output filename (files to be created/overwritten) entry handler: */  /* Proposals for new output filenames are generated by:     (1) explicit type-in of a complete name (no leading @ or trailing ..)     (2) auto-increment of numbers embedded in a filename          (optional trailing ..)      (3) reading a file list from a text file; elements may optionally         have trailing ..     (4) if the filename has a trailing .. an extention will be substituted         for the final .; the extension will be determined from a table	 which relates signal types (as specified in Signals.h) to extensions.	 This table will be compiled in for now...     (5) If the filename does not have trailing .. the above extensions will         be appended directly to the name if the name does not already	 have the correct extension (as .ext) for the file type being	 generated.     (6) If the filename is preceded by @ the file will be read as a source         of actual output filenames.     (7) As new output files are generated, their pathnames will be added         to a list which may be browsed and accessed as a source of input	 filenames for display and signal splicing.  */  *next = 0;  sscanf((char*)panel_get_value(item),"%s %s",name,next);    expand_name(name, name);  if(item == outputFile_item) {    strcpy(outputname, name);    if(! (cp = get_output_file_names(outputname, next))) {      *outputname = 0;      xv_set(item, PANEL_VALUE, outputname, 0);      return;    }    update_filename_display(cp, cp);    return;  }  if(item == newControl_item) {    command_proc(item, event);    return;  }  /* Generic handler for receivers of existing filenames. */  if(its_a_partial_pathname(name)) {    fix_path_end(name);    select_from_alternatives(name,item);    return;  }/* The following items will receive the results from the generic handler   (above) if the target location (results_to) is specified in   select_from_alternatives() in menus.c */  if(item == newFile_item) {     (void)apply_waves_input_path(name,name);    xv_set(item, PANEL_VALUE, name, 0);    create_new_signal_view(name);  }  if(item == overlay_item) {    if(*next)      expand_name(next, next);    (void)apply_waves_input_path(name,name);    xv_set(item, PANEL_VALUE, name, 0);    setup_overlay(objectname, name, next);  }    return;}/************************************************************************/Notify_value kill_program(canvas, status)     Canvas canvas;     Destroy_status status;{#ifndef NO_LIC  extern void lm_quit();#endif  stop_da(NULL);  meth_detach(&program,NULL);#ifndef NO_LIC  lm_quit();#endif  exit(0);}/************************************************************************//* When a canvas is destroyed, all views which refer to it must also   be destroyed.  If the destroyed view is a signal's only view, the   signal is also destroyed.  If the signal is an object's only signal,   the object is unlinked and destroyed.  This is implemented assuming that   different objects do not share canvases.  This doesn't seem too restrictive... */Notify_value kill_signal_view(frame, status)    Frame           frame;    Destroy_status  status;{    Canvas canvas;      if (status == DESTROY_CLEANUP)    {	canvas = (Canvas) xv_get(frame, WIN_CLIENT_DATA);	clobber_repaint_entry(canvas);	if (! free_canvas_views(canvas))	  printf("Problems with free_canvas_views() in kill_signal_views()\n");	xv_set(canvas, WIN_CLIENT_DATA, NULL, 0);    }    return(notify_next_destroy_func(frame, status));}Notify_valuedestroy_func(client, status)    Notify_client client;    Destroy_status status;{#define DEBUG(x) if(debug_level > x) fprintf    DEBUG(1) (stderr,"Inside of destroy_func.\n");    if (status == DESTROY_CHECKING) {	}    else  if (status == DESTROY_CLEANUP) {    DEBUG(1) (stderr,"Inside of destroy_func. CLEANUP\n");	quit_proc();        return notify_next_destroy_func(client, status);	}    else if (status == DESTROY_SAVE_YOURSELF) {	}    else {    DEBUG(1) (stderr,"Inside of destroy_func. DEATH\n");	quit_proc();	}	    return NOTIFY_DONE;}

⌨️ 快捷键说明

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