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

📄 erldemo.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 3 页
字号:
/* * This material contains proprietary software of Entropic Research Laboratory, * Inc. Any reproduction, distribution, or publication without the prior * written permission of Entropic Research Laboratory, Inc. is strictly  * prohibited. Any public distribution of copies of this work authorized in  * writing by Entropic Research Laboratory, Inc. must bear the notice * *  "Copyright (c) 1990 Entropic Research Laboratory, Inc.; All rights reserved" * * Program: erldemo.c * * Written by:  John Shore * Checked by: * * This is wavesdemo - interactive front end waves+/ESPS demo */#ifndef lintstatic char *sccs_id = "@(#)erldemo.c	1.49 4/3/92	ERL";#endif#define VERSION "1.49"#define DATE "4/3/92"#define NO_AUDIO 		0#define SUN_SPARC_AUDIO 	1#define SUN_VME_AUDIO 		2#define MC5600_AUDIO 		3#define SONY_AUDIO     		4#define NETWORK_AUDIO 		5#define SGI_AUDIO               6#define REPEAT_BUTTON_KEY 1785 /*XV_KEY for repeat button*//* exists if this or another copy of erldemo is running */#define ERLDEMO_RUNNING_FLAG  "/tmp/ERLDEMO.lock"/* exists if the demo is running */#define DEMO_RUNNING_FLAG  "/tmp/erldemo.lock"/* exists if waves+ is running from demo */#define WAVES_RUNNING_FLAG  "/tmp/ewaves.lock"/* exists if slide show is running (currently not exploited)*/ #define SLIDES_RUNNING_FLAG  "/tmp/eslides.lock"/* exists if wtry is running */#define WTRY_RUNNING_FLAG "/tmp/erlwtry.lock"/* exists if a single demo is needed */#define SINGLE_DEMO_FLAG  "/tmp/erldemo.single"/* The existence of one or the other or both of these controls whether * the demo consists of a live waves+ intro, a slide show, or both */#define WAVES_DEMO_FLAG   "/tmp/erldemo.live"#define SLIDE_SHOW_FLAG   "/tmp/erldemo.slides"/* The following define the top level scripts that are called when the * buttons "start demo" and "interactive waves+" are called; they contain  * all of the logging and locking logic and should not change.  In turn * they call the next group of defines, which implement the actual demos */#define TOP_DEMO_SCRIPT "erldemo.sh"#define ONE_DEMO_SCRIPT "one_demo.sh"#define TOP_WTRY_SCRIPT "erlwtry.sh"/* The following define the demo scripts that actually implement the  * three possible active demos: the introductory (live running) waves  * demo, the slide show, and the interactive waves demo.  The first two  * are called from TOP_DEMO_SCRIPT (invoked by "Start demo" button), and * the third is called from the TOP_WTRY_SCRIPT (invoked by "Interactive * waves" button).  The actual scripts are copied to these files by  * erldemo when it starts up (with the sources determined by command-line * options) */#define WAVES_DEMO_SCRIPT "/tmp/e_wdemo.sh"#define SLIDE_SHOW_SCRIPT "/tmp/e_slides.sh"#define WTRY_SCRIPT "/tmp/e_wtry.sh"/* * system include files */#include <stdio.h>#include <signal.h>#include <xview/xview.h>#include <xview/frame.h>#include <xview/panel.h>#include <xview/svrimage.h>#include <xview/tty.h>#include <xview/text.h>#include <xview/cms.h>#include <xview/notice.h>/* * esps include files */#include <esps/esps.h>#include <esps/unix.h>#include <esps/exview.h>/* * defines */#define Fprintf (void)fprintf#define Fflush (void)fflush#define PROG Fprintf(stderr, "%s: ", ProgName)#define DEBUG(n) if (debug_level >= n) Fprintf#define ERROR_EXIT(text) {(void) fprintf(stderr, "%s: %s - exiting\n", \		ProgName, text); SYNTAX; }#define EXIT Fprintf(stderr, "\n"); remove_file(ERLDEMO_RUNNING_FLAG); exit(1);#define ERROR_EXIT1(fmt,a) {PROG; Fprintf(stderr, (fmt), (a)); EXIT}#define TRYALLOC(type,num,var,msg) { \    if (((var) = (type *) calloc((unsigned)(num),sizeof(type))) == NULL) \    ERROR_EXIT1("Can't allocate memory--%s", (msg))}#define SYNTAX Fprintf(stderr,"erldemo [-m io_type] [-s] [-W wavesintro] [-S slideshow]\n\t[-T wavestry] [-I more_info_file] [-A about_file] [-t window_title]\n\t[-X x_loc] [-Y y_loc] [-x debug_level]"); EXIT/* * system functions and variables */int getopt ();extern  optind;extern	char *optarg;/* * external ESPS functions *//* * global declarations */char *mach_io_types[] = {  "NONE",  "SUN_SPARC",  "SUN_VME",  "MASSCOMP",  "SONY",  "NETWORK",  "SGI",  NULL};/* these are ugly as globals, but hey...*/Frame mainframe = NULL;		/* top level frame - owns everything */Panel_item feedback = NULL;	/*PANEL_MESSAGE item for feedback messages*/void sig_handler();		/* interrupt handler routine */#if !defined(hpux) && !defined(IBM_RS6000) && !defined(SG)char *getwd();char *sprintf();char *calloc();#endifchar *savestring();Panel create_info_panel();Panel create_control_panel();void link_file();void set_flag_file();void remove_file();void set_play_command();void set_sparc_output();void set_sun4_output();void set_mc_output();void set_sony_output();void set_sgi_output();void set_net_output();int file_exists();int run_demo();void start_demo();void select_repeat();void select_demo();void try_waves();void exit_proc();void display_text();void display_info();void display_about();char *make_temp();void stop_demo();void feedback_message();Notify_value destroy_func();Notify_value sigint_func();int		    debug_level = 0;int                 do_color = 0;char		    *ProgName = "erldemo";/* * main program */main (argc, argv)int argc;char **argv;{ /*  * setup and initialization  */  int		    c;		/* for getopt return */  Frame frame = NULL;		/* the main frame */  Panel demo_panel;  char *waves_demo_command = NULL;  char *slideshow_command = NULL;  char *waves_try_command = NULL;  int  Wflag = 0;  int  Sflag = 0;  int  Tflag = 0;  int demo_choices;		/* allow intro, slides, or both */  char *frame_title = "Entropic Demo";   char *info_file = "edemo.info";  char *about_file = "edemo.about";  int  x_loc = 670;		/* X location of command window */  int  y_loc = 0;		/* Y location of command window */  int  mach_io_type = SUN_SPARC_AUDIO;  int  silent_demo = 0;		/* true to force silent demos */  int  frame_height;		/* height of command window */  FILE *tfd;			/* for testing /tmp write permission */  static Xv_singlecolor  ffg = {0x00, 0x00, 0x00};  static Xv_singlecolor  fbg = {0xf0, 0xff, 0xff};  if (file_exists(ERLDEMO_RUNNING_FLAG)) {    char e_message[80];		/* error message buffer */    sprintf(e_message, "         If not, please \"rm %s\".\n", 	    ERLDEMO_RUNNING_FLAG);    Fprintf(stderr, 	    "\nerldemo: It appears that another copy of the demo is running.\n");    Fprintf(stderr, e_message);    exit(1);  }  set_flag_file(ERLDEMO_RUNNING_FLAG);  xv_init (XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL);    /*   * process command line options   */  while ((c = getopt (argc, argv, "m:sW:S:T:I:A:t:X:Y:x:")) != EOF) {    switch (c) {    case 'm':      mach_io_type = lin_search(mach_io_types, optarg);      if (mach_io_type == -1) 	ERROR_EXIT1("erldemo: unknown machine type %s", optarg);      break;    case 's':      silent_demo = 1;      break;    case 'W':      waves_demo_command = optarg;      Wflag++;      break;    case 'S':      slideshow_command = optarg;      Sflag++;      break;    case 'T':      waves_try_command = optarg;      Tflag++;      break;    case 'I':      info_file = optarg;      break;    case 'A':      about_file = optarg;      break;    case 't':      frame_title = optarg;      break;          case 'X':      x_loc = atoi(optarg);      break;    case 'Y':      y_loc = atoi(optarg);      break;    case 'x':       debug_level = atoi(optarg);      break;    default:      SYNTAX;    }  }  /* check to make sure demo commands are supplied */  if (!(Wflag || Sflag))    ERROR_EXIT("erldemo: can't run without at leasts one of -W and -S");  /* make sure can read the demo commands */  if (Wflag && !file_exists(waves_demo_command))     ERROR_EXIT1("erldemo: can't read waves+ intro command %s", 		waves_demo_command);  if (Sflag && !file_exists(slideshow_command))     ERROR_EXIT1("erldemo: can't read slideshow command %s", 		slideshow_command);  if (Tflag && !file_exists(waves_try_command))     ERROR_EXIT1("erldemo: can't read interactive waves+ command %s", 		waves_try_command);  /* make sure can read the wired-in scripts */  if (!file_exists(TOP_DEMO_SCRIPT))    ERROR_EXIT1("erldemo: can't read top level demo script %s", 		TOP_DEMO_SCRIPT);  if (!file_exists(ONE_DEMO_SCRIPT))     ERROR_EXIT1("erldemo: can't read the single loop demo script %s", 		ONE_DEMO_SCRIPT);  if (Tflag && !file_exists(TOP_WTRY_SCRIPT))     ERROR_EXIT1("erldemo: can't read top level interactive waves+ script %s", 		TOP_WTRY_SCRIPT);  /* make sure can read and write in /tmp */   if ((tfd = fopen("/tmp/e_test_write", "w")) == NULL)    ERROR_EXIT("erldemo: must have read/write permission in /tmp to run; exiting")  else {    fclose(tfd);    unlink("/tmp/e_test_write");   }  /* Set initial value for panel item controlling the choice of    * intro and slide show;  This is determined by which combination   * of -W and -S was set on startup (at least one was).   */  if (Wflag && Sflag) /*both waves intro and slides are allowed*/   {    demo_choices = 3;    set_flag_file(WAVES_DEMO_FLAG);    set_flag_file(SLIDE_SHOW_FLAG);   }  else if (Sflag) /* only slideshow is allowed */   {    demo_choices = 2;    set_flag_file(SLIDE_SHOW_FLAG);   }  else if (Wflag) /* only waves intro is allowed */   {    demo_choices = 1;    set_flag_file(WAVES_DEMO_FLAG);   }  DEBUG(1)(stderr, "erldemo: setting up files and links in /tmp\n");  /*default initial demo repeat is single */  set_flag_file(SINGLE_DEMO_FLAG);  /* setup up command scripts for waves+ intro, slide show, and    * interactive waves+   */  if (Wflag)     link_file(waves_demo_command, WAVES_DEMO_SCRIPT);  if (Sflag)     link_file(slideshow_command, SLIDE_SHOW_SCRIPT);  if (Tflag)    link_file(waves_try_command, WTRY_SCRIPT);  DEBUG(1)(stderr, "erldemo: creating base frame (command window)\n");  /* Since the -m option yields different sized stacks of I/O buttons,    * we set the overall height of the window accordingly.  Also    * affected by whether or not there's a tryout button (-T).    */  switch (mach_io_type) {  case SUN_SPARC_AUDIO:    if (Tflag)      frame_height = 287;    else       frame_height = 266;    break;  case SUN_VME_AUDIO:  case MC5600_AUDIO:  case SONY_AUDIO:  case NETWORK_AUDIO:  case SGI_AUDIO:  case NO_AUDIO:  default:    frame_height = 266;    break;    }  frame = (Frame)xv_create(NULL, FRAME,				   FRAME_LABEL,    frame_title,			   XV_X,     x_loc,			   XV_Y,     y_loc,			   XV_WIDTH, 375,			   XV_HEIGHT, frame_height,/* Next 3 lines fix colormap problem on Sony-- don't know why. */                           FRAME_INHERIT_COLORS,       FALSE,                           FRAME_FOREGROUND_COLOR,     &ffg,                           FRAME_BACKGROUND_COLOR,     &fbg,			   FRAME_CLOSED, FALSE,			   FRAME_SHOW_FOOTER, FALSE,			   FRAME_SHOW_RESIZE_CORNER, TRUE,			   NULL);  if (frame == NULL) {    Fprintf(stderr, "%s: couldn't create base frame\n");    EXIT;  }  notify_interpose_destroy_func(frame, destroy_func);  notify_set_signal_func(frame, sigint_func, SIGINT, NOTIFY_SYNC);  /* set global for color treatment*/    do_color = exv_color_status(frame);  demo_panel = create_info_panel(frame, about_file, info_file);  demo_panel = create_control_panel(frame, TOP_DEMO_SCRIPT, TOP_WTRY_SCRIPT, 				    mach_io_type, demo_choices, 				    Tflag, silent_demo);   window_fit(frame);  (void) exv_attach_icon(frame, ERL_NOBORD_ICON, "demo", TRANSPARENT);  /*set global*/  mainframe = frame;  xv_main_loop(frame);  exit(0);}Panelcreate_info_panel(frame, about_file, info_file)Frame  frame;			/* the main frame */char *about_file;		/* file for "about this demo" */char *info_file;		/* file for "for more info" */{  /*  create basic frame with titles and buttons for information   about the demo and more info about the products.  */  Panel  con_panel;		/* panel for control buttons */  Panel_item button;		/* temp handle */  Panel_item message;		/* temp handle */  DEBUG(1) (stderr, "Entered create_info_panel\n");  con_panel = (Panel)xv_create(frame, PANEL, 			       OPENWIN_SHOW_BORDERS, TRUE,			       WIN_BORDER, TRUE,			       XV_X, 0,			       XV_Y, 0,			       XV_WIDTH, WIN_EXTEND_TO_EDGE,			       XV_HEIGHT, 101,			       NULL);  if (do_color) {    (void) exv_init_colors(con_panel); 

⌨️ 快捷键说明

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