From ucsd!nosc!humu!uhccux!lee Mon Feb 20 20:56:31 PST 1989


I'm just beginning to modify the D10 version of Tim Thompson's
Glib posted by Michael Kesti to work with my K1.  I couldn't
face all the finicky details of specifying the menus, so I
wrote a program generator to help.  Maybe it will be useful
to others working with Glib.  Following is a shar file -- see
the introductory comment in makemenu.l for some explanation
of how it is supposed to work.  I've tested it on a Unix
BSD system (Ultrix 2.0).

		Greg, lee@uhccux.uhcc.hawaii.edu
------------------cut----------------------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  makemenu.l d10wfg.menu
# Wrapped by lee@uhccux on Mon Feb 20 04:46:16 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'makemenu.l' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'makemenu.l'\"
else
echo shar: Extracting \"'makemenu.l'\" \(5373 characters\)
sed "s/^X//" >'makemenu.l' <<'END_OF_FILE'
X%{
X/*	makemenu.l	-- Greg Lee, lee@uhccux.uhcc.hawaii.edu
X			   February 1989
X
X	Generate C language menu module for Glib from menu specification.
X
XCompile:
X	flex makemenu.l
X	cc -o makemenu lex.yy.c
Xor
X	lex makemenu.l
X	cc -o makemenu lex.yy.c -ll
X
XUsage:
X	makemenu <file.menu >file.c
X
XDescription:
X
XMakemenu simplifies constructing and modifying synthesizer-specific
Xmodules for Tim Thompson's Glib.  It allows the form of the on-screen
Xmenu to be specified as a picture in the menu source file, and generates
X'setval' and 'getval' calls automatically.
X
XThe following characterization of how makemenu works is probably
Xnot entirely clear.  Look at the example d10wfg.menu and the
Xsource code to get a more exact idea.  The source d10wfg.menu
Xshould give a C file equivalent to d10wfg.c in the d10 version
Xof Glib done by Michael Kesti.
X
XThe menu source file should contain five special preprocessor
Xdirectives: '#MENU' (once), '#END' (once), '#O' (one for each
Xlabel name), '#GETVAL' (once), and '#SETVAL' (once).  The source
Xfile has four sections:
X	(1) the portion before the '#MENU' directive is passed
X	    through unchanged to the output,
X	(2) a picture of the screen menu is given between the
X	    '#MENU' and '#END' directives,
X	(3) after the '#END' directive is C code with '#O' directives
X	    which specify the data offsets of variables and with
X	    '%%' or '@@' references to the screen locations for
X	    variable values, and
X	(4) more C code containing somewhere the '#SETVAL' and
X	    '#GETVAL' directives which cause a series of calls
X	    to the 'setval' and 'getval' functions to be generated,
X	    making use of the offset information given by the '#O'
X	    directives in the preceding section.
X
XThe picture of the screen menu has constant strings in the position
Xthey will be output to the screen and '%' or '@' in each position
Xwhere the current value of some variable is to be displayed by
XGlib.  The locations of the '%'s and '@'s are remembered in the
Xorder in which they are encountered (scanning left-to-right and
Xtop-to-bottom in the picture), then the corresponding row/column
Xcoordinates are substituted for '%%'s and '@@'s encountered in
Xsection 3 of the source file.  The '%'s and '@'s are stored
Xindependently so as to make it more convenient to specify menus
Xthat have two columns of values.
X
XThe '#O' specifications are given in the form:
X#O <integer-offset> "<label-name>" ...
Xand the quoted label-name is passed through unchanged to the
Xoutput.
X
X*/
X#define MAXLINE 133
X#define MAXVAL 100
X#define MAXVSTRINGS 200
X#define MAXBUF 2000
X
X	int i, j, k, wcol=0, col=0, row=0;
X	char word[MAXLINE];
X	int wordp = 0;
X	int valpos[MAXVAL][2];
X	int valpos2[MAXVAL][2];
X	int valcnt = 0;
X	int valcnt2= 0;
X	int offset;
X	int nlist[MAXVSTRINGS][2];
X	int np = 0;
X	char buf[MAXBUF];
X	int bufp=0;
X%}
X
X%s M IG VAL VSTRING
X
X%%
X
X<IG>^#[ \t]*MENU.*\n	BEGIN(M);
X<IG>\n			ECHO;
X<IG>.			ECHO;
X
X<M>"@"	{	writeword();
X		if (valcnt2+1 >= MAXVAL) {
X		    fprintf(stderr,"makemenu: too many @s in menu\n");
X		    exit(1);
X		}
X		valpos2[valcnt2][0] = row;
X		valpos2[valcnt2++][1] = col;
X		col += 1;
X};
X
X<M>"%"	{	writeword();
X		if (valcnt+1 >= MAXVAL) {
X		    fprintf(stderr,"makemenu: too many %%s in menu\n");
X		    exit(1);
X		}
X		valpos[valcnt][0] = row;
X		valpos[valcnt++][1] = col;
X		col += 1;
X};
X
X<M>[ ]*	{	if (yyleng > 4) writeword();
X		else if (wordp) for (i=0; i<yyleng; i++) append(' ');
X		col += yyleng;
X};
X
X<M>\t  {	writeword(); col = ((col + 8)/8)*8;
X};
X
X<M>\n  {	writeword(); col = 0; row += 1;
X};
X
X<M>.  {		append(yytext[0]); col += 1;
X};
X
X<M>^#[ \t]*END.*\n  {
X		BEGIN(VAL); i = 0; j = 0;
X};
X
X<VAL>^"#O "[0-9]+[ \t\n]*  {
X		offset = atoi(yytext+3);
X		BEGIN(VSTRING);
X};
X
X<VSTRING>\"[^"\n]+/\"  {
X		if (np+1 >= MAXVSTRINGS) {
X		    fprintf(stderr,"makemenu: too many VSTRINGs\n");
X		    exit(1);
X		}
X		if (bufp+yyleng >= MAXBUF) {
X		    fprintf(stderr,"makemenu: out of storage room\n");
X		    exit(1);
X		}
X		nlist[np][1] = offset;
X		nlist[np++][0] = bufp;
X		strcpy(buf+bufp, yytext+1);
X		bufp += yyleng;
X		ECHO;
X		BEGIN(VAL);
X};
X
X<VSTRING>[^"]*	fprintf(stderr,"\nmakemenu: #O spec not followed by string\n");
X
X<VAL>^#[ \t]*SETVAL.*\n  {
X		for (k=0; k<np; k++)
X		    printf("setval(\"%s\",data[RESERVESIZE + %d]);\n",
X			buf+nlist[k][0], nlist[k][1]);
X};
X
X<VAL>^#[ \t]*GETVAL.*\n  {
X		for (k=0; k<np; k++)
X		    printf("data[RESERVESIZE + %d] = getval(\"%s\");\n",
X			nlist[k][1], buf+nlist[k][0]);
X};
X
X<VAL>\\%%+	printf("%s", yytext+1);
X<VAL>\\@@+	printf("%s", yytext+1);
X
X<VAL>"@@"  {	if (j < valcnt2) {
X			printf("%d, %d", valpos2[j][0], valpos2[j][1]);
X			j++;
X		}
X		else fprintf(stderr,"\nmakemenu: too many @@s\n");
X};
X
X<VAL>"%%"  {	if (i < valcnt) {
X			printf("%d, %d", valpos[i][0], valpos[i][1]);
X			i++;
X		}
X		else fprintf(stderr,"\nmakemenu: too many %%%%s\n");
X};
X
X<VAL>.		ECHO;
X<VAL>\n		ECHO;
X
X%%
Xmain()
X{
X	word[0] = 0;
X	BEGIN(IG);
X	yylex();
X	if (i+1 < valcnt) fprintf(stderr,"\nmakemenu: not enough %%%%s\n");
X	if (j+1 < valcnt2) fprintf(stderr,"\nmakemenu: not enough @@s\n");
X	exit(0);
X}
X
Xappend(c)
Xchar c;
X{
X	if (wordp+1 >= MAXLINE) {
X	    fprintf(stderr,"makemenu: string in menu too long\n");
X	    exit(1);
X	}
X	if (!wordp) wcol = col;
X	word[wordp++] = c;
X	word[wordp] = 0;
X}
X
Xwriteword()
X{
X	if (wordp) {
X		while (word[--wordp] == ' ') ;
X		word[++wordp] = 0;
X		printf("%d,%d,\"%s\",\n", row, wcol, word);
X		wordp = 0;
X		word[wordp] = 0;
X	}
X}
END_OF_FILE
if test 5373 -ne `wc -c <'makemenu.l'`; then
    echo shar: \"'makemenu.l'\" unpacked with wrong size!
fi
# end of 'makemenu.l'
fi
if test -f 'd10wfg.menu' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'d10wfg.menu'\"
else
echo shar: Extracting \"'d10wfg.menu'\" \(8416 characters\)
sed "s/^X//" >'d10wfg.menu' <<'END_OF_FILE'
X/*
X * GLIB - a Generic LIBrarian and editor for synths
X *
X * D10 Tone Waveform Generator Librarian
X *
X * Code started 24 JAN 89 --  Michael R. Kesti mrk@gvgspd.GVG.TEK.COM
X * Sample menu specification -- Greg lee lee@uhccux.uhcc.hawaii.edu
X */
X
X#include "glib.h"
X#include "machdep.h"
X#include "vis.h"
X
X#define D10TONSIZE 246
X#define RESERVESIZE 20
X
Xchar *visnum(), *visonoff();
X
X/* This array contains arbitrary screen labels */
Xstruct labelinfo Ld10wfg[] = {
X
X#MENU for wfg
X
X
X
XCOMMON                                   PITCH ENV         1    2    3    4
X-----------------                        -------------------------------------
X                                            Depth	  @    @    @    @ 
X   Structures       %         %		    Vel Sens	  @    @    @    @ 
X   Partial Ena    %			    Time KF	  @    @    @    @ 
X   Env Mode	  %			    Attack	  @    @    @    @ 
X					    Decay	  @    @    @    @ 
XWAVEFORM GEN      1    2    3    4	    Recover	  @    @    @    @ 
X-------------------------------------	    Release	  @    @    @    @ 
X   Coarse Pitch	 %    %    %    %	    Start Lev	  @    @    @    @ 
X   Fine Pitch    %    %    %    %	    Attack Lev	  @    @    @    @ 
X   Pitch KF	 %    %    %    %	    Decay Lev	  @    @    @    @ 
X   Bend Switch	 %    %    %    %	    End Lev	  @    @    @    @ 
X   Wave/PCMBank	 %    %    %    %	    LFO Rate	  @    @    @    @ 
X   PCM Number	 %    %    %    %	    LFO Depth	  @    @    @    @ 
X   Pulse Width	 %    %    %    %	    Mod Sens	  @    @    @    @ 
X   PW Vel Sens	 %    %    %    %
X
X
X
X Press SPACE BAR to sound note @   at volume @   for duration @  on channel @ .
X#END wfg menu
X
X-1,-1,NULL
X};
X
Xstruct paraminfo Pd10wfg[] = {
X
X#O 10 "struct12",		NULL,	-1,-1, %%, visstruct,	0,  12,  0, 0,
X#O 11 "struct34",		NULL,	-1,-1, %%, visstruct,	0,  12,  0, 0,
X#O 12 "parmute",		NULL,	-1,-1, %%, vispmute,	0,  15,  0, 0,
X#O 13 "envmode",		NULL,	-1,-1, %%, visenvmode,	0,   1,  0, 0,
X
X#O 14 "wg_coarse_pitch1",	NULL,	-1,-1, %%, viscpitch,	0,  96,  0, 0,
X#O 72 "wg_coarse_pitch2",	NULL,	-1,-1, %%, viscpitch,	0,  96,  0, 0,
X#O 130"wg_coarse_pitch3",	NULL,	-1,-1, %%, viscpitch,	0,  96,  0, 0,
X#O 188"wg_coarse_pitch4",	NULL,	-1,-1, %%, viscpitch,	0,  96,  0, 0,
X#O 15 "wg_fine_pitch1",	NULL,	-1,-1, %%, visfinetune,	0, 100,  0, 0,
X#O 73 "wg_fine_pitch2",	NULL,	-1,-1, %%, visfinetune,	0, 100,  0, 0,
X#O 131"wg_fine_pitch3",	NULL,	-1,-1, %%, visfinetune,	0, 100,  0, 0,
X#O 189"wg_fine_pitch4",	NULL,	-1,-1, %%, visfinetune,	0, 100,  0, 0,
X#O 16 "wg_pitch_kf1",		NULL,	-1,-1, %%, vispkeyfol,	0,  16,  0, 0,
X#O 74 "wg_pitch_kf2",		NULL,	-1,-1, %%, vispkeyfol,	0,  16,  0, 0,
X#O 132"wg_pitch_kf3",		NULL,	-1,-1, %%, vispkeyfol,	0,  16,  0, 0,
X#O 190"wg_pitch_kf4",		NULL,	-1,-1, %%, vispkeyfol,	0,  16,  0, 0,
X#O 17 "wg_bend_switch1",	NULL,	-1,-1, %%, visonoff,	0,   1,  0, 0,
X#O 75 "wg_bend_switch2",	NULL,	-1,-1, %%, visonoff,	0,   1,  0, 0,
X#O 133"wg_bend_switch3",	NULL,	-1,-1, %%, visonoff,	0,   1,  0, 0,
X#O 191"wg_bend_switch4",	NULL,	-1,-1, %%, visonoff,	0,   1,  0, 0,
X#O 18 "wg_wave_bank1",	NULL,	-1,-1, %%, viswavebank,	0,   3,  0, 0,
X#O 76 "wg_wave_bank2",	NULL,	-1,-1, %%, viswavebank,	0,   3,  0, 0,
X#O 134"wg_wave_bank3",	NULL,	-1,-1, %%, viswavebank,	0,   3,  0, 0,
X#O 192"wg_wave_bank4",	NULL,	-1,-1, %%, viswavebank,	0,   3,  0, 0,
X#O 19 "wg_pcm_number1",	NULL,	-1,-1, %%, vispcmnum,	0, 127,  0, 0,
X#O 77 "wg_pcm_number2",	NULL,	-1,-1, %%, vispcmnum,	0, 127,  0, 0,
X#O 135"wg_pcm_number3",	NULL,	-1,-1, %%, vispcmnum,	0, 127,  0, 0,
X#O 193"wg_pcm_number4",	NULL,	-1,-1, %%, vispcmnum,	0, 127,  0, 0,
X#O 20 "wg_pulse_width1",	NULL,	-1,-1, %%, visnum,	0, 100,  0, 0,
X#O 78 "wg_pulse_width2",	NULL,	-1,-1, %%, visnum,	0, 100,  0, 0,
X#O 136"wg_pulse_width3",	NULL,	-1,-1, %%, visnum,	0, 100,  0, 0,
X#O 194"wg_pulse_width4",	NULL,	-1,-1, %%, visnum,	0, 100,  0, 0,
X#O 21 "wg_pw_vel_sens1",	NULL,	-1,-1, %%, visvelsens,	0,  14,  0, 0,
X#O 79 "wg_pw_vel_sens2",	NULL,	-1,-1, %%, visvelsens,	0,  14,  0, 0,
X#O 137"wg_pw_vel_sens3",	NULL,	-1,-1, %%, visvelsens,	0,  14,  0, 0,
X#O 195"wg_pw_vel_sens4",	NULL,	-1,-1, %%, visvelsens,	0,  14,  0, 0,
X
X#O 22 "penv_depth1",		NULL,	-1,-1, @@, visnum,	0,  10,  0, 0,
X#O 80 "penv_depth2",		NULL,	-1,-1, @@, visnum,	0,  10,  0, 0,
X#O 138"penv_depth3",		NULL,	-1,-1, @@, visnum,	0,  10,  0, 0,
X#O 196"penv_depth4",		NULL,	-1,-1, @@, visnum,	0,  10,  0, 0,
X#O 23 "penv_vel_sens1",	NULL,	-1,-1, @@, visnum,	0,   3,  0, 0,
X#O 81 "penv_vel_sens2",	NULL,	-1,-1, @@, visnum,	0,   3,  0, 0,
X#O 139"penv_vel_sens3",	NULL,	-1,-1, @@, visnum,	0,   3,  0, 0,
X#O 197"penv_vel_sens4",	NULL,	-1,-1, @@, visnum,	0,   3,  0, 0,
X#O 24 "penv_time_kf1",	NULL,	-1,-1, @@, visnum,	0,   4,  0, 0,
X#O 82 "penv_time_kf2",	NULL,	-1,-1, @@, visnum,	0,   4,  0, 0,
X#O 140"penv_time_kf3",	NULL,	-1,-1, @@, visnum,	0,   4,  0, 0,
X#O 198"penv_time_kf4",	NULL,	-1,-1, @@, visnum,	0,   4,  0, 0,
X#O 25 "penv_attack1",		NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 83 "penv_attack2",		NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 141"penv_attack3",		NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 199"penv_attack4",		NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 26 "penv_decay1",		NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 84 "penv_decay2",		NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 142"penv_decay3",		NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 200"penv_decay4",		NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 27 "penv_recover1",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 85 "penv_recover2",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 143"penv_recover3",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 201"penv_recover4",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 28 "penv_release1",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 86 "penv_release2",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 144"penv_release3",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 202"penv_release4",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 29 "penv_start_lev1",	NULL,	-1,-1, @@, visenvlev,	0, 100,  0, 0,
X#O 87 "penv_start_lev2",	NULL,	-1,-1, @@, visenvlev,	0, 100,  0, 0,
X#O 145"penv_start_lev3",	NULL,	-1,-1, @@, visenvlev,	0, 100,  0, 0,
X#O 203"penv_start_lev4",	NULL,	-1,-1, @@, visenvlev,	0, 100,  0, 0,
X#O 30 "penv_attack_lev1",	NULL,	-1,-1, @@, visenvlev,	0, 100,  0, 0,
X#O 88 "penv_attack_lev2",	NULL,	-1,-1, @@, visenvlev,	0, 100,  0, 0,
X#O 146"penv_attack_lev3",	NULL,	-1,-1, @@, visenvlev,	0, 100,  0, 0,
X#O 204"penv_attack_lev4",	NULL,	-1,-1, @@, visenvlev,	0, 100,  0, 0,
X#O 31 "penv_decay_lev1",	NULL,	-1,-1, @@, visenvlev,	0, 100,  0, 0,
X#O 89 "penv_decay_lev2",	NULL,	-1,-1, @@, visenvlev,	0, 100,  0, 0,
X#O 147"penv_decay_lev3",	NULL,	-1,-1, @@, visenvlev,	0, 100,  0, 0,
X#O 205"penv_decay_lev4",	NULL,	-1,-1, @@, visenvlev,	0, 100,  0, 0,
X
X#O 33 "penv_end_lev1",	NULL,	-1,-1, @@, visenvlev,	0, 100,  0, 0,
X#O 91 "penv_end_lev2",	NULL,	-1,-1, @@, visenvlev,	0, 100,  0, 0,
X#O 149"penv_end_lev3",	NULL,	-1,-1, @@, visenvlev,	0, 100,  0, 0,
X#O 207"penv_end_lev4",	NULL,	-1,-1, @@, visenvlev,	0, 100,  0, 0,
X#O 34 "penv_lfo_rate1",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 92 "penv_lfo_rate2",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 150"penv_lfo_rate3",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 208"penv_lfo_rate4",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 35 "penv_lfo_depth1",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 93 "penv_lfo_depth2",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 151"penv_lfo_depth3",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 209"penv_lfo_depth4",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 36 "penv_mod_sens1",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 94 "penv_mod_sens2",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 152"penv_mod_sens3",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X#O 210"penv_mod_sens4",	NULL,	-1,-1, @@, visnum,	0, 100,  0, 0,
X
X"autopitch",	NULL,	-1,-1, @@, visnum, 	0, 127, 60, 0,
X"autovol",	NULL,	-1,-1, @@, visnum, 	0, 127, 63, 0,
X"autodur",	NULL,	-1,-1, @@, visnum, 	1,  20,  5, 0,
X"autochan",	NULL,	-1,-1, @@, visnum, 	1,  16,  1, 0,
X
XNULL,		NULL,	-1,-1, -1, -1, visnum, 	0,   0, 0, 0
X};
X
X
X/*
X * d10wfgdin
X *
X * Take library bank 'data' and stuff values in the P array, by using
X * the setval function.
X */
X
Xd10wfgdin(data)
Xchar *data;
X{
X	/* The first RESERVESIZE bytes are reserved (arbitrarily) for the voice name */
X#SETVAL
X}
X
X/*
X * d10wfgdout
X *
X * Take (possibly changed) parameters values out of the P array and
X * put them back into the library bank 'data'.
X */
X
Xd10wfgdout(data)
Xchar *data;
X{
X#GETVAL
X}
X
X/* end */
END_OF_FILE
if test 8416 -ne `wc -c <'d10wfg.menu'`; then
    echo shar: \"'d10wfg.menu'\" unpacked with wrong size!
fi
# end of 'd10wfg.menu'
fi
echo shar: End of shell archive.
exit 0


