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

📄 xample.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 2 页
字号:
/* Copyright (c) 1995 Entropic Research Laboratory, Inc. *//* * 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) 1993  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 * * Brief description: A skeleton attachment. * */static char *sccs_id = "@(#)xample.c	1.3	9/26/95	ATT/ERL";#ifndef hpux#include <sys/param.h>#else#define MAXPATHLEN 1024#endif#include <Objects.h>#include <esps/esps.h>#define SYNTAX USAGE("xample [-w wave_pro] [-n<waves or other host program>] [-p<program number>] [-v<program version>] [-P<host program number>] [-V<host program version>]");static  char *wave_pro = ".wave_pro"; /* profile name from command line */int    debug_level = 0;/* Referred to in globals.c, but not necessarily used in this program. */int    command_paused = 0;extern u_char red[], blue[], green[];int	use_dsp32; double	image_clip = 7.0, image_range = 40.0;extern char ok[], null[];	/* in message.c */char *host = "waves", *thisprog = "xample";/* This prototype structure can be expanded to handle the needs of the   application.  It's only required fields are name, methods and next. */typedef struct objects {  char *name;  char *signal_name;  Methods *methods;  struct objects *next;} Objects;Objects *get_receiver();/* This is the master lists of all objects managed by the program. */Objects *objlist = NULL;/* These are some of the "global" attributes.  This list can be   expanded at will.  Attachments commonly keep track of the xwaves   signals (signame); the display ensemble name (objectname), and a local   file associated with these (file). */static char objectname[NAMELEN], file[NAMELEN], signame[NAMELEN];static Selector  a12 = {"signal", "%s", signame, NULL},  a1 = {"name", "%s", objectname, &a12},  a0 = {"file", "%s", file, &a1};/* These are the "prognum" and "versnum" of the host RPC server   (usually xwaves.  They are usually set automatically when a program is   "attached" to xwaves. */extern int  svrnum, svrver;/* mynum and myver are unique numbers to identify this program's   "prognum" and "versnum" (see man rpc). */int  mynum = 5271993, myver = 9876;/* This function tells xwaves what to do when the attachment's name is   selected from the menu.  This example issues the "mark" command with   the signal name and the cursor time as arguments. *//*********************************************************************/char *generate_startup_command(mynum, myver)     int mynum, myver;{  static char com[MES_BUF_SIZE];  sprintf(com,"add_op name %s op #send function %s prognum %d versnum %d command _name mark signal _file time _cursor_time",	   basename(thisprog), thisprog, mynum, myver);  return(com);}/*********************************************************************//*********************************************************************/main(ac, av)     int ac;     char **av;{  extern Objects *objlist, *new_objects();  extern Methods base_methods;  extern int attachment;  char mess[MES_BUF_SIZE];  int i;  extern int optind;  extern char *optarg;  int ch;  thisprog = av[0];  while ((ch = getopt(ac, av, "w:n:P:V:p:v:")) != EOF)    switch (ch)      {      case 'n':	host = optarg; /* receiver name for commands sent FROM this program */	break;      case 'w':		/* a profile file; same syntax as .wave_pro */	wave_pro = optarg;	break;      case 'P':		/* prognum and versnum of host and attachment */	svrnum = atoi(optarg);	break;      case 'V':	svrver = atoi(optarg);	break;      case 'p':	mynum = atoi(optarg);	break;      case 'v':	myver = atoi(optarg);	break;      default:	SYNTAX	exit(-1);      }  /* This reads the profile file grabbing all relevant to the list     pointed to by a0, and also all of the "standard" xwaves globals     (perhaps most, or none of which will be used) */  get_all_globals(wave_pro, &a0);    /* Start the list of active objects.  First item is the program     itself.  Note its methods list (base_methods).  This list may be     expanded at will. */  objlist = new_objects(av[0]);  objlist->methods = &base_methods;  /* This program example does not use X graphics (via xview). So, the     following call is issued. */  start_communication(svrnum, svrver, myver, mynum,		      generate_startup_command(mynum,myver));  /* The above call NEVER RETURNS.  All subsequent operations occur     asynchronously as RPC requests from xwaves. (Or via SIGNAL handlers in     this program. start_communication() enters svc_run(). (See man rpc) */  /* If an X window manager/dispatcher IS to be used, call     setup_communication(), instead, with exactly the same arguments as     above in start_communication().  Setup_communication() DOES return.     You are then expected to eventually enter the "notifier" loop via a     call to something like window_main_loop() */}/* This is a procedure that can be called by this program when it   wants to disconnect from xwaves. *//*********************************************************************/void quit_proc(item, event)     Panel_item item;     Event *event;{  cleanup();  kill_proc();}/* This example shows how a command might be sent to xwaves.  The   syntax of the command generated below could include all of the forms   described in the xwaves manual.  This particular example is designed   for telling xwaves to put up marks on its dieplays. *//*********************************************************************/waves_send(name,command,color,time)     char *name, *command;     int color;     double time;{  char mes[MES_BUF_SIZE];    sprintf(mes,"%s %s time %f color %d\n",name,command,time,color);  mess_write(mes);  return(TRUE);  }/*********************************************************************/char *meth_kill(ob, args)     Objects *ob;     char *args;{  static char file[NAMELEN],object[NAMELEN], chart[NAMELEN];  static Selector a0 = {"file","%s",file,NULL},                  a1 = {"name","%s",object,&a0},                  a2 = {"chart","%s",chart,&a1};  Objects *o;  int got;  got = get_args(args,&a2);  /* This would typically take the name, and optionally other     information like "chart" or "file" and destroy the corresponding     objects. */  return(ok);}/*********************************************************************/char *meth_set(ob, args)     Objects *ob;     char *args;{  fprintf(stderr,"meth_set(%s)\n",args);  get_args(args, &a0);  /* This is how items in the Selector list a0 above (or any other     Selector list you wish to create) may be assigned values.  Note that     the get_args() call will CREATE new variables if the names specified     in the args list do not already exist. */  return(ok);}/*********************************************************************/char *meth_mark(ob, args)     Objects *ob;     char *args;{  static double time, rstart, rend;  static int color;  static char file[NAMELEN];  static Selector    a2 = {"time", "%lf", (char*)&time, NULL},    a1 = {"color", "%d", (char*)&color, &a2},    a0b = {"signal", "%s", file, &a1},    a0 = {"file", "%s", file, &a0b};  time = 0.0;  *file = 0;  color = -1;  fprintf(stderr,"meth_mark(%s)\n",args);  if(get_args(args, &a0) ) {    /* This is an example of a routine that might take time-stamp       information from xwaves and do something to a particular file or       signal in relation to the timeing info. */    return(ok);  }  return(null);}

⌨️ 快捷键说明

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