home *** CD-ROM | disk | FTP | other *** search
- /* $Id: dw8000.mnu,v 1.6 89/05/06 17:13:21 lee Exp $
- * GLIB - a Generic LIBrarian and editor for synths
- *
- * DW8000 Librarian
- *
- * Code completed 8/24/87 -- Steven A. Falco moss!saf
- * modifications: Greg Lee
- * $Log: dw8000.mnu,v $
- * Revision 1.6 89/05/06 17:13:21 lee
- * rel. to comp.sources.misc
- *
- */
-
- #define OVERLAY2
-
- #include "glib.h"
-
- #define DW8VSIZE 51
-
- char *visnum(), *visd8wave(), *visd8oct(), *visd8trk();
- char *visd8ival(), *visd8detu(), *visdasel(), *dw8vnum(), *visdamod();
- char *visdmgw(), *visdmode(), *visd8pol(),*visd8sem(), *visonoff();
-
- #define RESERVESIZE 20
-
- #define visdw8vnum dw8vnum
- /* This array contains arbitrary screen labels */
- struct labelinfo Ldw800[] = {
- #MENU
-
-
- +----------------------------------+----------------+------------------+------+
- | Osc 1 Osc 2 Noise| ModGen| AutoBend| Mode |
- |Octave % % |Waveform % |Select % |% |
- |Waveform % % |Frequency % |Mode % | |
- |Level % % % |Delay % |Time % | |
- |Interval % |Osc % |Intensity % | |
- |Detune % |VCF % | | |
- +------------------+---------------+----------------+------------------+------+
- | VCF VCA| Delay| Joystick | Portamento |Key |
- |Attack % % |Time % |Osc % |Time % |Param |
- |Decay % % |Factor % |VCF % | |% |
- |Break Pt. % % |Feedback % +----------------+------------------+------+
- |Slope % % |Frequency % |
- |Sustain % % |Intensity % | +-------------------------+--------------+
- |Release % % |Eff.Level % | |Space = Play Note | Auto-Note |
- |V.Sensitv % % +---------------+ | | |
- |Cutoff % | AftTouch| |h = left q = quit |Pitch % |
- |Resonance % |Osc.MG % | |j = down N = Set Name |Duration % |
- |Tracking % |VCF % | |k = up J = Decrement |Volume % |
- |Polarity % |VCA % | |l = right K = Increment |Channel % |
- |EG.Intens % | | | | |
- +------------------+---------------+ +-------------------------+--------------+
- #END
- -1,-1,NULL
- };
-
- /* This array defines all the editable parameters. */
- struct paraminfo Pdw800[] = {
- /*
- NAME TYPE POS MAX OFFSET MASK SHIFT ADHOC
- */
- #O o1oct d8oct %% 3 0
- #O o2oct d8oct %% 3 7
- #O mgwave dmgw %% 3 34
- #O abndsel dasel %% 3 3
- #O mode dmode %% 3 13
- #O o1wave d8wave %% 15 1
- #O o2wave d8wave %% 15 8
- #O mgfrew num %% 31 35
- #O abndmod damod %% 1 4
- #O o1lev num %% 31 2
- #O o2lev num %% 31 9
- #O noise num %% 31 12
- #O mgdela num %% 31 36
- #O abndtim num %% 31 5
- #O o2ival d8ival %% 7 10
- #O mgosc num %% 31 37
- #O abndins num %% 31 6
- #O o2detu d8detu %% 7 11
- #O mgvcf num %% 31 38
- #O fatt num %% 31 20
- #O aatt num %% 31 27
- #O dtim num %% 7 41
- #O joyosc d8sem %% 15 39
- #O portam num %% 31 47
- #O fdec num %% 31 21
- #O adec num %% 31 28
- #O dfact num %% 15 42
- #O joyvcf onoff %% 1 40
- #O vnumb dw8vnum %% 63 14
- #O fbrk num %% 31 22
- #O abrk num %% 31 29
- #O dfeed num %% 15 43
- #O fslp num %% 31 23
- #O aslp num %% 31 30
- #O dfreq num %% 31 44
- #O fsus num %% 31 24
- #O asus num %% 31 31
- #O dintns num %% 31 45
- #O frel num %% 31 25
- #O arel num %% 31 32
- #O deff num %% 15 46
- #O asens num %% 7 33
- #O fsens num %% 7 26
- #O fcut num %% 63 15
- #O autopitch num %% 127 -60
- #O fres num %% 31 16
- #O autovol num %% 127 -63
- #O atosc num %% 3 48
- #O ftrk d8trk %% 3 17
- #O autodur num %% 20 -5 *5
- #O atvcf num %% 3 49
- #O fpol d8pol %% 1 18
- #O autochan num %% 16 -1 *5
- #O atvca num %% 3 50
- #O fegi num %% 31 19
- NULL,NULL,-1,-1,-1,-1,visnum,0,0,0,0
- };
-
-
- /*
- * dw8vnum
- *
- * Convert a voice number (0 to 63) to the string displayed in the
- * librarian (ie. 11 to 88).
- */
- /* added vis to beginning of this name -- gl */
- char *
- dw8vnum(n)
- {
- static char v[3];
-
- if ( n < 0 || n > 63 )
- return("??");
-
- v[0] = n/8 + '1';
- v[1] = n%8 + '1';
- v[2] = '\0';
- return(v);
- }
-
- /*
- * dw8numv
- *
- * Convert a display-style voice number (11 to 88) to internal
- * format (0 - 63).
- */
-
- dw8numv(n)
- int n;
- {
- int ld, rd;
-
- /* crack out the digits as octal codes */
- ld = (n / 10) - 1; /* left digit */
- rd = (n % 10) - 1; /* right digit */
-
- if(ld < 0 || ld > 7 || rd < 0 || rd > 7) {
- return(-1);
- } else {
- return(ld * 8 + rd); /* combine as octal */
- }
- }
-
- /*
- * dw8din
- *
- * Take library bank 'data' and stuff values in the P array, by using
- * the setval function.
- */
-
- dw8din(data)
- char *data;
- {
- /* The first 20 bytes are reserved (arbitrarily) for the voice name */
- #SETVAL
- /* We set the 'auto-note' channel upon entry */
- setval("autochan",Channel);
- }
-
- /*
- * dw8dout
- *
- * Take (possibly changed) parameters values out of the P array and
- * put them back into the library bank 'data'.
- */
-
- dw8dout(data)
- char *data;
- {
- #GETVAL
- /* If the autochan parameter has changed, update Channel */
- Channel = getval("autochan");
- }
-
- /*
- * dw8sedit
- *
- * Send a single voice to the edit buffer of the DW8000. This will be whatever
- * voice is currently selected.
- */
-
- dw8sedit(data)
- char *data;
- {
- int n;
-
- sendmidi(0xf0);
- sendmidi(0x42);
- sendmidi(0x30 | (Channel - 1));
- sendmidi(0x03);
- sendmidi(0x40);
- for(n = 0; n < DW8VSIZE; n++) {
- sendmidi(data[n + 20] & 0x7f);
- }
- sendmidi(EOX);
- }
-
- /*
- * dw8nof
- *
- * Return a pointer to the voice name buried in library bank data.
- */
- char *
- dw8nof(data)
- char *data;
- {
- static char currbuff[17];
- char *p;
- int m;
-
- p = currbuff;
- for ( m=0; m<16; m++ )
- *p++ = data[m];
- *p = '\0';
- return(currbuff);
- }
-
- /*
- * dw8snof
- *
- * Set the voice name buried in data to name.
- */
- dw8snof(data,name)
- char *data;
- char *name;
- {
- char *p;
- int m;
-
- for ( p=name,m=0; *p!='\0' && m<16; p++,m++ )
- data[m] = *p;
- for ( ; m<16; m++ )
- data[m] = ' ';
- }
-
- /* dw8sone - send a single voice to the DW8000 */
- dw8sone(iv, data)
- int iv;
- char *data;
- {
- int c, b2, ret = 1;
- long begin, toolong;
-
- /* select voice n */
- sendmidi(0xc0 | (Channel - 1));
- sendmidi(iv);
-
- /* send data */
- dw8sedit(data);
-
- /* request write */
- sendmidi(0xf0);
- sendmidi(0x42);
- sendmidi(0x30 | (Channel - 1));
- sendmidi(0x03);
- sendmidi(0x11); /* write request */
- sendmidi(iv); /* the now-current voice */
- sendmidi(EOX);
-
- /* read the ack/nack - set up for timeout */
- begin = milliclock();
- toolong = begin + 1000 * TIMEOUT;
-
- /* wait for the 0x03 byte (dw8000 ID byte) */
- while ( milliclock() < toolong ) {
- if ( STATMIDI && (c=(getmidi() & 0xff)) == 0x03 )
- break;
- }
- if ( c != 0x03 ) {
- Reason = "Timeout waiting for 0x03";
- goto getout;
- }
-
- /* next byte is the result code */
- while((b2 = getmidi() & 0xff) == 0xfe)
- ; /* burn active sensing */
- if(b2 != 0x21) {
- Reason = "Write failed - check protect switch!";
- goto getout;
- }
-
- while((b2 = getmidi() & 0xff) == 0xfe)
- ; /* want EOX - burn active sensing */
- if ( b2 != EOX )
- Reason = "EOX not received";
- else {
- Reason = "";
- ret = 0; /* all's well */
- }
-
- getout:
- return(ret);
- }
-
- /* dw8gbulk - Request and read a bulk dump from the DW8000 */
- dw8gbulk(data)
- char *data;
- {
- int c, n, v, b2, ret = 1;
- long begin, toolong;
-
- flushmidi();
-
- for(v = 0; v < Nvoices; v++) {
- /* select voice */
- sendmidi(0xc0 | (Channel - 1));
- sendmidi(v);
-
- /* request the voice */
- sendmidi(0xf0);
- sendmidi(0x42);
- sendmidi(0x30 | (Channel-1)); /* Channel # */
- sendmidi(0x03);
- sendmidi(0x10);
- sendmidi(EOX);
-
- /* set up for timeout */
- begin = milliclock();
- toolong = begin + 1000 * TIMEOUT;
-
- /* wait for the x40 byte starting the dump */
- while ( milliclock() < toolong ) {
- if ( STATMIDI && (c=(getmidi() & 0xff)) == 0x40 )
- break;
- }
- if ( c != 0x40 ) {
- Reason = "Timeout waiting for 0x40";
- goto getout;
- }
-
- /* now read 51 bytes of voice data */
- for(n = 0; n < DW8VSIZE; n++) {
- /* twiddle your thumbs, but not forever */
- while ( ! STATMIDI ) {
- if ( milliclock() > toolong )
- goto timeout; /* the end of an era */
- }
- while((b2 = getmidi() & 0xff) == 0xfe)
- ; /* burn active sensing */
- VOICEBYTE(data,v,n + 20) = b2;
- }
-
- timeout:
- if ( n != DW8VSIZE ) {
- Reason = "Timeout while reading!";
- goto getout;
- }
- while((b2 = getmidi() & 0xff) == 0xfe)
- ; /* want EOX - burn active sensing */
- if ( b2 != EOX )
- Reason = "EOX not received";
- else {
- Reason = "";
- ret = 0; /* all's well */
- }
- } /* go back for another voice */
-
- getout:
- return(ret);
- }
-
- /*
- * Below are functions used for display of parameter values
- */
-
- char *
- visd8wave(v)
- {
- switch (v) {
- case 0: return("ramp");
- case 1: return("square");
- case 2: return("ac. piano");
- case 3: return("el. piano");
- case 4: return("hd. piano");
- case 5: return("clavinet");
- case 6: return("organ");
- case 7: return("brass");
- case 8: return("sax");
- case 9: return("violin");
- case 10: return("a. guitar");
- case 11: return("d. guitar");
- case 12: return("el. bass");
- case 13: return("dg. bass");
- case 14: return("bell");
- case 15: return("sine");
- }
- return("*");
- }
-
- char *
- visd8oct(v)
- {
- switch(v) {
- case 0: return("16");
- case 1: return("8");
- case 2: return("4");
- case 3: return("*");
- }
- return("*");
- }
-
- char *
- visd8ival(v)
- {
- switch(v) {
- case 0: return("unison");
- case 1: return("min 3rd");
- case 2: return("maj 3rd");
- case 3: return("4th");
- case 4: return("5th");
- case 5: case 6: case 7: return("*");
- }
- return("*");
- }
-
- char *
- visd8detu(v)
- {
- switch(v) {
- case 0: return("in tune");
- case 1: return("1 cent");
- case 2: return("2 cents");
- case 3: return("3 cents");
- case 4: return("4 cents");
- case 5: return("5 cents");
- case 6: return("6 cents");
- case 7: return("*");
- }
- return("*");
- }
-
- char *Semicode[] = {
- "none",
- "1 semitone",
- "2 semitones",
- "3 semitones",
- "4 semitones",
- "5 semitones",
- "6 semitones",
- "7 semitones",
- "8 semitones",
- "9 semitones",
- "10 semitones",
- "11 semitones",
- "1 octave"
- };
-
- char *
- visd8sem(v)
- {
- if(v >= 0 && v <= 12) {
- return(Semicode[v]);
- }
- return("*");
- }
-
- char *
- visdasel(v)
- {
- switch(v) {
- case 0: return("off");
- case 1: return("Osc 1");
- case 2: return("Osc 2");
- case 3: return("Osc 1+2");
- }
- return("*");
- }
-
- char *
- visdamod(v)
- {
- switch(v) {
- case 0: return("Up");
- case 1: return("Down");
- }
- return("*");
- }
-
- char *
- visd8pol(v)
- {
- switch(v) {
- case 0: return("/-\\");
- case 1: return("\\_/");
- }
- return("*");
- }
-
- char *
- visdmode(v)
- {
- switch(v) {
- case 0: return("Poly 1");
- case 1: return("Poly 2");
- case 2: return("Uni 1");
- case 3: return("Uni 2");
- }
- return("*");
- }
-
- char *
- visdmgw(v)
- {
- switch(v) {
- case 0: return("/\\");
- case 1: return("|\\");
- case 2: return("/|");
- case 3: return("_|-|");
- }
- return("*");
- }
-
- char *
- visd8trk(v)
- {
- switch(v) {
- case 0: return("0");
- case 1: return("1/4");
- case 2: return("1/2");
- case 3: return("1");
- }
- return("*");
- }
-
- /* end */
-