📄 xspectrum.c
字号:
get_args(args, &gg1); if (do_region != 0) do_region = 1; xv_set(limits_item, PANEL_VALUE, do_region, 0); if (hcurs_on != 0) hcurs_on = 1; xv_set(hcurs_item, PANEL_VALUE, !hcurs_on, 0); if (horiz_c_on != 0) horiz_c_on = 1; xv_set(horiz_c_item, PANEL_VALUE, !horiz_c_on, 0); if (reticle_on != 0) reticle_on = 1; xv_set(reticle_item, PANEL_VALUE, !reticle_on, 0); if (fb_flag != 0) fb_flag = 1; xv_set(fb_item, PANEL_VALUE, !fb_flag, 0); LIM_LOW(scale_type, 0); LIM_HIGH(scale_type, 2); xv_set(scale_item, PANEL_VALUE, scale_type, 0); SET_PANEL_DOUBLE(preemp_item, preemp); /* MIT */ SET_ABS(cep_trans); SET_PANEL_DOUBLE(cep_trans_item, cep_trans); SET_ABS(cep_cutoff); SET_PANEL_DOUBLE(cep_cutoff_item, cep_cutoff); LIM_HIGH(cep_cutoff, 1); if (cep_cutoff > 1 || cep_cutoff < 0) cep_cutoff = 0; xv_set(cep_liftering_item, PANEL_VALUE, cep_liftering, 0); SET_ABS(i_f_dur); SET_PANEL_DOUBLE(fsize_item, i_f_dur); SET_ABS(i_f_int); SET_PANEL_DOUBLE(int_c_item, i_f_int); SET_ABS(w_size); SET_PANEL_DOUBLE(wsize_item, w_size); if (xsp_max_lpc_order > MAX_LPC_ORDER) xsp_max_lpc_order = MAX_LPC_ORDER; LIM_LOW(order, 1); LIM_HIGH(order, xsp_max_lpc_order); SET_PANEL_INT(order_item, order); LIM_LOW(weight_type, 0); LIM_HIGH(weight_type, 3); /* we reset the method-associated window weighting type. We ` don't need to reset the weightType_item on the panel, as the call to newFunct_item will take care of that */ def_weight_type[current_analysis_type] = weight_type; LIM_LOW(current_analysis_type, 0); LIM_HIGH(current_analysis_type, 10); xv_set(newFunct_item, PANEL_VALUE, current_analysis_type, 0); /* this sets the analysis funtion() and also calls recompute_all()*/ newFunction(NULL, current_analysis_type, NULL); return(Ok);}/*********************************************************************/char *make_new_object(str) char *str;{ char name[NAMELEN], command[NAMELEN], *meth_make_object(); sscanf(str,"%s",name); /* get the name of the "object" to be created. */ if(strlen(name)) { sprintf(command,"name %s",name); /* put it into a message */ if(!strcmp(Ok,meth_make_object(NULL,command))) { return(get_receiver(name)); } } return(NULL);}/*************************************************************************//* The following are procedures for retrieving data from the control panel created in main(). *//*************************************************************************/void double_proc(item, event) /* accept numeric input from a panel< item */ Panel_item item; Event *event;{ double val; #define PNZ_VAL(x) (x = (val > 0.0)? val : x) sscanf((char *) xv_get(item, PANEL_VALUE), "%lf", &val); if(item == wsize_item) /* Examples of vectoring the input values */ PNZ_VAL(w_size); if(item == preemp_item) preemp = val; if(item == int_c_item) i_f_int = val; if(item == fsize_item) i_f_dur = val; /* MIT */ if(item == cep_cutoff_item) { cep_cutoff = val; if(!doing_cepstral_smoothing()) return; } if(item == cep_trans_item) { cep_trans = val; if(!doing_cepstral_smoothing()) return; } recompute_all(); /* redo all spectra with the new parameter */#undef PNZ_VAL}/*************************************************************************/void int_proc(item, event) /* accept numeric input from a panel item */ Panel_item item; Event *event;{ int val; char junk[10]; #define PNZ_VAL(x) (x = (val > 0)? val : x) sscanf((char *) xv_get(item, PANEL_VALUE), "%d", &val); if(item == order_item) /* Example of vectoring an input value */ if (xsp_max_lpc_order > MAX_LPC_ORDER) xsp_max_lpc_order = MAX_LPC_ORDER; if(PNZ_VAL(order) > xsp_max_lpc_order) { order = xsp_max_lpc_order; sprintf(junk,"%d",order); xv_set(item, PANEL_VALUE, junk, 0); } recompute_all(); /* redo all spectra with the new parameter */#undef PNZ_VAL}/*************************************************************************/void newFunction(item, value, event) Panel_item item; int value; Event *event;{ int (*fun)(); Funlist *fp = &fun0; int func_id = value; /* set corresponding window weighting */ current_analysis_type = value; weight_type = def_weight_type[current_analysis_type]; xv_set(weightType_item, PANEL_VALUE, weight_type, 0); while(fp && value--) fp = fp->next; if(fp->funct) { function = fp->funct; esps_spect_method = fp->esps_method; recompute_all(); /* redo all spectra with the new parameter */ } return;}/*************************************************************************/void newWindType(item, value, event) Panel_item item; int value; Event *event;{ if(item == weightType_item) { weight_type = value; def_weight_type[current_analysis_type] = weight_type; } else if(item == limits_item) { do_region = value; return; } else if(item == hcurs_item) hcurs_on = !value; else if(item == horiz_c_item) horiz_c_on = !value; else if(item == scale_item) scale_type = value; else if(item == reticle_item) reticle_on = !value; else if(item == fb_item) fb_flag = !value; else if(item == cep_liftering_item) { /* MIT */ cep_liftering = value; if(!doing_cepstral_smoothing()) return; } recompute_all(); /* redo all spectra with the new parameter */}/*********************************************************************/void quit_proc(item, event) Panel_item item; Event *event;{ cleanup(); kill_proc();}/*********************************************************************/char *generate_startup_command(registry_name) char *registry_name;{ static char com[MES_BUF_SIZE]; sprintf(com,"add_op name %s op #send function %s registry %s command _name mark signal _file time _cursor_time rstart _l_marker_time rend _r_marker_time", basename(thisprog), thisprog, registry_name); return(com);}/*********************************************************************//*********************************************************************//* This program is designad to be called as an "attachment" to programs like "xwaves," but can be run stand-alone for debugging and other purposes. */extern int optind; /* for use of getopt() */extern char *optarg; /* for use of getopt() */extern int fullscreendebug;static char env_str[MAXPATHLEN+20];main(ac, av) int ac; char **av;{ static void doit(); /* the procedure which handles mouse interaction */ static Notify_value iocatcher(); /* handles pipe I/O for host communication*/ Objects *new_objects(); extern Methods base_methods; /* a list of things that the program can do */ char mess[100]; extern char default_header[]; /* dummy header to use if signals have none (in copheader.c) */ int rem_args; /* no. of args after getopt processing */ int i; int ch; /* option letter read by getopt */ char *server_name = "xwaves"; extern Display *X_Display; extern Window comm_window; extern char *registry_name; extern Frame daddy; /* global reference in xprint_setup.c and xnotice.c */ fullscreendebug = 1; /* this global inhibits server grabs that cause problems on the SGI */ thisprog = av[0]; while ((ch = getopt(ac, av, "w:n:c:")) != EOF) switch (ch) { case 'n': host = optarg; break; case 'w': wave_pro = optarg; break; case 'c': server_name = optarg; break; default: SYNTAX if(debug_level) for(ch = 0; ch < ac; ch++) fprintf(stderr,"%s ",av[ch]); fprintf(stderr,"\n"); exit(-1); } attachment = TRUE; /* make cmap create static colormap segment */ def_font = (Xv_Font) xv_find(XV_NULL, FONT, FONT_FAMILY, FONT_FAMILY_DEFAULT_FIXEDWIDTH, 0); def_font_width = (int) xv_get(def_font, FONT_DEFAULT_CHAR_WIDTH); def_font_height = (int) xv_get(def_font, FONT_DEFAULT_CHAR_HEIGHT); get_all_globals(wave_pro, &gg1); sprintf(env_str,"XPPATH=%s/lib/Xp",get_esps_base(NULL)); putenv(env_str); /* just in case fea_sd_special is set in the .wave_pro, we reset it here; we want all data types read in as they are in the file */ fea_sd_special = 0; get_color_depth(); setup_colormap(); menu = make_menu(); /* Create a control panel. */ /* initial position can be specified via globals (.wave_pro) */ daddy = /* global reference in xprint_setup.c and xnotice.c */ frame = xv_create(XV_NULL, FRAME, XV_X, (xsp_ctlwin_x >= 0) ? xsp_ctlwin_x : 590, XV_Y, (xsp_ctlwin_y >= 0) ? xsp_ctlwin_y : 0, XV_LABEL, "Spectrum Analyzer", FRAME_INHERIT_COLORS, FALSE, WIN_IGNORE_EVENTS, WIN_ASCII_EVENTS, 0, 0); notify_interpose_destroy_func(frame, destroy_func); /* set up communications with the host (xwaves) */ if (!setup_attach_comm(frame, server_name, "xspectrum")) { fprintf(stderr, "Failed to setup ipc communications\n"); exit(0); } sprintf(mess, "Spectrum Analyzer %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); panel = xv_create(frame, PANEL, XV_X, 0, XV_Y, 0, 0); window_wash(panel); newFunct_item = xv_create(panel, PANEL_CYCLE, XV_X, 8, XV_Y, 16, PANEL_LABEL_STRING, "Analysis type:", PANEL_CHOICE_STRINGS, fun0.name, fun1.name,/* fun2.name,*//* fun3.name,*/ fun4.name, fun5.name, fun6.name, fun7.name, fun8.name, fun9.name, fun10.name, fun11.name,/* MIT */ fun13.name, 0, PANEL_VALUE, current_analysis_type, PANEL_NOTIFY_PROC, newFunction, 0); weightType_item = xv_create(panel, PANEL_CYCLE, XV_X, 8, XV_Y, 40, PANEL_LABEL_STRING, "Window type:", PANEL_CHOICE_STRINGS, "rectangular", "Hamming", "cos^4", "Hanning", 0, PANEL_VALUE, weight_type, PANEL_NOTIFY_PROC, newWindType, 0); limits_item = xv_create(panel, PANEL_CHOICE, XV_X, 8, XV_Y, 68, PANEL_LABEL_STRING, "Window limits from:", PANEL_LAYOUT, PANEL_HORIZONTAL, PANEL_CHOOSE_ONE, TRUE, PANEL_CHOICE_STRINGS, "Cursor +- size/2", "Markers", 0, PANEL_VALUE, do_region, PANEL_NOTIFY_PROC, newWindType, 0); sprintf(mess,"%6.4f",preemp); preemp_item = xv_create(panel, PANEL_TEXT, XV_X, 8, XV_Y, 101, PANEL_LABEL_STRING, "Preemphasis coeff:", PANEL_VALUE, mess, PANEL_VALUE_DISPLAY_LENGTH, 8, PANEL_NOTIFY_PROC, double_proc, 0); sprintf(mess,"%7.6f",i_f_dur); fsize_item = xv_create(panel, PANEL_TEXT, XV_X, 8, XV_Y, 125, PANEL_LABEL_STRING, "Inverse filter intvl. (sec):", PANEL_VALUE, mess, PANEL_VALUE_DISPLAY_LENGTH, 8, PANEL_NOTIFY_PROC, double_proc, 0); sprintf(mess,"%6.4f",i_f_int); int_c_item = xv_create(panel, PANEL_TEXT, XV_X, 8, XV_Y, 149, PANEL_LABEL_STRING, "Integration coeff:", PANEL_VALUE, mess, PANEL_VALUE_DISPLAY_LENGTH, 8, PANEL_NOTIFY_PROC, double_proc, 0); sprintf(mess,"%d",order);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -