home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume6
/
glib
/
part04
/
d10tim.mnu
< prev
next >
Wrap
Text File
|
1989-05-14
|
9KB
|
486 lines
/* $Id: d10tim.mnu,v 1.6 89/05/06 17:13:16 lee Exp $
* GLIB - a Generic LIBrarian and editor for synths
*
* D10 Timbre Librarian
*
* Code started 23 JAN 89 -- Michael R. Kesti mrk@gvgspd.GVG.TEK.COM
* modified by Greg Lee
* $Log: d10tim.mnu,v $
* Revision 1.6 89/05/06 17:13:16 lee
* rel. to comp.sources.misc
*
*/
#include "glib.h"
#include "vis.h"
#define D10TIMSIZE 8
#define TIMBASEADDR 0x050000
#define RESERVESIZE 20
char *visnum(), *visonoff();
/* This array contains arbitrary screen labels */
struct labelinfo Ldtim[] = {
#MENU
Tone Select %%
Key Shift %
Fine Tune %
Bender Range %
Assign Mode %
Reverb Switch %
Press SPACE BAR to sound note % at volume % for duration % on channel % .
#END
-1,-1,NULL
};
struct paraminfo Pdtim[] = {
/*
NAME TYPE POS MAX OFFSET MASK SHIFT ADHOC
*/
#O tonegroup tonegroup %% 3 0
#O tonenum tonenum %% 63 1
#O keyshift keyshift %% 48 2
#O finetune finetune %% 100 3
#O bendrange bendrange %% 24 4
#O assignmode assignmode %% 3 5
#O reverbsw onoff %% 1 6
#O autopitch num %% 127 -60
#O autovol num %% 127 -63
#O autodur num %% 20 -5 *5
#O autochan num %% 16 -1 *5
NULL,NULL,-1,-1,-1,-1,visnum,0,0,0,0
};
/*
* dtimnum
*
* Convert a voice number (0 to 127) to the string displayed in the
* librarian (ie. 011 to 188).
*/
char *
dtimnum(n)
{
static char v[4];
if ( n < 0 || n > 188 )
return("???");
if(n < 64) {
v[0] = '0';
} else {
v[0] = '1';
n -= 64;
}
v[1] = n/8 + '1';
v[2] = n%8 + '1';
v[3] = '\0';
return(v);
}
/*
* dnumtim
*
* Convert a display-style voice number (011 to 188) to internal
* format (0 to 127).
*/
dnumtim(n)
int n;
{
int ld, md, rd;
/* crack out the digits as octal codes */
ld = (n / 100); /* left digit */
n %= 100;
md = (n / 10) - 1; /* middle digit */
rd = (n % 10) - 1; /* right digit */
if(ld < 0 || ld > 1 || md < 0 || md > 7 || rd < 0 || rd > 7) {
return(-1);
} else {
return((ld * 64) + (md * 8) + rd); /* combine as octal */
}
}
/*
* dtimdin
*
* Take library bank 'data' and stuff values in the P array, by using
* the setval function.
*/
dtimdin(data)
char *data;
{
/* The first RESERVESIZE bytes are reserved (arbitrarily) for the voice name */
#SETVAL
}
/*
* dtimdout
*
* Take (possibly changed) parameters values out of the P array and
* put them back into the library bank 'data'.
*/
dtimdout(data)
char *data;
{
#GETVAL
}
/*
* dtimsedit
*
* Send a single voice to the edit buffer of the D10. This will be whatever
* voice is currently selected.
*/
dtimsedit(data)
char *data;
{
int n;
int cksum;
sendmidi(0xf0);
sendmidi(0x41);
sendmidi(0x10);
sendmidi(0x16);
sendmidi(0x12); /* DT1 - Data set 1 command */
sendmidi(0x03); /* address msb */
cksum = 0x03;
sendmidi(0x00);
cksum += 0x00;
sendmidi(0x00); /* address lsb */
cksum += 0x00;
for(n = 0; n < D10TIMSIZE; n++) {
sendmidi(data[n + RESERVESIZE] & 0x7f);
cksum += data[n + RESERVESIZE] & 0x7f;
}
sendmidi((-cksum) & 0x7f); /* checksum */
sendmidi(EOX);
}
/*
* dtimnof
*
* Return a pointer to the voice name buried in library bank data.
*/
char *
dtimnof(data)
char *data;
{
static char buf[4];
int n;
for(n = 0; n < D10TIMSIZE; n++)
if ( data[n + RESERVESIZE] != 0 ) break;
if ( n != D10TIMSIZE ) {
strcpy(buf, vistonegroup(data[RESERVESIZE + 0]));
strcat(buf, vistonenum(data[RESERVESIZE + 1]));
} else
strcpy(buf, " ");
return(buf);
}
/*
* dtimsnof
*
* Set the voice name buried in data to name.
*/
dtimsnof(data,name)
char *data;
char *name;
{
}
/* dtimsone - send a single voice to the D10 */
dtimsone(iv, data)
int iv;
char *data;
{
int n;
int cksum;
long curadd;
int addbyte;
curadd = TIMBASEADDR;
for(n = 0; n < iv; n++) {
curadd += D10TIMSIZE;
if((curadd & 0x80) != 0) {
curadd &= 0x7fff7f;
curadd += 0x100;
}
if((curadd & 0x8000) != 0) {
curadd &= 0x7f7f7f;
curadd += 0x10000;
}
}
sendmidi(0xf0);
sendmidi(0x41);
sendmidi(0x10);
sendmidi(0x16);
sendmidi(0x12); /* DT1 - Data set 1 command */
addbyte = ((curadd >> 16) & 0x7f); /* address msb */
sendmidi(addbyte);
cksum = addbyte;
addbyte = ((curadd >> 8) & 0x7f);
sendmidi(addbyte);
cksum += addbyte;
addbyte = (curadd & 0x7f); /* address lsb */
sendmidi(addbyte);
cksum += addbyte;
for(n = 0; n < D10TIMSIZE; n++) {
sendmidi(data[n + RESERVESIZE] & 0x7f);
cksum += data[n + RESERVESIZE] & 0x7f;
}
sendmidi((-cksum) & 0x7f); /* checksum */
sendmidi(EOX);
return(0);
}
/* dtimgbulk - Request and read a bulk dump from the D10 */
dtimgbulk(data)
char *data;
{
static char Buff[BUFSIZ];
int n, v, b2, ret = 1;
long begin, toolong;
long curadd;
int addbyte;
int cksum;
sprintf(Buff,"\nA: ");
windstr(Buff);
curadd = TIMBASEADDR;
for(v = 0; v < Nvoices; v++) {
flushmidi();
if(v == 64) {
sprintf(Buff,"\nB: ");
windstr(Buff);
}
if((((v > 63) ? (v - 64) : v) % 10) != 0) {
sprintf(Buff, ".");
} else {
sprintf(Buff,"%d", (((v > 63) ? (v - 64) : v) / 10));
}
windstr(Buff);
/* request the voice */
sendmidi(0xf0);
sendmidi(0x41);
sendmidi(0x10);
sendmidi(0x16);
sendmidi(0x11); /* RQ1 - Data request 1 command */
addbyte = ((curadd >> 16) & 0x7f); /* address msb */
sendmidi(addbyte);
cksum = addbyte;
addbyte = ((curadd >> 8) & 0x7f);
sendmidi(addbyte);
cksum += addbyte;
addbyte = (curadd & 0x7f); /* address lsb */
sendmidi(addbyte);
cksum += addbyte;
sendmidi(0x00); /* length msb */
cksum += 0x00;
sendmidi(0x00);
cksum += 0x00;
sendmidi(D10TIMSIZE); /* length lsb */
cksum += D10TIMSIZE;
sendmidi((-cksum) & 0x7f); /* checksum */
sendmidi(EOX);
/* set up timeout */
begin = milliclock();
toolong = begin + (1000 * TIMEOUT);
/* read header */
for(n = 0; n < 8; ) {
if ( STATMIDI ) {
b2 = (getmidi() & 0xff);
/* burn active sensing and timing clock */
if((b2 != 0xfe) && (b2 != 0xf8))
n++;
} else {
if ( milliclock() > toolong ) {
Reason = "Timeout waiting for header";
goto getout;
}
}
}
/* read data */
for(n = 0; n < D10TIMSIZE; ) {
if ( STATMIDI ) {
b2 = (getmidi() & 0xff);
/* burn active sensing and timing clock */
if((b2 != 0xfe) && (b2 != 0xf8)) {
VOICEBYTE(data,v,n + RESERVESIZE) = b2;
n++;
}
} else {
if ( milliclock() > toolong ) {
Reason = "Timeout reading data";
goto timeout;
}
}
}
timeout:
if ( n != D10TIMSIZE ) {
Reason = "Timeout reading data!";
goto getout;
}
/* read checksum */
for(n = 0; n < 1; ) {
if ( STATMIDI ) {
b2 = (getmidi() & 0xff);
/* burn active sensing and timing clock */
if((b2 != 0xfe) && (b2 != 0xf8))
n++;
} else {
if ( milliclock() > toolong ) {
Reason = "Timeout reading checksum";
goto getout;
}
}
}
/* read EOX */
for(n = 0; n < 1; ) {
if ( STATMIDI ) {
b2 = (getmidi() & 0xff);
/* burn active sensing and timing clock */
if((b2 != 0xfe) && (b2 != 0xf8))
if ( b2 != EOX ) {
sprintf(Buff,"EOX not received (%X)\n", b2);
Reason = Buff;
goto getout;
}
n++;
} else {
if ( milliclock() > toolong ) {
Reason = "Timeout reading EOX";
goto getout;
}
}
}
curadd += D10TIMSIZE;
if((curadd & 0x80) != 0) {
curadd &= 0x7fff7f;
curadd += 0x100;
}
if((curadd & 0x8000) != 0) {
curadd &= 0x7f7f7f;
curadd += 0x10000;
}
} /* go back for another voice */
Reason = "";
ret = 0; /* all's well */
getout:
return(ret);
}
/* dtimsbulk - send a bulk dump to the D10 */
dtimsbulk(data)
char *data;
{
static char Buff[BUFSIZ];
int v, n;
int cksum;
long curadd;
int addbyte, databyte;
int curoff;
curadd = TIMBASEADDR;
curoff = 0;
sprintf(Buff,"\nA: ");
windstr(Buff);
for(v = 0; v <Nvoices ; v++) {
if(v == 64) {
sprintf(Buff,"\nB: ");
windstr(Buff);
}
if((((v > 63) ? (v - 64) : v) % 10) != 0) {
sprintf(Buff, ".");
} else {
sprintf(Buff,"%d", (((v > 63) ? (v - 64) : v) / 10));
}
windstr(Buff);
sendmidi(0xf0);
sendmidi(0x41);
sendmidi(0x10);
sendmidi(0x16);
sendmidi(0x12); /* DT1 - Data set 1 command */
addbyte = ((curadd >> 16) & 0x7f); /* address msb */
sendmidi(addbyte);
cksum = addbyte;
addbyte = ((curadd >> 8) & 0x7f);
sendmidi(addbyte);
cksum += addbyte;
addbyte = (curadd & 0x7f); /* address lsb */
sendmidi(addbyte);
cksum += addbyte;
for(n = 0; n < D10TIMSIZE; n++) {
databyte = data[curoff + n + RESERVESIZE] & 0x7f;
sendmidi(databyte);
cksum += databyte;
}
sendmidi((-cksum) & 0x7f); /* checksum */
sendmidi(EOX);
curadd += D10TIMSIZE;
if((curadd & 0x80) != 0) {
curadd &= 0x7fff7f;
curadd += 0x100;
}
if((curadd & 0x8000) != 0) {
curadd &= 0x7f7f7f;
curadd += 0x10000;
}
curoff += (D10TIMSIZE + RESERVESIZE);
}
return(0);
}
/* end */