v06i111: glib part 10 of 15

Brandon S. Allbery - comp.sources.misc allbery at uunet.UU.NET
Mon May 15 13:41:10 AEST 1989


Posting-number: Volume 6, Issue 111
Submitted-by: lee at uhccux.uhcc.Hawaii.Edu (Greg Lee )
Archive-name: glib/part10

#! /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 archive 10 (of 15)."
# Contents:  dx7s.mnu yama_com.c
# Wrapped by lee at uhccux on Sun May  7 00:40:17 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'dx7s.mnu' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dx7s.mnu'\"
else
echo shar: Extracting \"'dx7s.mnu'\" \(21591 characters\)
sed "s/^X//" >'dx7s.mnu' <<'END_OF_FILE'
X/* $Id: dx7s.mnu,v 1.6 89/05/06 17:13:23 lee Exp $
X * GLIB - a Generic LIBrarian and editor for synths
X *
X * DX-7s routines
X *
X * Scott Snyder - ssnyder at citromeo.bitnet, ssnyder at romeo.caltech.edu
X * $Log:	dx7s.mnu,v $
X * Revision 1.6  89/05/06  17:13:23  lee
X * rel. to comp.sources.misc
X * 
X */
X
X#define ARYLEN(a) (sizeof((a))/sizeof((a)[0]))
X
X#define BITS(x, start, len) (((x) >> (start)) & ((1<<(len))-1))
X
X#define OVERLAY1
X
X#define VCED_SIZE 155
X#define ADVCED_SIZE 49
X
X#define VMEM_SIZE 128
X#define ADVMEM_SIZE 35
X#define NVOICES 32
X
X#include "glib.h"
X#include <ctype.h>
X
Xchar *visnum(), *visonoff(), *vism3num(), *viswave(), *vismono();
Xchar *visfreq(), *visdx1a(), *visr2num();
X
Xchar *visxq(), *visxx(), *vism7num(), *visx7note(), *visx7crv();
Xchar *visx7a(), *visx7wave(), *visx7brkpt();
X
Xchar *visxq1(), *visxq2(), *visxq3();
Xchar *visxq4(), *visxq5(), *visxq6();
Xchar *visxx1(), *visxx2(), *visxx3();
Xchar *visxx4(), *visxx5(), *visxx6();
X
Xchar *vissport(),  *visspbmode(), *visspegrng(), *visssngl();
Xchar *vissmono(),  *vissedmde(), *vissmpm(),  *vissmam();
Xchar *vissmeg(), *vissm4(),   *visssclm(),   *visx7crv();
X
Xchar *vissf1(), *vissf2(), *vissf3();
Xchar *vissf4(), *vissf5(), *vissf6();
X
X#define RESERVESIZE VMEM_SIZE
X
X/* This array contains arbitrary screen labels */
Xstruct labelinfo Ldx7S[] = {
X#MENU
X                      N: set name; q: quit; K: incr; J: decr; >: max; <: min  k
X                  space: play autonote Pitch  %   Vol  %   Dur  %   Chan  %  h l
X                                                                              j
X    Atk  Sust1 Sust2  Rls          Scal Out De  Rat  Sens  Brk  Depth  Curve
XOP Rt Lv Rt Lv Rt Lv Rt Lv  Freq   Mode Lvl tun Scl Key AM Pt   L  R   L    R
X-- -- -- -- -- -- -- -- -- ------- ---- --- --- --- --- -- ---- -- -- ---- ----
X 1 %  %  %  %  %  %  %  %  %    %  %     %   %   %   %   % %    %  %  %    %
X 2 %  %  %  %  %  %  %  %  %    %  %     %   %   %   %   % %    %  %  %    %
X 3 %  %  %  %  %  %  %  %  %    %  %     %   %   %   %   % %    %  %  %    %
X 4 %  %  %  %  %  %  %  %  %    %  %     %   %   %   %   % %    %  %  %    %
X 5 %  %  %  %  %  %  %  %  %    %  %     %   %   %   %   % %    %  %  %    %
X 6 %  %  %  %  %  %  %  %  %    %  %     %   %   %   %   % %    %  %  %    %
XPE %  %  %  %  %  %  %  %
X                                      Osc. Sync     %      Rnd Pitch      @
XAlgorithm   %  LFO trigger   %        Feedback      %      Port. mode     @
X============== LFO Speed     %        Middle C      %      Port. step     @
X               LFO Delay     %        PEG Range     %      Port. time     @
X               LFO AM Depth  %        PEG by vel    %
X               LFO PM Depth  %        PEG Rate Scl  %                     @
X               LFO Wave      %        PB Range      %      PM range       @
X               LFO Sync      %        PB Step       %      AM range       @
X               LFO PM Sense  %        PB Mode       %      EG bias        @
X               Unison detune %        Poly/Mono     %                     @
X               FC1 is CS1    %        Unison mode   %
X#END
X-1,-1,NULL
X};
X
X/* This array defines all the editable parameters. */
Xstruct paraminfo Pdx7S[] = {
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
X"op1atkrt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op1atklv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op1sust1rt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op1sust1lv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op1sust2rt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op1sust2lv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op1rlsrt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op1rlslv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op1freq",	NULL, -1, -1,   %%, visxq1,  0, 4067, 0, 0,
X"op1fx",	NULL, -1, -1,   %%, vissf1, 0,    1, 0, 0,
X#O op1scalmode	ssclm	%%	1	0	0x20	5
X"op1outlevel",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op1detune",	NULL, -1, -1,   %%, vism7num,   0,   14, 0, 0,
X"op1ratscl",	NULL, -1, -1,   %%, visnum,     0,    7, 0, 0,
X"op1tchsens",	NULL, -1, -1,   %%, visnum,     0,    7, 0, 0,
X#O op1amsens	num		%%	7	3	0x38	3
X"op1brkpt",	NULL, -1, -1,   %%, visx7brkpt,0,   99, 0, 0,
X"op1ldepth",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op1rdepth",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op1lcurve",	NULL, -1, -1,   %%, visx7crv,  0,    3, 0, 0,
X"op1rcurve",	NULL, -1, -1,   %%, visx7crv,  0,    3, 0, 0,
X"op1modsens",	NULL, -1, -1,-1,-1, visnum,     0,    3, 0, 0,
X
X"op2atkrt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op2atklv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op2sust1rt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op2sust1lv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op2sust2rt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op2sust2lv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op2rlsrt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op2rlslv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op2freq",	NULL, -1, -1,   %%, visxq2,  0, 4067, 0, 0,
X"op2fx",	NULL, -1, -1,   %%, vissf2, 0,    1, 0, 0,
X#O op2scalmode	ssclm	%%	1	0	0x10	4
X"op2outlevel",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op2detune",	NULL, -1, -1,   %%, vism7num,   0,   14, 0, 0,
X"op2ratscl",	NULL, -1, -1,   %%, visnum,     0,    7, 0, 0,
X"op2tchsens",	NULL, -1, -1,   %%, visnum,     0,    7, 0, 0,
X#O op2amsens	num		%%	7	3	0x07
X"op2brkpt",	NULL, -1, -1,   %%, visx7brkpt,0,   99, 0, 0,
X"op2ldepth",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op2rdepth",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op2lcurve",	NULL, -1, -1,   %%, visx7crv,  0,    3, 0, 0,
X"op2rcurve",	NULL, -1, -1,   %%, visx7crv,  0,    3, 0, 0,
X"op2modsens",	NULL, -1, -1,-1,-1, visnum,     0,    3, 0, 0,
X
X"op3atkrt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op3atklv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op3sust1rt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op3sust1lv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op3sust2rt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op3sust2lv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op3rlsrt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op3rlslv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op3freq",	NULL, -1, -1,   %%, visxq3,  0, 4067, 0, 0,
X"op3fx",	NULL, -1, -1,   %%, vissf3, 0,    1, 0, 0,
X#O op3scalmode	ssclm	%%	1	0	0x08	3
X"op3outlevel",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op3detune",	NULL, -1, -1,   %%, vism7num,   0,   14, 0, 0,
X"op3ratscl",	NULL, -1, -1,   %%, visnum,     0,    7, 0, 0,
X"op3tchsens",	NULL, -1, -1,   %%, visnum,     0,    7, 0, 0,
X#O op3amsens	num		%%	7	2	0x38	3
X"op3brkpt",	NULL, -1, -1,   %%, visx7brkpt,0,   99, 0, 0,
X"op3ldepth",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op3rdepth",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op3lcurve",	NULL, -1, -1,   %%, visx7crv,  0,    3, 0, 0,
X"op3rcurve",	NULL, -1, -1,   %%, visx7crv,  0,    3, 0, 0,
X"op3modsens",	NULL, -1, -1,-1,-1, visnum,     0,    3, 0, 0,
X
X"op4atkrt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op4atklv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op4sust1rt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op4sust1lv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op4sust2rt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op4sust2lv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op4rlsrt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op4rlslv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op4freq",	NULL, -1, -1,   %%, visxq4,  0, 4067, 0, 0,
X"op4fx",	NULL, -1, -1,   %%, vissf4, 0,    1, 0, 0,
X#O op4scalmode	ssclm	%%	1	0	0x04	2
X"op4outlevel",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op4detune",	NULL, -1, -1,   %%, vism7num,   0,   14, 0, 0,
X"op4ratscl",	NULL, -1, -1,   %%, visnum,     0,    7, 0, 0,
X"op4tchsens",	NULL, -1, -1,   %%, visnum,     0,    7, 0, 0,
X#O op4amsens	num		%%	7	2	0x07
X"op4brkpt",	NULL, -1, -1,   %%, visx7brkpt,0,   99, 0, 0,
X"op4ldepth",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op4rdepth",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op4lcurve",	NULL, -1, -1,   %%, visx7crv,  0,    3, 0, 0,
X"op4rcurve",	NULL, -1, -1,   %%, visx7crv,  0,    3, 0, 0,
X"op4modsens",	NULL, -1, -1,-1,-1, visnum,     0,    3, 0, 0,
X
X"op5atkrt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op5atklv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op5sust1rt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op5sust1lv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op5sust2rt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op5sust2lv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op5rlsrt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op5rlslv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op5freq",	NULL, -1, -1,   %%, visxq5,  0, 4067, 0, 0,
X"op5fx",	NULL, -1, -1,   %%, vissf5, 0,    1, 0, 0,
X#O op5scalmode	ssclm	%%	1	0	0x02	1
X"op5outlevel",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op5detune",	NULL, -1, -1,   %%, vism7num,   0,   14, 0, 0,
X"op5ratscl",	NULL, -1, -1,   %%, visnum,     0,    7, 0, 0,
X"op5tchsens",	NULL, -1, -1,   %%, visnum,     0,    7, 0, 0,
X#O op5amsens	num		%%	7	1	0x38	3
X"op5brkpt",	NULL, -1, -1,   %%, visx7brkpt,0,   99, 0, 0,
X"op5ldepth",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op5rdepth",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op5lcurve",	NULL, -1, -1,   %%, visx7crv,  0,    3, 0, 0,
X"op5rcurve",	NULL, -1, -1,   %%, visx7crv,  0,    3, 0, 0,
X"op5modsens",	NULL, -1, -1,-1,-1, visnum,     0,    3, 0, 0,
X
X"op6atkrt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op6atklv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op6sust1rt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op6sust1lv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op6sust2rt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op6sust2lv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op6rlsrt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op6rlslv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op6freq",	NULL, -1, -1,   %%, visxq6,  0, 4067, 0, 0,
X"op6fx",	NULL, -1, -1,   %%, vissf6, 0,    1, 0, 0,
X#O op6scalmode	ssclm	%%	1	0	0x01
X"op6outlevel",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op6detune",	NULL, -1, -1,   %%, vism7num,   0,   14, 0, 0,
X"op6ratscl",	NULL, -1, -1,   %%, visnum,     0,    7, 0, 0,
X"op6tchsens",	NULL, -1, -1,   %%, visnum,     0,    7, 0, 0,
X#O op6amsens	num		%%	7	1	0x07
X"op6brkpt",	NULL, -1, -1,   %%, visx7brkpt,0,   99, 0, 0,
X"op6ldepth",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op6rdepth",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"op6lcurve",	NULL, -1, -1,   %%, visx7crv,  0,    3, 0, 0,
X"op6rcurve",	NULL, -1, -1,   %%, visx7crv,  0,    3, 0, 0,
X"op6modsens",	NULL, -1, -1,-1,-1, visnum,     0,    3, 0, 0,
X
X"pegatkrt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"pegatklv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"pegsust1rt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"pegsust1lv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"pegsust2rt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"pegsust2lv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"pegrlsrt",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"pegrlslv",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X
X"oscsync",	NULL, -1, -1,   %%, visonoff,   0,    1, 0, 0,
X"algorithm",	NULL, -1, -1,   %%, visx7a,    0,   31, 0, 0,
X#O lfotrig	ssngl	%%	1	4	0x04	2
X"feedback",	NULL, -1, -1,   %%, visnum,     0,    7, 0, 0,
X"lfospeed",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X"transpose",	NULL, -1, -1,   %%, visx7note, 0,   48, 0, 0,
X"lfodelay",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X#O pegrange	spegrng	%%	3	4	0x03
X"lfoamdepth",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X#O pegvel	onoff		%%	1	4	0x08	3
X"lfopmdepth",	NULL, -1, -1,   %%, visnum,     0,   99, 0, 0,
X#O pegratscl	num		%%	7	24	0x07
X"lfowave",	NULL, -1, -1,   %%, visx7wave, 0,    5, 0, 0,
X#O pbrange	num		%%	12	5	0x3C	2
X"lfosync",	NULL, -1, -1,   %%, visonoff,   0,    1, 0, 0,
X#O pbstep	num		%%	12	6	0x0F
X"lfopmsens",	NULL, -1, -1,   %%, visnum,     0,    7, 0, 0,
X#O pbmode	spbmode	%%	3	6	0x30	4
X#O unidetune	num		%%	7	34	0x07
X#O polymono	smono	%%	1	5	0x01
X#O fc1_cs1	onoff		%%	1	34	0x08	3
X#O unison	onoff		%%	1	5	0x02	1
X
X#O rndpitch	num		@@	7	4	0x70	4
X#O portmode	sport	@@	1	7	0x01
X#O portstep	num		@@	12	7	0x1E	1
X#O porttime	num		@@	99	8
X
X/*
X * note: for proper operation of this hack, the 'edit mode' parm must be
X *  displayed before any of the dummy parms when the screen is first being
X *  drawn. making it alphabetically less will accomplish this.
X */
X
X"_aeditmode",	NULL, -1, -1,   @@, vissedmde, 0,  5, 0, 0,
X"_dummy_pm",	NULL, -1, -1,   @@, vissmpm,  0, 99, 0, 0,
X"_dummy_am",	NULL, -1, -1,   @@, vissmam,  0, 99, 0, 0,
X"_dummy_eg",	NULL, -1, -1,   @@, vissmeg,  0, 99, 0, 0,
X"_dummy4",	NULL, -1, -1,   @@, vissm4,   0, 99, 0, 1,
X
X#O mw_pm	num		--	99	9
X#O mw_am	num		--	99	10
X#O mw_eg	num		--	99	11
X#O mw_vol	num		--	99	-1
X
X#O fc1_pm	num		--	99	12
X#O fc1_am	num		--	99	13
X#O fc1_eg	num		--	99	14
X#O fc1_vol	num		--	99	15
X
X#O fc2_pm	num		--	99	26
X#O fc2_am	num		--	99	27
X#O fc2_eg	num		--	99	28
X#O fc2_vol	num		--	99	29
X
X#O midi_pm	num		--	99	30
X#O midi_am	num		--	99	31
X#O midi_eg	num		--	99	32
X#O midi_vol	num		--	99	33
X
X#O bc_pm	num		--	99	16
X#O bc_am	num		--	99	17
X#O bc_eg	num		--	99	18
X#O bc_pitchb	num		--	100	19
X
X#O at_pm	num		--	99	20
X#O at_am	num		--	99	21
X#O at_eg	num		--	99	22
X#O at_pitchb	num		--	100	23
X
XNULL,	NULL, -1, -1, -1, -1, visnum, 0, 0, 0, 0
X};
X
Xchar *vissmono(v)
Xint v;
X{
X  showparam(parmindex("portmode"), 0);
X  return vismono(v);
X}
X
Xchar *visssngl(v)
Xint v;
X{
X  if (v == 0)
X    return "Single";
X  else
X    return "Multi";
X}
X
Xchar *visspegrng(v)
Xint v;
X{
X  switch (v) {
X    case 0: return "8oct";
X    case 1: return "2oct";
X    case 2: return "1oct";
X    case 3: return "1/2oct";
X    default: return "???";
X  }
X}
X
Xchar *visspbmode(v)
Xint v;
X{
X  switch (v) {
X    case 0: return "Norm";
X    case 1: return "Low";
X    case 2: return "High";
X    case 3: return "Key On";
X    default: return "???";
X  }
X}
X
Xchar *vissport(v)
Xint v;
X{
X  if (getval("polymono") == 0)
X    if (v == 0)
X      return "Retain";
X    else
X      return "Follow";
X  else
X    if (v == 0)
X      return "Fingrd";
X    else
X      return "Fulltm";
X}
X
Xchar *edmdes[] = {
X  "Modulation Wheel",
X  "Aftertouch",
X  "Breath Control",
X  "Foot Control 1",
X  "Foot Control 2",
X  "MIDI Control",
X};
X
Xchar *edmde_prefixes[] = {"mw", "at", "bc", "fc1", "fc2", "midi",};
X
Xchar *mk_mode_parm(v, suffix)
Xunsigned v;
Xchar *suffix;
X{
X  static char buf[20];
X
X  if (v < ARYLEN(edmde_prefixes)) {
X    (void)sprintf(buf, "%s_%s", edmde_prefixes[v], suffix);
X    return buf;
X  }
X  else return "???";
X}
X
Xchar *vissedmde(v, eras)
Xunsigned v, eras;
X{
X  int j;
X  static char buf[30];
X
X  if (eras) {
X    showparam(parmindex("_dummy_pm"), 1);
X    showparam(parmindex("_dummy_am"), 1);
X    showparam(parmindex("_dummy_eg"), 1);
X    showparam(parmindex("_dummy4"), 1);
X  }
X  else {
X    setval("_dummy_pm", getval(mk_mode_parm(v, "pm")));
X    setval("_dummy_am", getval(mk_mode_parm(v, "am")));
X    setval("_dummy_eg", getval(mk_mode_parm(v, "eg")));
X
X    showparam(parmindex("_dummy_pm"), 0);
X    showparam(parmindex("_dummy_am"), 0);
X    showparam(parmindex("_dummy_eg"), 0);
X
X    j = parmindex("_dummy4");
X    if (v == 0)	/* MW */
X      disableparm(j);
X    else {
X      enableparm(j);
X      if (v == 1 || v == 2) {  /* BC, AT */
X        P[j].p_max = 100;
X        setval("_dummy4", getval(mk_mode_parm(v, "pitchb")));
X      }
X      else {
X        P[j].p_max = 99;
X        setval("_dummy4", getval(mk_mode_parm(v, "vol")));
X      }
X      showparam(j, 0);
X    }
X  }
X
X  (void)sprintf(buf, "~15l%s", v < ARYLEN(edmdes) ? edmdes[v] : "???");
X  return buf;
X}
X
Xchar *vissmpm(v)
Xint v;
X{
X  setval(mk_mode_parm((unsigned)getval("_aeditmode"), "pm"), v);
X  return visnum(v);
X}
X
Xchar *vissmam(v)
Xint v;
X{
X  setval(mk_mode_parm((unsigned)getval("_aeditmode"), "am"), v);
X  return visnum(v);
X}
X
Xchar *vissmeg(v)
Xint v;
X{
X  setval(mk_mode_parm((unsigned)getval("_aeditmode"), "eg"), v);
X  return visnum(v);
X}
X
Xchar *vissm4(v)
Xint v;
X{
X  int mode = getval("_aeditmode");
X  static char buf[40];
X
X  if (mode == 1 || mode == 2) { /* BC, AT */
X    setval(mk_mode_parm((unsigned)mode, "pitchb"), v);
X    (void)sprintf(buf, "~15lPitch Bias~5 %s", visnum(v-50));
X    return buf;
X  }
X  else {
X    setval(mk_mode_parm((unsigned)mode, "vol"), v);
X    (void)sprintf(buf, "~15lVolume Range~3 %s", visnum(v));
X    return buf;
X  }
X}
X
Xchar *visssclm(v)
Xint v;
X{
X  if (v == 0)
X    return "Norm";
X  else
X    return "Frac";
X}
X
Xchar *vissf1(v) { return visxx(v, 1, 1); }
Xchar *vissf2(v) { return visxx(v, 2, 1); }
Xchar *vissf3(v) { return visxx(v, 3, 1); }
Xchar *vissf4(v) { return visxx(v, 4, 1); }
Xchar *vissf5(v) { return visxx(v, 5, 1); }
Xchar *vissf6(v) { return visxx(v, 6, 1); }
X
Xdx7Sdin(data)
Xchar *data;
X{
X  int op;
X
X#SETVAL
X
X  dx7din(data);
X
X  for (op=1; op <= 6; op++)
X    setopval(op, "modsens", 0);
X}
X
Xdx7Sdout(data)
Xchar *data;
X{
X#GETVAL
X  dx7dout(data);
X}
X
Xdx7Sadvmemtoadvced(in, out)
Xchar *in, *out;
X{
X  int op;
X
X  for (op=1; op <= 6; op++)
X    out[6-op] = BITS(in[0], (6-op), 1);		/* scaling mode */
X  out[ 6] = BITS(in[1], 0, 3);			/* op6 am sens */
X  out[ 7] = BITS(in[1], 3, 3);			/* op5 am sens */
X  out[ 8] = BITS(in[2], 0, 3);			/* op4 am sens */
X  out[ 9] = BITS(in[2], 3, 3);			/* op3 am sens */
X  out[10] = BITS(in[3], 0, 3);			/* op2 am sens */
X  out[11] = BITS(in[3], 3, 3);			/* op1 am sens */
X
X  out[12] = BITS(in[4], 0, 2);			/* pegrange		*/
X  out[13] = BITS(in[4], 2, 1);			/* lfotrig		*/
X  out[14] = BITS(in[4], 3, 1);			/* pegvel		*/
X  out[15] = BITS(in[5], 0, 2);			/* polymono/unison	*/
X  out[16] = BITS(in[5], 2, 4);			/* pbrange		*/
X  out[17] = BITS(in[6], 0, 4);			/* pbstep		*/
X  out[18] = BITS(in[6], 4, 2);			/* pbmode		*/
X  out[19] = BITS(in[4], 4, 3);			/* rndpitch		*/
X  out[20] = BITS(in[7], 0, 1);			/* portmode		*/
X  out[21] = BITS(in[7], 1, 4);			/* portstep		*/
X  out[22] = in[8];				/* porttime		*/
X
X  out[23] = in[9];				/* mw_pm		*/
X  out[24] = in[10];				/* mw_am		*/
X  out[25] = in[11];				/* mw_eg		*/
X
X  out[26] = in[12];				/* fc1_pm		*/
X  out[27] = in[13];				/* fc1_am		*/
X  out[28] = in[14];				/* fc1_eg		*/
X  out[29] = in[15];				/* fc1_vol		*/
X
X  out[30] = in[16];				/* bc_pm		*/
X  out[31] = in[17];				/* bc_am		*/
X  out[32] = in[18];				/* bc_eg		*/
X  out[33] = in[19];				/* bc_pitchb		*/
X
X  out[34] = in[20];				/* at_pm		*/
X  out[35] = in[21];				/* at_am		*/
X  out[36] = in[22];				/* at_eg		*/
X  out[37] = in[23];				/* at_pitchb		*/
X
X  out[38] = BITS(in[24], 0, 3);			/* pegratscl		*/
X
X  out[39] = in[26];				/* fc2_pm		*/
X  out[40] = in[27];				/* fc2_am		*/
X  out[41] = in[28];				/* fc2_eg		*/
X  out[42] = in[29];				/* fc2_vol		*/
X
X  out[43] = in[30];				/* midi_pm		*/
X  out[44] = in[31];				/* midi_am		*/
X  out[45] = in[32];				/* midi_eg		*/
X  out[46] = in[33];				/* midi_vol		*/
X
X  out[47] = BITS(in[34], 0, 3);			/* unidetune		*/
X  out[48] = BITS(in[34], 3, 1);			/* fc1_cs1		*/
X}  
X
Xdx7Ssadvced(data)
Xchar *data;
X{
X  return dx7send_bulk(5, ADVCED_SIZE, data);
X}
X
Xdx7Ssedit(data)
Xchar *data;
X{
X  char edmem[ADVCED_SIZE];
X
X  dx7Sadvmemtoadvced(data+128, edmem);
X  return dx7sedit(data) || dx7Ssadvced(edmem);
X}
X
Xstatic int alloc_bufs(vmem, advmem)
Xchar **vmem, **advmem;
X{
X  if ((*vmem = (char *)malloc(NVOICES * VMEM_SIZE)) != NULL) {
X    if ((*advmem = (char *)malloc(NVOICES * ADVMEM_SIZE)) != NULL)
X      return 0;
X    free(*vmem);
X  }
X
X  Reason = "Couldn't allocate enough buffer space";
X  return 1;
X}
X
Xstatic split_data(data, vmem, advmem)
Xchar *data, *vmem, *advmem;
X{
X  int i;
X
X  for (i=0; i<NVOICES; i++) {
X    memcpy(vmem, data, VMEM_SIZE);
X    memcpy(advmem, data+VMEM_SIZE, ADVMEM_SIZE);
X    data += VMEM_SIZE + ADVMEM_SIZE;
X    vmem += VMEM_SIZE;
X    advmem += ADVMEM_SIZE;
X  }
X}
X
Xstatic combine_data(data, vmem, advmem)
Xchar *data, *vmem, *advmem;
X{
X  int i;
X
X  for (i=0; i<NVOICES; i++) {
X    memcpy(data, vmem, VMEM_SIZE);
X    memcpy(data+VMEM_SIZE, advmem, ADVMEM_SIZE);
X    data += VMEM_SIZE + ADVMEM_SIZE;
X    vmem += VMEM_SIZE;
X    advmem += ADVMEM_SIZE;
X  }
X}
X
Xdx7Ssbulk(data)
Xchar *data;
X{
X  char *vmem, *advmem;
X  int retstat;
X
X  if (alloc_bufs(&vmem, &advmem)) return 1;
X  split_data(data, vmem, advmem);
X
X  retstat = dx7sbulk(vmem) || dx7send_bulk(6, NVOICES * ADVMEM_SIZE, advmem);
X
X  free(vmem);
X  free(advmem);
X
X  return retstat;
X}
X
Xdx7Sgbulk(data)
Xchar *data;
X{
X  char *vmem, *advmem;
X  int retstat;
X
X  if (alloc_bufs(&vmem, &advmem)) return 1;
X
X  retstat = dx7gbulk(vmem) || dx7get_bulk(6, NVOICES * ADVMEM_SIZE, advmem);
X
X  if (!retstat) combine_data(data, vmem, advmem);
X
X  free(vmem);
X  free(advmem);
X
X  return retstat;
X}
X
Xstatic char deflt_advmem[] = {
X 0, 0, 0, 0, 3, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 
X 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
X
X/* read a DX7 file as a DX7S file */
X
Xdx7Sread_dx7(f, data)
XFILE *f;
Xchar *data;
X{
X  int v;
X
X  message("Reading DX7 bank");
X
X  for (v=0; v<NVOICES; v++) {
X    (void)fread(data, VMEM_SIZE, 1, f);
X    memcpy(data+VMEM_SIZE, deflt_advmem, ADVMEM_SIZE);
X    data += VMEM_SIZE + ADVMEM_SIZE;
X  }
X}
X
X/* read a DX7s file as a DX7 file */
X
Xdx7read_dx7S(f, data)
XFILE *f;
Xchar *data;
X{
X  int v;
X
X  message("Reading DX7s bank");
X
X#ifndef SEEK_CUR
X#define SEEK_CUR 1
X#endif
X  for (v=0; v<NVOICES; v++) {
X    (void)fread(data, VMEM_SIZE, 1, f);
X    fseek(f, (long)ADVMEM_SIZE, SEEK_CUR);
X    data += VMEM_SIZE;
X  }
X}
END_OF_FILE
if test 21591 -ne `wc -c <'dx7s.mnu'`; then
    echo shar: \"'dx7s.mnu'\" unpacked with wrong size!
fi
# end of 'dx7s.mnu'
fi
if test -f 'yama_com.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'yama_com.c'\"
else
echo shar: Extracting \"'yama_com.c'\" \(24461 characters\)
sed "s/^X//" >'yama_com.c' <<'END_OF_FILE'
X/* $Id: yama_com.c,v 1.6 89/05/06 17:13:47 lee Exp $
X * GLIB - a Generic LIBrarian and editor for synths
X *
X * Yamaha Common Routines
X * Tim Thompson
X * modifications: Greg Lee
X * $Log:	yama_com.c,v $
X * Revision 1.6  89/05/06  17:13:47  lee
X * rel. to comp.sources.misc
X * 
X */
X
X#define OVERLAY1
X
X#include "glib.h"
X#include <ctype.h>
X
X#define DX100VSIZE 128
X#define DX100NSIZE 17
X
Xchar *visnum(), *visonoff(), *vism3num(), *viswave(), *vismono();
Xchar *visfreq(), *visdx1a();
Xextern int Tx81;
X
Xint *txindex = NULL;
Xint txleng = 0;
X
X
Xextern int Dopmap[];
X
Xint Tx81 = 0;	/* 1 means we're talking to the TX81Z */
Xint Dopmap[] = { 3,1,2,0 };
X
Xint txfreq[] = {
X50, 56, 62, 69, 75, 81, 87, 93,
X     100, 106, 112, 118, 124, 131, 137, 143,
X71, 80, 88, 97, 106, 115, 123, 132,
X     141, 149, 158, 167, 176, 184, 193, 202,
X78, 88, 98, 107, 117, 127, 137, 147,
X     156, 166, 176, 186, 196, 205, 215, 225,
X87, 98, 108, 119, 130, 141, 151, 162,
X     173, 183, 194, 205, 216, 226, 237, 248,
X100, 106, 112, 119, 125, 131, 137, 143,
X     149, 156, 162, 168, 174, 180, 187, 193,
X141, 150, 159, 167, 176, 185, 194, 203,
X     211, 220, 229, 238, 247, 255, 264, 273,
X157, 167, 177, 186, 196, 206, 216, 226,
X     235, 245, 255, 265, 275, 284, 294, 304,
X173, 184, 195, 205, 216, 227, 238, 249,
X     259, 270, 281, 292, 303, 313, 324, 335,
X200, 206, 212, 218, 225, 231, 237, 243,
X     249, 256, 262, 268, 274, 280, 287, 293,
X282, 291, 300, 308, 317, 326, 335, 344,
X     352, 361, 370, 379, 388, 396, 405, 414,
X300, 306, 312, 318, 325, 331, 337, 343,
X     349, 356, 362, 368, 374, 380, 387, 393,
X314, 324, 334, 343, 353, 363, 373, 383,
X     392, 402, 412, 422, 432, 441, 451, 461,
X346, 357, 368, 378, 389, 400, 411, 422,
X     432, 443, 454, 465, 476, 486, 497, 508,
X400, 406, 412, 418, 425, 431, 437, 443,
X     449, 456, 462, 468, 474, 480, 487, 493,
X424, 433, 441, 450, 459, 468, 476, 485,
X     494, 503, 511, 520, 529, 537, 546, 555,
X471, 481, 491, 500, 510, 520, 530, 539,
X     549, 559, 569, 579, 588, 598, 608, 618,
X500, 506, 512, 519, 525, 531, 537, 543,
X     550, 556, 562, 568, 574, 581, 587, 593,
X519, 530, 540, 551, 562, 573, 584, 594,
X     605, 616, 627, 638, 648, 659, 670, 681,
X565, 574, 582, 591, 600, 609, 617, 626,
X     635, 644, 652, 661, 670, 678, 687, 696,
X600, 606, 612, 619, 625, 631, 637, 643,
X     650, 656, 662, 668, 674, 681, 687, 693,
X628, 638, 647, 657, 667, 677, 687, 696,
X     706, 716, 726, 736, 745, 755, 765, 775,
X692, 703, 713, 724, 735, 746, 757, 767,
X     778, 789, 800, 811, 821, 832, 843, 854,
X700, 706, 712, 719, 725, 731, 737, 743,
X     750, 756, 762, 768, 774, 781, 787, 793,
X707, 716, 724, 733, 742, 750, 759, 768,
X     776, 785, 794, 802, 811, 820, 828, 837,
X785, 795, 804, 814, 824, 834, 844, 853,
X     863, 873, 883, 893, 902, 912, 922, 932,
X800, 806, 812, 819, 825, 831, 837, 843,
X     850, 856, 862, 868, 874, 881, 887, 893,
X848, 857, 865, 874, 883, 891, 900, 909,
X     917, 926, 935, 943, 952, 961, 969, 978,
X865, 876, 886, 897, 908, 919, 930, 940,
X     951, 962, 973, 984, 994, 1005, 1016, 1027,
X900, 906, 912, 919, 925, 931, 937, 943,
X     950, 956, 962, 968, 974, 981, 987, 993,
X942, 952, 961, 971, 981, 991, 1001, 1010,
X     1020, 1030, 1040, 1050, 1059, 1069, 1079, 1089,
X989, 998, 1006, 1015, 1024, 1032, 1041, 1050,
X     1058, 1067, 1076, 1084, 1093, 1102, 1110, 1119,
X1000, 1006, 1012, 1019, 1025, 1031, 1037, 1043,
X     1050, 1056, 1062, 1068, 1074, 1081, 1087, 1093,
X1038, 1049, 1060, 1070, 1081, 1092, 1103, 1113,
X     1124, 1135, 1146, 1157, 1167, 1178, 1189, 1200,
X1099, 1109, 1119, 1128, 1138, 1148, 1158, 1167,
X     1177, 1187, 1197, 1207, 1216, 1226, 1236, 1246,
X1100, 1106, 1112, 1119, 1125, 1131, 1137, 1143,
X     1150, 1156, 1162, 1168, 1174, 1181, 1187, 1193,
X1130, 1139, 1147, 1156, 1165, 1173, 1182, 1191,
X     1199, 1208, 1217, 1225, 1234, 1243, 1251, 1260,
X1200, 1206, 1212, 1219, 1225, 1231, 1237, 1243,
X     1250, 1256, 1262, 1268, 1274, 1281, 1287, 1293,
X1211, 1222, 1233, 1243, 1254, 1265, 1276, 1286,
X     1297, 1308, 1319, 1330, 1340, 1351, 1362, 1373,
X1256, 1266, 1276, 1285, 1295, 1305, 1315, 1324,
X     1334, 1344, 1354, 1364, 1373, 1383, 1393, 1403,
X1272, 1281, 1289, 1298, 1306, 1315, 1323, 1332,
X     1341, 1349, 1358, 1366, 1375, 1384, 1392, 1401,
X1300, 1306, 1312, 1319, 1325, 1331, 1337, 1343,
X     1350, 1356, 1362, 1368, 1374, 1381, 1387, 1393,
X1384, 1395, 1406, 1416, 1427, 1438, 1449, 1459,
X     1470, 1481, 1492, 1503, 1513, 1524, 1535, 1546,
X1400, 1406, 1412, 1419, 1425, 1431, 1437, 1443,
X     1450, 1456, 1462, 1468, 1474, 1481, 1487, 1493,
X1410, 1419, 1428, 1436, 1445, 1454, 1463, 1471,
X     1480, 1489, 1498, 1507, 1515, 1524, 1533, 1542,
X1413, 1423, 1433, 1442, 1452, 1462, 1472, 1481,
X     1491, 1501, 1511, 1521, 1530, 1540, 1550, 1560,
X1500, 1506, 1512, 1519, 1525, 1531, 1537, 1543,
X     1550, 1556, 1562, 1568, 1574, 1581, 1587, 1593,
X1555, 1563, 1572, 1581, 1589, 1598, 1606, 1615,
X     1623, 1632, 1640, 1649, 1657, 1666, 1674, 1683,
X1557, 1568, 1579, 1589, 1600, 1611, 1622, 1632,
X     1643, 1654, 1665, 1676, 1686, 1697, 1708, 1719,
X1570, 1580, 1590, 1599, 1609, 1619, 1629, 1638,
X     1648, 1658, 1668, 1678, 1687, 1697, 1707, 1717,
X1696, 1704, 1713, 1722, 1730, 1739, 1747, 1756,
X     1764, 1773, 1781, 1790, 1798, 1807, 1815, 1824,
X1727, 1737, 1747, 1756, 1766, 1776, 1786, 1795,
X     1805, 1815, 1825, 1835, 1844, 1854, 1864, 1874,
X1730, 1741, 1752, 1762, 1773, 1784, 1795, 1805,
X     1816, 1827, 1838, 1849, 1859, 1870, 1881, 1892,
X1837, 1845, 1854, 1863, 1871, 1880, 1888, 1897,
X     1905, 1914, 1922, 1931, 1939, 1948, 1956, 1965,
X1884, 1894, 1904, 1913, 1923, 1933, 1943, 1952,
X     1962, 1972, 1982, 1992, 2001, 2011, 2021, 2031,
X1903, 1914, 1925, 1935, 1946, 1957, 1968, 1978,
X     1989, 2000, 2011, 2022, 2032, 2043, 2054, 2065,
X1978, 1986, 1995, 2004, 2012, 2021, 2029, 2038,
X     2046, 2055, 2063, 2072, 2080, 2089, 2097, 2106,
X2041, 2051, 2061, 2070, 2080, 2090, 2100, 2110,
X     2119, 2129, 2139, 2149, 2159, 2168, 2178, 2188,
X2076, 2087, 2098, 2108, 2119, 2130, 2141, 2152,
X     2162, 2173, 2184, 2195, 2206, 2216, 2227, 2238,
X2120, 2128, 2137, 2145, 2154, 2162, 2171, 2179,
X     2188, 2196, 2205, 2213, 2222, 2230, 2238, 2247,
X2198, 2208, 2218, 2227, 2237, 2247, 2257, 2267,
X     2276, 2286, 2296, 2306, 2316, 2325, 2335, 2345,
X2249, 2260, 2271, 2281, 2292, 2303, 2314, 2325,
X     2335, 2346, 2357, 2368, 2379, 2389, 2400, 2411,
X2355, 2365, 2375, 2384, 2394, 2404, 2414, 2424,
X     2433, 2443, 2453, 2463, 2473, 2482, 2492, 2502,
X2422, 2433, 2444, 2454, 2465, 2476, 2487, 2498,
X     2508, 2519, 2530, 2541, 2552, 2562, 2573, 2584,
X2595, 2606, 2617, 2627, 2638, 2649, 2660, 2671,
X     2681, 2692, 2703, 2714, 2725, 2735, 2746, 2757
X};
X
X/*
X * dxtxdin
X *
X * Take info from 'data' and stuff values in the P array, by using
X * the setval (and setopval) functions.  'data' is the Yamaha VMEM format.
X * This function works for both the dx100 and tx81z.
X */
X
Xdxtxdin(data)
Xchar *data;
X{
X	int dop, adop, n, crs, fin, v;
X
X	setdxtx();
X	if ( Tx81 )
X		txinit();
X	for ( n=1; n<=4; n++ ) {
X		dop = Dopmap[n-1]*10;
X		adop = Dopmap[n-1]*2;
X		setopval(n,"attack",data[0+dop]);
X		setopval(n,"decay1",data[1+dop]);
X		setopval(n,"level1",data[4+dop]);
X		setopval(n,"decay2",data[2+dop]);
X		setopval(n,"release",data[3+dop]);
X		setopval(n,"keyscale",data[5+dop]);
X		setopval(n,"ampmod",(data[6+dop]>>6)&01);
X		setopval(n,"egbias",(data[6+dop]>>3)&07);
X		setopval(n,"velocity",data[6+dop]&07);
X		setopval(n,"outlevel",data[7+dop]);
X
X		if ( Tx81 ) {
X			crs = data[8+dop];
X			fin = (data[74+adop]) & 017;
X			v = freqin(crs,fin);
X			setopval(n,"freq",v);
X		}
X		else
X			setopval(n,"freq",data[8+dop]);
X
X		setopval(n,"keyrate",data[9+dop]>>3);
X		setopval(n,"detune",data[9+dop]&07);
X
X		if ( Tx81 ) {
X			setopval(n,"egsft",(data[73+adop]>>4)&03);
X			setopval(n,"fix",(data[73+adop]>>3)&01);
X			setopval(n,"wave",(data[74+adop]>>4)&07);
X		}
X	}
X	setval("lfosync",(data[40]>>6)&01);
X	setval("feedback",(data[40]>>3)&07);
X	setval("algorithm",data[40]&07);
X	setval("lfospeed",data[41]);
X	setval("lfodelay",data[42]);
X	setval("pmoddepth",data[43]);
X	setval("amoddepth",data[44]);
X	setval("pmodsens",(data[45]>>4)&07);
X	setval("amodsens",(data[45]>>2)&03);
X	setval("lfowave",data[45]&03);
X	setval("transpose",data[46]);
X	setval("pitchbend",data[47]);
X	setval("portatime",data[49]);
X	setval("modprange",data[51]);
X	setval("modarange",data[52]);
X	setval("breathprange",data[53]);
X	setval("breatharange",data[54]);
X	setval("breathpbias",data[55]);
X	setval("breathegbias",data[56]);
X	setval("playmode",(data[48]>>3)&01);
X	setval("susfoot",(data[48]>>2)&01);
X	setval("portfoot",(data[48]>>1)&01);
X	setval("portmode",data[48]&01);
X	setval("autochan",Channel);
X	if ( Tx81 ) {
X		setval("reverbrate",data[81]&07);
X		setval("fcpitch",data[82]);
X		setval("fcamp",data[83]);
X	}
X}
X
X/*
X * dxtxdout
X *
X * Take (possibly changed) parameters values out of the P array and
X * put them back into 'data'.  'data' is in the Yamaha VMEM format.
X * This works for both the dx100 and tx81z.
X */
X
Xdxtxdout(data)
Xchar *data;
X{
X	int dop, n, crs, fin;
X
X	for ( n=1; n<=4; n++ ) {
X		dop = Dopmap[n-1]*10;
X		data[0+dop] = getopval(n,"attack");
X		data[1+dop] = getopval(n,"decay1");
X		data[4+dop] = getopval(n,"level1");
X		data[2+dop] = getopval(n,"decay2");
X		data[3+dop] = getopval(n,"release");
X		data[5+dop] = getopval(n,"keyscale");
X		data[6+dop] = getopval(n,"ampmod")<<6
X				| getopval(n,"egbias")<<3
X				| getopval(n,"velocity");
X		data[7+dop] = getopval(n,"outlevel");
X		data[9+dop] = getopval(n,"keyrate")<<3 | getopval(n,"detune");
X
X		if ( ! Tx81 ) {
X			data[8+dop] = getopval(n,"freq");
X		}
X		else {
X			freqout(getopval(n,"freq"),&crs,&fin);
X			data[8+dop] = crs;
X
X			dop = Dopmap[n-1]*2;
X			data[73+dop] = getopval(n,"egsft")<<4
X					| getopval(n,"fix")<<3
X					/* | getopval(n,"fixrg") */;
X			data[74+dop] = getopval(n,"wave")<<4 | fin;
X		}
X	}
X	data[40] = getval("lfosync")<<6
X		| getval("feedback")<<3
X		| getval("algorithm");
X	data[41] = getval("lfospeed");
X	data[42] = getval("lfodelay");
X	data[43] = getval("pmoddepth");
X	data[44] = getval("amoddepth");
X	data[45] = getval("pmodsens")<<4 | getval("amodsens")<<2
X		| getval("lfowave");
X	data[46] = getval("transpose");
X	data[47] = getval("pitchbend");
X	data[49] = getval("portatime");
X	data[51] = getval("modprange");
X	data[52] = getval("modarange");
X	data[53] = getval("breathprange");
X	data[54] = getval("breatharange");
X	data[55] = getval("breathpbias");
X	data[56] = getval("breathegbias");
X	data[48] = (unsigned) ( getval("playmode")<<3
X		| getval("susfoot")<<2
X		| getval("portfoot")<<1
X		| getval("portmode"));
X
X	if ( Tx81 ) {
X		data[81] = getval("reverbrate");
X		data[82] = getval("fcpitch");
X		data[83] = getval("fcamp");
X	}
X
X	Channel = getval("autochan");
X}
X
Xsetdxtx()
X{
X	if ( strcmp(Synthname,"DX-100")==0 )
X		Tx81 = 0;
X	else
X		Tx81 = 1;
X}
X
Xsetopval(n,str,v)
Xchar *str;
X{
X	char buff[32];
X	sprintf(buff,"op%d%s",n,str);
X	setval(buff,v);
X}
X
Xgetopval(n,str)
Xchar *str;
X{
X	char buff[32];
X	sprintf(buff,"op%d%s",n,str);
X	return(getval(buff));
X}
X
X/*
X * The routines below are used (in the P array) for printing the
X * values of various parameters (e.g. the vism3num routine prints
X * the value-3, which is appropriate for the 'detune' parameter.
X */
X
Xchar Numbuff[8];
X
Xchar *visnum();
X
Xchar *
Xvism3num(v)
X{
X	sprintf(Numbuff,"%d",v-3);
X	return(Numbuff);
X}
X
Xchar *visonoff();
X
Xchar *
Xvismono(v)
X{
X	if ( v==0 )
X		return("poly");
X	else
X		return("mono");
X}
X
X/*
X            4    2  4    2         4                             4
X            |    |  |    |         |               4             |
X        2---3    ---3    3  4   2  3   1  4     ___|___    1  2  3
X        |           |    |  |   |  |   |  |     |  |  |    |__|__|
X        1           1    1---   1---   2  3     1  2  3
X                                       |__|     |__|__|
X                                                             1  2  3  4
X                                                             |__|__|__|
X */
X
Xchar *Algostr[] = {
X	"1     ~d2---3~u~l|~u~l4~d~d~d~l~l~l~l~l|~l~d1",
X	"2     ~d---3~l~l~l~l~u|  |~l~l~l~l~u2  4~l~d~d~d|~l~d1",
X	"3     ~d3  4~l~l~l~l~u|~l~u2~l~d~d~d|  |~d~l~l~l~l1---",
X	"4     ~d2  3~l~u|~u~l4~l~d~d~d~l~l~l|  |~l~l~l~l~d1---",
X	"5     ~d~u1  4~d~l~l~l~l|  |~d~l~l~l~l2  3~d~l~l~l~l----",
X	"6     ~d|  |  |~u~l~l~l~l~l~l~l___|___~u~l~l~l~l4~l~d~d~d~l~l~l1  2  3~d~l~l~l~l~l~l~l|__|__|",
X	"7     ~d1  2  3~u~l|~u~l4~l~d~d~d~l~l~l~l~l~l|__|__|",
X	"8     ~d1  2  3  4~d~l~l~l~l~l~l~l~l~l~l|__|__|__|"
X};
X
Xchar *
Xvisdx1a(v)
X{
X	if ( v >= 0 && v <= 7 )
X		return(Algostr[v]);
X	else
X		return("????");
X}
X
Xchar *
Xviswave(v)
X{
X	switch(v){
X	case 0: return("saw up");
X	case 1: return("square");
X	case 2: return("triangle");
X	case 3: return("s/hold");
X	default: return("???");
X	}
X}
X
Xchar *Freqstr[] = {	/* values from 0 to 63 */
X	"0.50 ", "0.71 ", "0.78 ", "0.87 ", "1.00 ",
X	"1.41 ", "1.57 ", "1.73 ", "2.00 ", "2.82 ",
X	"3.00 ", "3.14 ", "3.46 ", "4.00 ", "4.24 ",
X	"4.71 ", "5.00 ", "5.19 ", "5.65 ", "6.00 ",
X	"6.28 ", "6.92 ", "7.00 ", "7.07 ", "7.85 ",
X	"8.00 ", "8.48 ", "8.65 ", "9.00 ", "9.42 ",
X	"9.89 ", "10.00", "10.38", "10.99", "11.00",
X	"11.30", "12.00", "12.11", "12.56", "12.72",
X	"13.00", "13.84", "14.00", "14.10", "14.13",
X	"15.00", "15.55", "15.57", "15.70", "16.96",
X	"17.27", "17.30", "18.37", "18.84", "19.03",
X	"19.78", "20.41", "20.76", "21.20", "21.98",
X	"22.49", "23.55", "24.22", "25.95"
X};
X
Xchar *
Xvisfreq(v)
X{
X	if ( v >=0 && v <= 63 )
X		return ( Freqstr[v] );
X	else
X		return("????");
X}
X
X/*
X * dx1sedit
X *
X * Send a single voice to the edit buffer of the DX.
X */
Xdx1sedit(data)
Xchar *data;
X{
X	setdxtx();
X	if ( Tx81 )
X		sendaced(data);
X	sendvced(data);
X}
X
Xsendvced(data)
Xchar *data;
X{
X	char vdata[DX100VSIZE];
X	int n, cksum, c;
X
X	clrdata(vdata,DX100VSIZE);
X	vmtovced(data,vdata);
X	sendmidi(0xf0);
X	sendmidi(0x43);
X	sendmidi(Channel-1);	/* channel # */
X	sendmidi(0x03);		/* format type */
X	sendmidi(0x00);		/* byte count */
X	sendmidi(0x5d);		/* byte count */
X	cksum = 0;
X	for ( n=0; n<93; n++ ) {
X		sendmidi(c = (int)(vdata[n]));
X		cksum += c;
X	}
X	sendmidi((-cksum) & 0x7f);
X	sendmidi(EOX);
X}
X
Xsendaced(data)
Xchar *data;
X{
X	char *p, vdata[DX100VSIZE];
X	int n, cksum, c;
X
X	clrdata(vdata,DX100VSIZE);
X	vmtoaced(data,vdata);
X	sendmidi(0xf0);
X	sendmidi(0x43);
X	sendmidi(Channel-1);	/* channel # */
X	sendmidi(0x7e);		/* format type */
X	sendmidi(0x00);		/* byte count */
X	sendmidi(0x21);		/* byte count */
X	p = "LM  8976AE";
X	cksum = 0;
X	while ( (c=(int)(*p++)) != '\0' ) {
X		sendmidi(c);
X		cksum += c;
X	}
X	for ( n=0; n<23; n++ ) {
X		sendmidi(c=(int)(vdata[n]));
X		cksum += c;
X	}
X	sendmidi((-cksum) & 0x7f);
X	sendmidi(EOX);
X}
X
X/*
X * vmtovced
X *
X * convert a vmem format voice to vced format.
X */
X
Xvmtovced(data,vdata)
Xchar *data;
Xchar *vdata;
X{
X	int vop, dop, n;
X
X	for ( n=0; n<4; n++ ) {
X		/* vop = Dopmap[n]*13; */
X		vop = Dopmap[n]*13;
X		dop = Dopmap[n]*10;
X		vdata[vop+0] = data[dop+0];	/* attack rate */
X		vdata[vop+1] = data[dop+1];	/* decay 1 rate */
X		vdata[vop+2] = data[dop+2];	/* decay 2 rate */
X		vdata[vop+3] = data[dop+3];	/* release rate */
X		vdata[vop+4] = data[dop+4];	/* decal 1 level */
X		vdata[vop+5] = data[dop+5];	/* keyboard scaling level */
X		vdata[vop+6] = (data[dop+9]>>3);/* keyboard scaling rate */
X		vdata[vop+7] = (data[dop+6]>>3)&7;	/* eg bias sens. */
X		vdata[vop+8] = (data[dop+6]>>6)&1;	/* amp. mod. enable */
X		vdata[vop+9] = (data[dop+6]&7);	/* key velocity */
X		vdata[vop+10] = data[dop+7];	/* output level */
X		vdata[vop+11] = data[dop+8];	/* osc. frequency */
X		vdata[vop+12] = (data[dop+9]&7);	/* detune */
X	}
X	vdata[52] = (data[40]&7);	/* algorithm */
X	vdata[53] = (data[40]>>3)&7;	/* feedback level */
X	vdata[54] = data[41];		/* lfo speed */
X	vdata[55] = data[42];		/* lfo delay */
X	vdata[56] = data[43];		/* pitch modulation depth */
X	vdata[57] = data[44];		/* amplitude modulation depth */
X	vdata[58] = (data[40]>>6)&1;	/* lfo sync */
X	vdata[59] = data[45]&3;		/* lfo wave */
X	vdata[60] = (data[45]>>4)&7;		/* pitch modulation sens. */
X	vdata[61] = (data[45]>>2)&3;		/* amp. modulation sens. */
X	vdata[62] = data[46];		/* transpose */
X	vdata[63] = (data[48]>>3)&1;	/* play mode (poly/mono) */
X	vdata[64] = data[47];		/* pitch bend range */
X	vdata[65] = (data[48]&1);	/* portamento mode */
X	vdata[66] = data[49];		/* portamento time */
X	vdata[67] = data[50];		/* foot volume range */
X	vdata[68] = (data[48]>>2)&1;	/* sustain foot switch */
X	vdata[69] = (data[48]>>1)&1;	/* portamento foot switch */
X	vdata[70] = (data[48]>>4)&1;	/* chorus switch */
X	vdata[71] = data[51];		/* mod. wheel pitch mod. range */
X	vdata[72] = data[52];		/* mod. wheel ampli. mod. range */
X	vdata[73] = data[53];		/* breath pitch mod. range */
X	vdata[74] = data[54];		/* breath ampli. mod. range */
X	vdata[75] = data[55];		/* breath control pitch bias range */
X	vdata[76] = data[56];		/* breath control EG bias range */
X	for ( n=77; n<93; n++ )		/* voice name AND pitch EG rates */
X		vdata[n] = data[n-20];
X}
X
X/*
X * vmtoaced
X *
X * Convert a vmem format voice to aced format (TX81Z).
X */
X
Xvmtoaced(data,adata)
Xchar *data;
Xchar *adata;
X{
X	int vop, aop, n;
X
X	for ( n=0; n<4; n++ ) {
X	    vop = 73 + Dopmap[n]*2;
X	    aop = Dopmap[n]*5;
X	    adata[0+aop] = (data[vop]>>3) & 01;    /* fixed freq (0,1) */
X	    adata[1+aop] = data[vop] & 07;	   /* fixed freq range (0-7) */
X	    adata[2+aop] = data[vop+1] & 017;	   /* freq range fine (0-15) */
X	    adata[3+aop] = (data[vop+1]>>4) & 07;  /* op. waveform (0-7) */
X	    adata[4+aop] = (data[vop]>>3) & 03;   /* EG shift (0-3) */
X	}
X	adata[20] = data[81] & 07;	/* reverb rate */
X	adata[21] = data[82];	/* Foot controller pitch */
X	adata[22] = data[83];	/* Foot controller amp. */
X}
X
X#ifdef OLD
X/*
X * Send a single parameter value.
X */
Xsendparam(param,val)
X{
X	sendmidi(0xf0);
X	sendmidi(0x43);
X	sendmidi(0x10);	/* Channel? */
X	sendmidi(0x12);
X	sendmidi(param);
X	sendmidi(val);
X	sendmidi(EOX);
X}
X
X/*
X * remotely press a key on the DX
X */
Xpresskey(key,val)
X{
X	sendmidi(0xf0);
X	sendmidi(0x43);
X	sendmidi(0x10);	/* Channel? */
X	sendmidi(0x08);
X	sendmidi(key);
X	sendmidi(val);
X	sendmidi(EOX);
X}
X
X/*
X * tovmem
X *
X * convert a vced format voice to vmem format.
X */
X
Xtovmem(vdata,data)
Xchar *vdata;	/* vced format data */
Xchar *data;	/* vmem format */
X{
X	int vop, dop, n;
X
X	for ( n=0; n<4; n++ ) {
X		vop = Dopmap[n]*13;
X		dop = Dopmap[n]*10;
X		data[dop+0] = vdata[vop+0];	/* attack rate */
X		data[dop+1] = vdata[vop+1];	/* decay 1 rate */
X		data[dop+2] = vdata[vop+2];	/* decay 2 rate */
X		data[dop+3] = vdata[vop+3];	/* release rate */
X		data[dop+4] = vdata[vop+4];	/* decal 1 level */
X		data[dop+5] = vdata[vop+5];	/* keyboard scaling level */
X				/* amp. mod. enab/eg bias sens/key velocity */
X		data[dop+6]=(vdata[vop+8]<<6) | (vdata[vop+7]<<3) | vdata[vop+9];
X		data[dop+7] = vdata[vop+10];	/* output level */
X		data[dop+8] = vdata[vop+11];	/* osc. frequency */
X				/* key scaling rate/detune */
X		data[dop+9] = (vdata[vop+6]<<3) | vdata[vop+12];
X	}
X		/* lfo sync/feedback level/algorithm */
X	data[40] = (vdata[58]<<6) | (vdata[53]<<3) | vdata[52];
X	data[41] = vdata[54];		/* lfo speed */
X	data[42] = vdata[55];		/* lfo delay */
X	data[43] = vdata[56];		/* pitch modulation depth */
X	data[44] = vdata[57];		/* amplitude modulation depth */
X		/* pitch mod. sens/amp. mod. sens/lfo wave */
X	data[45] = (vdata[60]<<4) | (vdata[61]<<2) | vdata[59];
X	data[46] = vdata[62];		/* transpose */
X
X		/* chorus/playmode/sustain/portamento-foot/portamento-mode */
X	data[48] = (vdata[70]<<4)|(vdata[63]<<3)|(vdata[68]<<2)|(vdata[69]<<1)
X		| vdata[65];
X
X	data[47] = vdata[64];		/* pitch bend range */
X	data[49] = vdata[66];		/* portamento time */
X	data[50] = vdata[67];		/* foot volume range */
X	data[51] = vdata[71];		/* mod. wheel pitch mod. range */
X	data[52] = vdata[72];		/* mod. wheel ampli. mod. range */
X	data[53] = vdata[73];		/* breath pitch mod. range */
X	data[54] = vdata[74];		/* breath ampli. mod. range */
X	data[55] = vdata[75];		/* breath control pitch bias range */
X	data[56] = vdata[76];		/* breath control EG bias range */
X	for ( n=77; n<93; n++ )		/* voice name AND pitch EG rates */
X		data[n-20] = vdata[n];
X}
X#endif
X
X/* dx1nof - return a pointer to the voice name buried in data */
Xchar *
Xdx1nof(data)
Xchar *data;
X{
X	static char currbuff[DX100NSIZE+1];
X	char *p;
X	int m;
X
X	p = currbuff;
X	for ( m=0; m<10; m++ )
X		*p++ = data[57+m];
X	*p = '\0';
X	return(currbuff);
X}
X
X/* dx1snof - set the voice name buried in data to name */
Xdx1snof(data,name)
Xchar *data;
Xchar *name;
X{
X	char *p;
X	int m;
X
X	for ( p=name,m=0; *p!='\0' && m<10; p++,m++ )
X		data[57+m] = *p;
X	for ( ; m<10; m++ )
X		data[57+m] = ' ';
X}
X
X/* dx1sbulk - send a bulk dump to the DX-100 */
Xdx1sbulk(data)
Xchar *data;
X{
X	int c, v, n, cksum;
X
X	sendmidi(0xf0);
X	sendmidi(0x43);
X	sendmidi(Channel-1);	/* Channel # */
X	sendmidi(0x04);
X	sendmidi(0x20);
X	sendmidi(0x00);
X	cksum = 0;
X	/* send 32 voices worth of data */
X	for ( v=0; v<32; v++ ) {
X		for ( n=0; n<DX100VSIZE; n++ ) {
X			/* The DX100 can only handle 24 voices (but needs */
X			/* to have 32 voices worth of data sent, anyway) */
X			if ( v >= 24 && ( ! Tx81 ) )
X				c = 0;
X			else
X				c = VOICEBYTE(data,v,n);
X			sendmidi(c & 0xff);
X			cksum += c;
X		}
X	}
X	sendmidi((-cksum) & 0x7f);
X	sendmidi(0xf7);
X	return(0);
X}
X
X/* dx1gbulk - Request and read a bulk dump from the DX-100 */
Xdx1gbulk(data)
Xchar *data;
X{
X	int c, n, v, b1, b2, cksum, ret = 1;
X	long begin, toolong;
X
X	setdxtx();
X	flushmidi();
X
X	sendmidi(0xf0);
X	sendmidi(0x43);
X	sendmidi(0x20 | (Channel-1) );	/* Channel # */
X	sendmidi(4);			/* 4 == 32 voice bulk dump */
X	sendmidi(EOX);			/* EOX */
X
X	begin = milliclock();
X	toolong = begin + 1000 * TIMEOUT;
X
X	if (synthinfileflag) getmidi(); /* the 0xf0 byte */
X
X	/* wait for the x43 byte starting the dump */
X	while ( milliclock() < toolong ) {
X		if ( STATMIDI && (c=(getmidi() & 0xff)) == 0x43 )
X			break;
X	}
X	if ( c != 0x43 ) {
X		Reason = "Timeout waiting for 0x43";
X		goto getout;
X	}
X	getmidi();	/* channel # */
X	getmidi();	/* format # */
X	getmidi();	/* byte count high byte */
X	getmidi();	/* byte count low byte */
X
X	cksum = 0;
X	/* 32 voices are dumped */
X	for ( v=0; v<32; v++ ) {
X		for ( n=0; n<DX100VSIZE; n++ ) {
X			/* twiddle your thumbs, but not forever */
X			while ( ! STATMIDI ) {
X				if ( milliclock() > toolong )
X					goto timeout;	/* the end of an era */
X			}
X			c = (getmidi() & 0xff);
X			/* Ignore non-data bytes ? */
X			if ( c & 0x80 )
X				continue;
X			/* compute checksum */
X			cksum += c;
X			/* Only 24 voices are used on the DX100 */
X			if ( v < 24 || Tx81 )
X				VOICEBYTE(data,v,n) = c;
X		}
X	}
Xtimeout:
X	if ( v < 32 ) {
X		Reason = "Timeout while reading!";
X		goto getout;
X	}
X	b1 = (getmidi() & 0xff);	/* Checksum */
X	b2 = (getmidi() & 0xff);	/* EOX */
X	cksum = (-cksum) & 0x7f;	/* convert to what we must match */
X	if ( b2 != EOX )
X		Reason = "EOX not received";
X	else if ( b1 != cksum ) {
X		static char ckbuff[80];
X		sprintf(ckbuff,"Checksum doesn't match (got %d expected %d)",b1,cksum);
X		/* Reason = "Checksum doesn't match"; */
X		Reason = ckbuff;
X	}
X	else {
X		Reason = "";
X		ret = 0;	/* all's well */
X	}
Xgetout:
X	return(ret);
X}
X
X#ifdef OLDSTUFF
Xdxchecksum(data)
Xchar *data;
X{
X	int v, n, s=0;
X
X	for ( v=0; v<DX100NVOICES; v++ ) {
X		for ( n=0; n<DX100VSIZE; n++ ) {
X			s += (int)(VOICEBYTE(data,v,n));
X			while ( s > 128 )
X				s -= 128;
X		}
X	}
X	return(128-s);
X}
X#endif
X
Xfreqin(crs,fin)
X{
X	int n, f;
X
X	txinit();
X	f = txfreq[crs*16+fin];
X	for ( n=0; n<txleng; n++ ) {
X		if ( txfreq[txindex[n]] == f )
X			return(n);
X	}
X	return(0);
X}
X
Xfreqout(v,acrs,afin)
Xint *acrs;
Xint *afin;
X{
X	int i;
X
X	i = txindex[v];
X	*acrs = i/16;
X	*afin = i%16;
X}
X
Xtxinit()
X{
X	int n, k;
X	char *parm;
X
X	if ( txindex != NULL )
X		return;
X	/* create an array of indexes into txfreq, giving a sorted */
X	/* list of unique frequencies. */
X	txindex = (int *) alloc(sizeof(int) * 64 * 16);
X	for ( n=0; n<64; n++ ) {
X		for ( k=0; k<16; k++ ) {
X			int freq = txfreq[n*16+k];
X			register int i, f;
X			register int *p, *endp;
X
X			/* insertion sort, starting from top of already */
X			/* sorted list, since the values we're inserting */
X			/* are almost sorted already. */
X			for ( i=txleng-1; i>=0; i-- ) {
X				if ( (f=txfreq[txindex[i]]) < freq )
X					break;
X				if ( f == freq )
X					goto dontadd;
X			}
X			i++;
X			/* shift everything up one */
X			p = &txindex[txleng];
X			endp = &txindex[i];
X			for ( ; p>endp; p-- )
X				*p = *(p-1);
X			txindex[i] = 16*n+k;
X			txleng++;
X		    dontadd: ;
X		}
X	}
X	/* set the maximum value for the frequency parameters */
X	parm = "op#freq";
X	for ( n=1; n<=4; n++ ) {
X		parm[2] = '0' + n;
X		if ( (k=parmindex(parm)) >= 0 )
X			P[k].p_max = txleng-1;
X	}
X}
END_OF_FILE
if test 24461 -ne `wc -c <'yama_com.c'`; then
    echo shar: \"'yama_com.c'\" unpacked with wrong size!
fi
# end of 'yama_com.c'
fi
echo shar: End of archive 10 \(of 15\).
cp /dev/null ark10isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 15 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0



More information about the Comp.sources.misc mailing list