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

📄 xspectrum.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 5 页
字号:
  order_item = xv_create(panel, PANEL_TEXT,		XV_X,			    224,		XV_Y,			    21,		PANEL_LABEL_STRING,	    "order:",		PANEL_VALUE,		    mess,		PANEL_VALUE_DISPLAY_LENGTH, 3,		PANEL_NOTIFY_PROC,	    int_proc,		0);  sprintf(mess,"%7.6f",w_size);  wsize_item = xv_create(panel, PANEL_TEXT,		XV_X,			    224,		XV_Y,			    45,		PANEL_LABEL_STRING,	    "size (sec):",		PANEL_VALUE,		    mess,		PANEL_VALUE_DISPLAY_LENGTH, 8,		PANEL_NOTIFY_PROC,	    double_proc,		0);  hcurs_item  = xv_create(panel, PANEL_CHOICE,		XV_X,			    328,		XV_Y,			    100,		PANEL_LABEL_STRING,	    "Harmonic cursors:",		PANEL_LAYOUT,		    PANEL_HORIZONTAL,		PANEL_CHOOSE_ONE,	    TRUE,		PANEL_CHOICE_STRINGS,		    "On",		    "Off",		    0,		PANEL_VALUE,		    !hcurs_on,		PANEL_NOTIFY_PROC,	    newWindType,		0);  scale_item = xv_create(panel, PANEL_CYCLE,		XV_X,			    328,		XV_Y,			    125,		PANEL_LABEL_STRING,	    "Plot scale:",		PANEL_CHOICE_STRINGS,		    "log pwr (dB)",		    "magnitude",		    "power (sq mag)",		    0,		PANEL_VALUE,		    scale_type,		PANEL_NOTIFY_PROC,	    newWindType,		0);  man_item = xv_create(panel, PANEL_BUTTON, 	      XV_X,			    8, 	      XV_Y,			    173,		PANEL_LABEL_STRING,	    "xspectrum manual",		XV_KEY_DATA,		    EXVK_HELP_NAME,	    FIND_WAVES_LIB(NULL,							   "xspectrum.man"),		XV_KEY_DATA,		    EXVK_HELP_TITLE,        "xspectrum manual page",		PANEL_NOTIFY_PROC,	    exv_get_help,		0);  quit_item = xv_create(panel, PANEL_BUTTON,		XV_X,			    160,		XV_Y,			    173,		PANEL_LABEL_STRING,	    "QUIT",		PANEL_NOTIFY_PROC,	    quit_proc,		0);  horiz_c_item  = xv_create(panel, PANEL_CHOICE,		XV_X,			    332,		XV_Y,			    13,		PANEL_LABEL_STRING,	    "Horizontal cursor:",		PANEL_LAYOUT,		    PANEL_HORIZONTAL,		PANEL_CHOOSE_ONE,	    TRUE,		PANEL_CHOICE_STRINGS,		    "On",		    "Off",		    0,		PANEL_VALUE,		    !horiz_c_on,		PANEL_NOTIFY_PROC,	    newWindType,		0);  reticle_item = xv_create(panel, PANEL_CHOICE, 		XV_X,			    404,		XV_Y,			    42,		PANEL_LABEL_STRING,	    "Reticle:",		PANEL_LAYOUT,		    PANEL_HORIZONTAL,		PANEL_CHOOSE_ONE,	    TRUE,		PANEL_CHOICE_STRINGS,		    "On",		    "Off",		    0,		PANEL_VALUE,		    !reticle_on,		PANEL_NOTIFY_PROC,	    newWindType,		0);  fb_item = xv_create(panel, PANEL_CHOICE, 		XV_X,			    387,		XV_Y,			    71,		PANEL_LABEL_STRING,	    "Formants:",		PANEL_LAYOUT,		    PANEL_HORIZONTAL,		PANEL_CHOOSE_ONE,	    TRUE,		PANEL_CHOICE_STRINGS,		    "On",		    "Off",		    0,		PANEL_VALUE,		    !fb_flag,		PANEL_NOTIFY_PROC,	    newWindType,		0); /* MIT */   sprintf(mess,"%6.4f", cep_cutoff);   cep_cutoff_item = xv_create(panel, PANEL_TEXT,			       XV_X,			    230,		XV_Y,			    154, 	      PANEL_LABEL_STRING,	    "Cep. cut (sec):", 	      PANEL_VALUE,		    mess, 	      PANEL_VALUE_DISPLAY_LENGTH, 8, 	      PANEL_NOTIFY_PROC,	    double_proc, 	      0);   sprintf(mess,"%6.4f", cep_trans);   cep_trans_item = xv_create(panel, PANEL_TEXT,		XV_X,			    400,		XV_Y,			    154, 	      PANEL_LABEL_STRING,	    "Cep. trans:", 	      PANEL_VALUE,		    mess, 	      PANEL_VALUE_DISPLAY_LENGTH, 8, 	      PANEL_NOTIFY_PROC,	    double_proc, 	      0);   cep_liftering_item = xv_create(panel, PANEL_CHOICE, 		XV_X,			    275, 		XV_Y,			    175, 		PANEL_LABEL_STRING,	    "Liftering:", 		PANEL_LAYOUT,		    PANEL_HORIZONTAL, 		PANEL_CHOOSE_ONE,	    TRUE, 		PANEL_CHOICE_STRINGS, 		    "None", 		    "Lowpass",                     "Highpass", 		    0, 		PANEL_VALUE,		    cep_liftering, 		PANEL_NOTIFY_PROC,	    newWindType, 		0);   /* (XView bug?) Attaching the icon earlier screws up the panel dimensions   * and the placement of panel items.   */  (void) exv_attach_icon(frame, ERL_NOBORD_ICON, "spectrum", TRANSPARENT);  window_fit(panel);  window_fit(frame);  newFunction(NULL, current_analysis_type, NULL);   /* This program will be the first entry on the list of objects which may     receive messages. */  objlist = new_objects(av[0]);	/* It will have the program's name */  objlist->methods = &base_methods; /* and a special set of methods. */  if(!debug_level) {    /*      notify_set_signal_func(frame, sigint_func, SIGINT, NOTIFY_SYNC);      notify_set_signal_func(frame, sigtrm_func, SIGTERM, NOTIFY_ASYNC);      notify_set_signal_func(frame, sigfpe_func, SIGFPE, NOTIFY_ASYNC);      notify_set_signal_func(frame, sigbus_func, SIGBUS, NOTIFY_ASYNC);      notify_set_signal_func(frame, sigseg_func, SIGSEGV, NOTIFY_ASYNC);      notify_set_signal_func(frame, sigill_func, SIGILL, NOTIFY_ASYNC);      */    signal( SIGINT, sigint_func);    signal( SIGTERM, sigtrm_func);    signal( SIGFPE, sigfpe_func);    signal( SIGBUS, sigbus_func);    signal( SIGSEGV, sigseg_func);    signal( SIGILL, sigill_func);  }  window_main_loop(frame);	/* Relinquish control to "notifier." */}/*********************************************************************/set_blowup_op(){  char mess[MES_BUF_SIZE];  sprintf(mess,"set blowup_op %s",basename(thisprog));  mess_write(mess);}/*************************************************************************//* These translate things to and from screen to data coordinates. *//*************************************************************************/static double x_to_frequency(ob, x)    Objects *ob;    int	    x;{    Rect    *rec;    Reticle *r;    double  width;    if (!ob) return 0.0;    if (r = ob->ret)    {	x -= r->bounds.left;	width = r->bounds.right - r->bounds.left;    } else {	rec = (Rect *) xv_get(canvas_paint_window(ob->view), WIN_RECT);	x -= ob->x_off;	width = rec->r_width - 1 - ob->x_off;    }    return (x >= width) ? ob->xhigh	    : (x <= 0) ? ob->xlow	    : ob->xlow + x * (ob->xhigh - ob->xlow) / width;}/*************************************************************************/static intfrequency_to_x(ob, freq)    Objects *ob;    double  freq;{    Rect    *rec;    Reticle *r;    double  width, xoff;    int	    x;    if (ob)    { 	if (r = ob->ret)	{	    width = r->bounds.right - r->bounds.left;	    xoff = 0.5 + r->bounds.left;	/* 0.5 for rounding */	} else {	    rec = (Rect *) xv_get(canvas_paint_window(ob->view), WIN_RECT);	    width = rec->r_width - 1 - ob->x_off;	    xoff = 0.5 + ob->x_off;		/* 0.5 for rounding */	}	x = (int) (xoff + width * (freq - ob->xlow) / (ob->xhigh - ob->xlow));	return x;    }    return 0;}/*************************************************************************/static intx_to_index(ob, x, t)    Objects *ob;    int	    x;    int	    t;{    Rect    *rec;    Trace   *trace;    Reticle *r;    double  width;    int	    n, index;    double  *freqs;    if (ob && (trace = ob->trace[t]) && trace->band > 0.0 && (n = trace->n) > 0)    {	if (freqs = trace->freqs)	{	    double  f = x_to_frequency(ob, x);	    int	    i, j, k;	    if (f < freqs[i = 0])		return i;	    else if (f > freqs[j = n-1])		return j;	    else	    {		while (j - i > 1)		{		    if (f < freqs[k = (i+j)/2])			j = k;		    else			i = k;		}		return (f - freqs[i] < freqs[j] - f) ? i : j;	    }	}	else	{	    if (r = ob->ret)	    {		x -= r->bounds.left;		width = r->bounds.right - r->bounds.left;	    } else {		rec = (Rect *) xv_get(canvas_paint_window(ob->view), WIN_RECT);		x -= ob->x_off;		width = rec->r_width - 1 - ob->x_off;	    }	    if (x > 0 && width > 0.0)	    {		index = (int) (0.5 + ((n-1)/trace->band)				      * (ob->xlow - trace->band_low					 + x*(ob->xhigh - ob->xlow)/width));		return (index < 0) ? 0 : (index < n) ? index : (n-1);	    }	}    }    return 0;}/*********************************************************************/amplitude_to_y(ob, amp)    Objects *ob;    double  amp;{    Rect    *rec;    Reticle *r;    double  height, yscale, yoff;    int	    y;    if (ob)    {	if (r = ob->ret)	{	    height = r->bounds.bottom - r->bounds.top;	    yoff = 0.5 + r->bounds.bottom;	/* 0.5 for rounding */	} else {	    rec = (Rect *) xv_get(canvas_paint_window(ob->view), WIN_RECT);	    height = rec->r_height - 1 - ob->y_off;	    yoff = 0.5 + height;		/* 0.5 for rounding */	}	yscale = -height/(ob->yhigh - ob->ylow);	y = (int) (yoff + yscale * (amp - ob->ylow));	return (y <= yoff) ? y : yoff;    }    return 0;}/*********************************************************************/double y_to_amplitude(ob, y)     Objects *ob;     int y;{  Rect    *rec;  Reticle *r;  double  height, yscale, yoff, amp;  if(ob) {    if(r = ob->ret) {      height = r->bounds.bottom - r->bounds.top;      yoff = 0.5 + r->bounds.bottom; /* 0.5 for rounding */    } else {      rec = (Rect *) xv_get(canvas_paint_window(ob->view), WIN_RECT);      height = rec->r_height - 1 - ob->y_off;      yoff = 0.5 + height;	/* 0.5 for rounding */    }    yscale = -height/(ob->yhigh - ob->ylow);    amp = ob->ylow + ((y - yoff)/yscale);    return (amp);  }  return(0.0);}/*********************************************************************/inttrace_color(i)    int		i;{    static int	*c_vars[] = {&TEXT_COLOR, &CURSOR_COLOR, &YA1_COLOR,			     &YA2_COLOR,  &YA3_COLOR,    &YA4_COLOR,			     &YA5_COLOR},		n = sizeof(c_vars)/sizeof(c_vars[0]) - 1;    return (i <= n) ? *c_vars[i] : *c_vars[1 + i%n];}/*********************************************************************/static voidplotcursors(ob)    Objects	*ob;{    Xv_Window	pw;    Rect	*rec;    int		i, j, n;    int		x, y, y0[Y_CURS_MAX];    double	curs;    int		color;    if (!ob || ob->view == XV_NULL	|| (pw = canvas_paint_window(ob->view)) == XV_NULL) return;    rec = (Rect *) xv_get(pw, WIN_RECT);    for (i = 0; i < ob->x_curs_num; i++)	if ((curs = ob->cursorx[i]) >= ob->xlow && curs <= ob->xhigh)	{	    x = frequency_to_x(ob, curs);	    pw_vector(pw, x, 0, x, rec->r_height - 1,		      PIX_COLOR(CURSOR_COLOR)|(PIX_SRC^PIX_DST), CURSOR_COLOR);	}    if(horiz_c_on) {      n = 0;      for (i = 0; i < ob->y_curs_num; i++)	if ((curs = ob->cursory[i]) >= ob->ylow && curs <= ob->yhigh)	  {	    y = amplitude_to_y(ob, curs);	    for (j = 0; j < n && y0[j] != y; j++) { }	    if (j == n)		/* New y value; won't overwrite another cusor. */	      {		y0[n++] = y;	/* New distinct value. */		color = (i == 0) ? RETICLE_COLOR : trace_color(i);		pw_vector(pw, 0, y, rec->r_width - 1, y,			  PIX_COLOR(color)|(PIX_SRC^PIX_DST), color);	      }	  }    }}/*********************************************************************/static voidprintcursors(ob)    Objects	*ob;{    Xv_Window	pw;    char	mess[200];    int		i;    int		color;    if (!ob || ob->view == XV_NULL	|| (pw = canvas_paint_window(ob->view)) == XV_NULL	|| ob->cursorx[0] < ob->xlow || ob->cursorx[0] > ob->xhigh) return;    if (ob->trace[0])    {	color = trace_color(0);	sprintf(mess, "%7.1fHz   ", ob->cursorx[0]);	pw_text(pw, 50, 11, PIX_COLOR(color)|PIX_SRC, def_font, mess);    }    for (i = 0; i < TRACE_MAX && ob->trace[i]; i++)    {	color = trace_color(i);	sprintf(mess, "%5.1f%s", ob->cursory[i],		(ob->trace[i]->scale_type == SCALE_DB) ? "dB" : "  ");	pw_text(pw, 146 + 64*i, 11,		PIX_COLOR(color)|PIX_SRC, def_font, mess);    }}/*********************************************************************/send_curs_freq(name, freq)     char *name;     double freq;{

⌨️ 快捷键说明

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