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

📄 xmethods.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 5 页
字号:
                     b1b = { "image_range", "%lf", (char*)&image_range, &b2b },                     b2 = { "threshold", "%lf", (char*)&threshold, &b1b },                     b1 = { "range", "%lf", (char*)&image_range, &b2 },                     a7 = {"width", "%d", (char *) &new_width, &b1},                     a6b = {"height", "%d", (char *) &new_height, &a7},                     a6 = {"file", "%s", name, &a6b},                     a5 = {"loc_y", "%d", (char*)&next_y, &a6},                     a4 = {"loc_x", "%d", (char*)&next_x, &a5},                     a3b = {"type", "%s", type, &a4},                     a3 = {"output", "%s", output, &a3b},                     a2 = { "start", "%lf", (char*)&start, &a3 },                     a1 = { "end", "%lf", (char*)&end, &a2 };  double temp;  Signal *s;  strcpy(type, "wideband");  *name = 0;  *output = 0;  start = -10.0;  end = -1.0;  new_width = new_height = 0;  threshold = -234.5;  CHECK_QUERY(str,&a1)    get_args(str,&a1);  if(*name) {    (void)apply_waves_input_path(name,name);    s = find_signal(o,name);  }  else  /* Try to find a .sd or .d file or the first  P_SHORTS file. */    if(!((s = find_signal(o,new_ext(((Signal*)o->signals)->name,"d"))) ||	 (s = find_signal(o,new_ext(((Signal*)o->signals)->name,"sd"))))) {      s = o->signals;      while(s) {	if(IS_GENERIC(s->type) && ((s->type & VECTOR_SIGNALS) == P_SHORTS) &&	   (s->dim == 1))	  break;	s = s->others;      }    }  if(s) {    if(start < 0.0)      start = BUF_START_TIME(s);    if(end < 0.0)      end = BUF_END_TIME(s);    if(start < (temp = SIG_START_TIME(s)))       start = temp;    if(end > (temp = 	SIG_END_TIME(s)))      end = temp;    if(threshold != -234.5)      image_clip = HI_SPECT_LIM - (threshold + image_range);    limit_z_range(MAX_CMAP_SIZE - (cmap_size-CMAP_RESERVED));    spectrogram(s, type, start, end, output);/* Note that "spectrogram()" has the side effect of setting new_height   and new_width to zero. */    return(ok);  }  new_width = new_height = 0;  return(null);}/***********************************************************************/char *meth_page(o,str)     Object *o;     register char *str;{  static double step;  static char file[MAXPATHLEN];  static  Selector a3 = {"file", "%s", file, NULL},                   a2 = { "step", "%lf", (char*)&step, &a3 },                   a1 = { "ref_step", "%lf", (char*)&ref_step, &a2 };  Signal *s;    step = 0.0;  strcpy(file,inputname);  CHECK_QUERY(str, &a1)    get_args(str,&a1);  if (*file)     (void)apply_waves_input_path(file,file);  if((s = find_signal(o,file)) && s->views) {    if(step == 0.0)      step = s->views->page_step;    s->views->lmarker_time += step;    s->views->rmarker_time += step;    page(s->views, s, s->views->start_time + step);    return(ok);  }  return(null);}/***********************************************************************/char *meth_bracket_markers(o, str)    Object	    *o;    register char   *str;{    extern int	    h_spect_rescale;    static double   start, end;    static char	    file[MAXPATHLEN];    static Selector a3 = {"file",   "%s",  file,	    NULL},		    a2 = { "start", "%lf", (char *) &start, &a3},		    a1 = { "end",   "%lf", (char *) &end,   &a2};    Signal	    *s;    start = end = -1.0;  strcpy(file, inputname);    CHECK_QUERY(str, &a1)      get_args(str, &a1);  if (*file)     apply_waves_input_path(file,file);      if ((s = find_signal(o, file))      && s->views && s->views->h_rescale)  {    if (start == -1.0) start = s->views->lmarker_time;    if (end == -1.0) end = s->views->rmarker_time;    if (start < end)    {	s->views->rmarker_time = end;	s->views->lmarker_time = start;	position_view(s->views, start, end);	return(ok);    }  }  return(null);}/***********************************************************************/char *meth_save_seg(o,str)     Object *o;     register char *str;{  static double start, end;  static char name[MAXPATHLEN];  static  Selector a3 = {"file", "%s", name, NULL},  a2 = { "start", "%lf", (char*)&start, &a3 },  a1b = {"outputname", "%s", outputname, &a2},  a1 = { "end", "%lf", (char*)&end, &a1b };  double duration;  char next[200];  Signal *s;  View *v;    *name = 0;  start = -1.0;  end = -1.0;  CHECK_QUERY(str, &a1)    get_args(str,&a1);  if(*name && apply_waves_input_path(name, name) && (s = find_signal(o,name))) {    if(start < end) { /* specified in command */      if(start < s->start_time)	start = s->start_time;       if(end > SIG_END_TIME(s))	 end = SIG_END_TIME(s);      duration = end - start;    } else {      if((start == end) && (end == -1.0) && (v = s->views)) {	duration = v->rmarker_time - v->lmarker_time;	start = v->lmarker_time;	end = v->rmarker_time;      } else return(null);    }    if(save_segment(s,start,duration)) {      get_output_file_names(outputname, next);      update_filename_display(next);      return(ok);    }  } else {    if(! *name) strcpy(name,null);    fprintf(stderr,"Can't find_signal(%s) in meth_save_segment().\n",name);  }  return(null);}/***********************************************************************/char *meth_play_seg(o, str)    Object	    *o;    char	    *str;{    Signal	    *s;    Header	    *h;    struct header   *espsh;    static double   start, end, gain_0, gain_1;    static int pchannel;    static char	    name[MAXPATHLEN];    static Selector a3 = {"file",  "%s",  name,		   NULL},		    a2d = {"channel", "%d", (char *) &pchannel, &a3},		    a2c = {"gain_1", "%lf", (char *) &gain_1, &a2d},		    a2b = {"gain_0", "%lf", (char *) &gain_0, &a2c},		    a2 = {"start", "%lf", (char *) &start, &a2b},                    a1 = {"end",   "%lf", (char *) &end,   &a2};      *name = 0;    start = 0.0;    end = 0.0;    gain_0 = gain_1 = 1.0;    pchannel = -1;    CHECK_QUERY(str, &a1)      get_args(str, &a1);    if(*name) {      (void)apply_waves_input_path(name,name);	s = find_signal(o, name);    }    else    {        for (s = o->signals;	     s && !(IS_GENERIC(s->type)		    && ((s->type & VECTOR_SIGNALS) == P_SHORTS)		    && playable_dimension(s->dim))	       && !((h = s->header)		    && h->magic == ESPS_MAGIC		    && (espsh = h->esps_hdr)		    && (espsh->common.type == FT_FEA)		    && (espsh->hd.fea->fea_type == FEA_SD));	     s = s->others)        { }    }    if (s)    {	if (start < s->start_time) start = s->start_time;	if (end <= start) end = s->start_time + s->file_size/s->freq;	if(pchannel == 0)	  gain_1 = 0.0;	else	  if(pchannel == 1)	    gain_0 = 0.0;	set_channel_gains(gain_0, gain_1);	play_file(s, start, end);	return(ok);    }    return(null);}/***********************************************************************/char *meth_stop_play(o, str)    Object	    *o;    char	    *str;{    Signal	    *s, *get_playing_signal();    Header	    *h;    struct header   *espsh;    extern int da_stop_pos_view;    int repo_hold;    static char	    name[MAXPATHLEN];    static int      reposition;    static Selector a2 = {"reposition_view",  "%d",  (char *) &reposition, NULL},                    a1 = {"file",  "%s",  name,	&a2};      *name = 0;    reposition = da_stop_pos_view;    CHECK_QUERY(str, &a1)      get_args(str, &a1);    if(*name) {      (void)apply_waves_input_path(name,name);	s = find_signal(o, name);    }    else      if( ! (s = get_playing_signal())) {        for (s = o->signals;	     s && !(s->views && IS_GENERIC(s->type)		    && ((s->type & VECTOR_SIGNALS) == P_SHORTS)		    && playable_dimension(s->dim))	       && !(s->views && (h = s->header)		    && h->magic == ESPS_MAGIC		    && (espsh = h->esps_hdr)		    && (espsh->common.type == FT_FEA)		    && (espsh->hd.fea->fea_type == FEA_SD));	     s = s->others)        { }      }    if (s && s->views) {      repo_hold = da_stop_pos_view;      da_stop_pos_view = reposition;      handle_da_interruption(s->views);      da_stop_pos_view = repo_hold;      return(ok);    }    return(null);}/***********************************************************************/char *meth_play_window(o,str)     Object *o;     register char *str;{  double start, end;  static char name[MAXPATHLEN];  static  Selector a1 = {"file", "%s", name, NULL};  double temp;  Signal *s;  View *v;    *name = 0;  start = 0.0;  end = 0.0;  CHECK_QUERY(str, &a1)    get_args(str,&a1);  if(*name) {      (void)apply_waves_input_path(name,name);      s = find_signal(o,name);    }  else  /* Try to find a .d file or the first available P_SHORTS file. */    if(!(s = find_signal(o,new_ext(((Signal*)o->signals)->name,"d")))) {      s = o->signals;      while(s) {	if(IS_GENERIC(s->type) && ((s->type & VECTOR_SIGNALS) == P_SHORTS) &&	   (s->dim == 1))	  break;	s = s->others;      }    }  if(s) {    if((v = s->views)) {      start = v->start_time;      end = ET(v);    } else {      start = s->start_time;      end = SIG_END_TIME(s);    }    play_file(s, start, end);    return(ok);  }  return(null);}/***********************************************************************/char *meth_branch_to_script(o, str)     Object *o;     char *str;{  extern FILE *fp_command;  char tmp[500];  extern Panel_item newControl_item;  CHECK_QUERY(str,&g1)    if(get_args(str,&g1) && *commandname) {    if(fp_command)      fclose(fp_command);        if(!(fp_command = fopen_command_file(commandname,"r")))      *commandname = 0;    sprintf(tmp,"@%s",commandname);    panel_set_value(newControl_item,tmp);    if(*commandname)      return(ok);  }  return(null);}/***********************************************************************/FILE *pop_command_file(){  extern FILE *fp_command;  extern int command_line;  Com_stack *ct;  char junk[501];  extern Panel_item newControl_item;  if(fp_command && (fp_command != stdin))    fclose(fp_command);  *commandname = 0;  command_line = 0;  fp_command = NULL;  *junk = 0;  if((ct = command_stack)) {    if(!strcmp(ct->name,"stdin"))      fp_command = stdin;    else      fp_command = fopen(ct->name,"r");    if(fp_command) {      for ( ; command_line < ct->line_num; command_line++)	fgets(junk, 500, fp_command);      strcpy(commandname,ct->name);      sprintf(junk,"@%s",ct->name);      command_stack = ct->next;      free((char *)ct);    }  }  panel_set_value(newControl_item,junk);  return(fp_command);}/***********************************************************************/char *meth_call_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(push_command_file()) {    strcpy(tmp,commandname);    *commandname = 0;    if(get_args(str,&g1) && *commandname && strcmp(tmp,commandname)) {	if(!(fp_command = fopen_command_file(commandname,"r")))	  *commandname = 0;    }    command_line = 0;    sprintf(tmp,"@%s",commandname);    panel_set_value(newControl_item,tmp);    if(! *commandname)      pop_command_file();    else      return(ok);  }  return(null);}/***********************************************************************//* Only necessary because of bugs in mbuttons and send_xwaves. */strip_trailing_spaces(cmd)     char *cmd;{  int i;  for (i = strlen(cmd) - 1; i >= 0 && cmd[i] == ' '; i--)    cmd[i] = '\0';}/***********************************************************************/static char *find_double_colon(str)     char *str;{  if(str) {    while(*str) {      if((*str == ':') && (str[1] == ':'))	return(str);      str++;    }  }  return(NULL);}	/***********************************************************************/char *separate_wcommands(cmd)     char *cmd;{  char *cp, *index(), tomatch;  if(cmd) {    while((*cmd == ' ') || (*cmd == '	'))      *cmd++;    if(((tomatch = *cmd) == '"') || (tomatch == '\'')) { /* first nonblank quote? */      cp = ++cmd;      while(*cp) {	if(*cp == tomatch) {	  *cp = ' ';	  break;	}	cp++;      }    }    if(*cmd && (cp = find_double_colon(cmd))) {      char *cpp = cmd;      for( ; cpp < cp;)	if(((tomatch = *cpp++) == '"') || (tomatch == '\'')) {	  for(; *cpp;)	    if(*cpp++ == tomatch)	      return(separate_wcommands(cpp));	}      if(cpp >= cp) {	*cp++ = 0;	*cp++ = 0;	if(*cp)	  return(cp);      }    }  }  return(NULL);}/***********************************************************************/char *exec_waves(cmd)    char    *cmd;{  extern FILE		*fp_command;

⌨️ 快捷键说明

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