📄 xwaves_utils.c
字号:
/* * This material contains unpublished, proprietary software of * Entropic Research Laboratory, Inc. Any reproduction, distribution, * or publication of this work must be authorized in writing by Entropic * Research Laboratory, Inc., and must bear the notice: * * "Copyright (c) 1987-1990 AT&T, Inc. * "Copyright (c) 1986-1990 Entropic Speech, Inc. * "Copyright (c) 1990-1996 Entropic Research Laboratory, Inc. * All rights reserved" * * The copyright notice above does not evidence any actual or intended * publication of this source code. * * Written by: David Talkin * Checked by: * Revised by: Rod Johnson, Alan Parker, David Talkin, ERL * * xwaves_utils.c * a collection of routines of general use in "xwaves" * */static char *sccs_id = "@(#)xwaves_utils.c 1.27 28 Oct 1999 ATT/ESI/ERL";#include <Objects.h>#include <spectrogram.h>#include <file_ext.h>#include <esps/esps.h>#include <esps/fea.h>#include <sys/param.h>#include <xview/notice.h>extern Object program;extern int debug_level;extern int do_color;extern int h_spect_rescale;static char env_str[MAXPATHLEN + 20];char *get_esps_base(), *get_output_file_names();/*************************************************************************/void set_default_header(){ extern char default_header[]; if (*default_header) { static char tch[NAMELEN];#if defined(SONY_RISC) || defined(CONVEX) setenv("DEF_HEADER", default_header, 1);#else sprintf(tch, "DEF_HEADER=%s", default_header); putenv(tch);#endif }}voidset_old_sphere_format(){ extern int old_sphere_format; extern void set_old_sphere_flag(); /* in esps headers.c */ set_old_sphere_flag(old_sphere_format);}/*************************************************************************/clone_methods(so, si) Signal *so, *si;{ if (si && so) { /* Clone (possibly specialized) utility methods. */ so->utils->read_data = si->utils->read_data; so->utils->write_data = si->utils->write_data; so->utils->free_data = si->utils->free_data; so->utils->buf_start = si->utils->buf_start; so->utils->buf_end = si->utils->buf_end; so->utils->sig_dur = si->utils->sig_dur; so->utils->index_to_time = si->utils->index_to_time; so->utils->time_to_index = si->utils->time_to_index; return (TRUE); } return (FALSE);}/*************************************************************************/window_wash(handle) caddr_t handle;{ if (handle) return; printf("Xview failed to return a window; sorry...\n"); quit_proc();}static char cur_oname[NAMELEN] = "";/*************************************************************************/char *current_object_name(){ static char rv[NAMELEN]; extern Panel_item newObj_item; if (*cur_oname) { strcpy(rv, cur_oname); *cur_oname = 0; } else { *rv = 0; sscanf((char*)panel_get_value(newObj_item), "%s", rv); } return (rv);}/*************************************************************************/set_current_obj_name(name) char *name;{ if (name && *name) strcpy(cur_oname, name); else *cur_oname = 0;}/*************************************************************************/window_check_return(handle) caddr_t handle;{ if (handle) return (TRUE); printf("Xview can't create a window; sorry...\n"); return (FALSE);}/*************************************************************************/char *receiver_prefixed(str) char *str;{ static char tmp[MES_BUF_SIZE]; char junk[MES_BUF_SIZE], cd, *cdp; Object *ob, *find_object(); extern char objectname[]; if (debug_level > 1) (void) fprintf(stderr, "receiver_prefixed: function entered\n"); if (str) { while ((*str == ' ') || (*str == '\t')) str++; if ((((cd = *str) == '"') || (cd == '\''))) { cdp = ++str; while (*cdp && (*cdp != cd)) cdp++; if (*cdp) *cdp = ' '; } if (*str && sscanf(str, "%s", junk) == 1) { if ((ob = find_object(junk))) { if (debug_level > 1) (void) fprintf(stderr, "receiver_prefixed(1): returning %s\n", str); return (str); } if (*str == '.') /* means current object */ sprintf(tmp, "%s %s", objectname, str + 1); else /* assume the program is the receiver */ sprintf(tmp, "%s %s", program.name, str); if (debug_level > 1) (void) fprintf(stderr, "receiver_prefixed(2): returning %s\n", tmp); return (tmp); } } if (debug_level > 1) (void) fprintf(stderr, "receiver_prefixed(3): returning NULL\n"); return (NULL);}/*************************************************************************/esps_initialize(){}Notify_valuesigint_func(client, sig, when) Notify_client client; int sig, when;{ if (debug_level > 1) fprintf(stderr, "Killed due to signal(%d); cleaning up...\n", sig); quit_proc();}emergency_quit(){ stop_da(NULL);#ifndef NO_LIC lm_quit();#endif exit(-1);}Notify_valuesigtrm_func(client, sig, when) Notify_client client; int sig, when;{ fprintf(stderr, "Killed -- exiting.\n"); emergency_quit();}Notify_valuesigfpe_func(client, sig, when) Notify_client client; int sig, when;{ fprintf(stderr, "Floating point exception. Exiting.\n"); quit_proc();}Notify_valuesigbus_func(client, sig, when) Notify_client client; int sig, when;{ fprintf(stderr, "Bus error exception caught. Exiting.\n"); emergency_quit();}Notify_valuesigill_func(client, sig, when) Notify_client client; int sig, when;{ fprintf(stderr, "Illegal instruction exception caught. Exiting.\n"); emergency_quit();}Notify_valuesigseg_func(client, sig, when) Notify_client client; int sig, when;{ fprintf(stderr, "Seg violation exception caught. Xwaves exiting.\n"); emergency_quit();}/*************************************************************************/install_signal_handlers(frame) Frame frame;{ notify_set_signal_func(frame, sigint_func, SIGINT, NOTIFY_SYNC); notify_set_signal_func(frame, sigint_func, SIGQUIT, NOTIFY_SYNC); notify_set_signal_func(frame, sigint_func, SIGHUP, NOTIFY_SYNC); if (0 && !debug_level) { 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); } /* if(!debug_level) { * signal(SIGTERM,sigtrm_func); * signal(SIGFPE,sigfpe_func); * signal(SIGBUS,sigbus_func); * signal(SIGSEGV,sigseg_func); * signal(SIGILL,sigill_func); * } */}/*************************************************************************/void distribute_options_settings(){ extern int options; extern int dont_save_sgrams, overlay_as_number, redraw_on_release, rewrite_after_edit; dont_save_sgrams = overlay_as_number = redraw_on_release = rewrite_after_edit = 0; if (options & REPAINT_ON_RELEASE) redraw_on_release = 1; if (options & DONT_SAVE_SPGM) dont_save_sgrams = 1; if (options & SAVE_AFTER_EDIT) rewrite_after_edit = 1; if (options & BW_PLOTS) overlay_as_number = 1;}/*************************************************************************/waves_initialize(){ char *kluge, *getenv(); extern int use_dsp32, dsp_type, w_verbose; extern int fea_sd_special; /* in header.c */ extern char default_header[]; int coulduse = 0; char *ptr;#ifndef DEMO extern void set_timer();#endif#ifndef NO_LIC#ifndef DEMO if (!erl_mit()) {fprintf(stderr,"point a\n"); waves_check(); set_timer(); }#endif#endif /* This little gem is an attempt to sidestep a Sun allocator bug! */ if ((kluge = (char *) malloc(1000000))) free(kluge); else printf("You may not have enough memory to do anything interesting.\n"); setup_environ(); get_globals(); /* read the configuration file */ if ((kluge = getenv("DEF_HEADER"))) strcpy(default_header, kluge); else set_default_header(); if (was_changed("options")) distribute_options_settings();#if defined(SUN4) || defined(SG) || defined(HP700) || defined(LINUX) if (sg_audio_is_available()) { if (!was_changed("use_dsp32") && !was_changed("use_internal_audio")) /* not forced in profile */ use_dsp32 = 1; dsp_type = DSP_SGI; if (use_dsp32 && w_verbose) printf("Will use built-in D/A for play commands.\n"); }#else if ((coulduse |= dsp32c_is_available())) { if (!was_changed("use_dsp32")) /* not forced in profile */ use_dsp32 = 1; dsp_type = DSP32C_VME; if (use_dsp32 && w_verbose) printf( "DSP32C board present; will use it for spectrogram and play commands.\n"); } else if ((coulduse |= dsp32_is_available())) { if (!was_changed("use_dsp32")) /* not forced in profile */ use_dsp32 = 1; dsp_type = DSP32_FAB2; if (use_dsp32 && w_verbose) printf( "DSP32 board present; will use it for spectrogram and play commands.\n"); } if (!was_changed("use_dsp32")) /* not forced in profile */ use_dsp32 = 0; /* (Board is not available) */ if (use_dsp32) { if (!was_changed("fea_sd_special")) /* not forced in profile */ fea_sd_special = 1; if (w_verbose) printf( "(FEA_SD files will be read in as shorts; toggle with fea_sd_special)\n"); } else { if (!was_changed("fea_sd_special")) /* not forced in profile */ fea_sd_special = 0; if (coulduse && w_verbose) printf("Built-in DSP will not be used.\n"); if (w_verbose) printf("Will use external ESPS calls for spectrograms and play.\n"); }#endif get_color_depth(); if (!was_changed("do_color")) { /* color not specified in profile */ extern int cmap_depth; /* check whether color */ if (cmap_depth < 2) /* this COULD be cleverer */ do_color = 0; /* MONO hardware */ else do_color = 1; } sprintf(env_str, "XPPATH=%s/lib/Xp", (ptr = get_esps_base(NULL))); free(ptr); putenv(env_str); setup_colormap(); install_dispatch_hook();}/*************************************************************************/install_colormap(obj) register Object *obj;{ while (obj) { Signal *s = obj->signals; while (s) { View *v = s->views; while (v) { if (v->canvas) { cmap(v->canvas); return; } v = v->next; } s = s->others; } obj = obj->next; }}/*************************************************************************/iabs(i)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -