/*      SoundScape.H 
 
        (c) 1986 Todor Fay 
 
        Definitions and structure declarations for SoundScape. 
*/ 
 
struct Link { 
        struct Link *next;         /* Next node in the linked list. */ 
        unsigned char type;        /* Type of this node. */ 
        unsigned char mark; 
        unsigned short data; 
}; 
 
struct Note { 
        struct Link link; 
        unsigned short duration;    /* Clock beats the note is on. */ 
        unsigned short wait;        /* Clock beats till next note. */ 
        unsigned char status;       /* Midi status. */ 
        unsigned char value;        /* Note value. */ 
        unsigned char velocity; 
}; 
 
struct Seq { 
        struct Link link; 
        struct Note *note;          /* Pointer to a string of notes. */ 
        unsigned short wait;        /* Clock beats till next note. */ 
        char transpose;             /* Transpose value. */ 
        char usetrans;              /* Use this tranposition. */ 
}; 
 
#define NAMESIZE        12 
 
struct Track { 
        struct Link link; 
        struct Seq *startseq;       /* First sequence node. */ 
        struct Seq *seq;            /* Pointer to sequence being processed. */ 
        struct Note *startnote;     /* First note in sequence. */ 
        struct Note *note;          /* Next note to play. */         
        struct Note *lastnote;      /* Last note played. */ 
        struct Note *noteon;        /* Oldest note still on. */ 
        struct Note *rnote;         /* Note list for recording. */ 
        struct Note *rstartnote;    /* Note list for recording. */ 
        unsigned long time;         /* Time last event was recorded. */ 
        unsigned short wait;        /* Clock beats till next note. */ 
        unsigned short rstartwait;  /* Initial wait when recording. */ 
        unsigned short startwait;   /* Initial wait. */ 
        short mode;                 /* Play/Mute/Through, etc. */ 
        short statusin;             /* Status types to allow in. */ 
        short statusout;            /* Status types to allow out. */ 
        char name[NAMESIZE];        /* Track gets a name! */ 
        unsigned char portin;       /* Midi port to listen to. */ 
        unsigned char portout;      /* Midi port to send to. */ 
        char channelin;             /* Midi channel to record from. */ 
        char channelout;            /* Midi channel to play on. */ 
        char transpose;             /* Transpose value. */ 
}; 

struct Ports {
	struct Link link;	    /* Yest another linked list. */
	unsigned char port;	    /* The index of the port to send to. */
};

struct Port {
	struct Ports *portsout;	    /* Ports to send to. */
	char *name;		    /* Name of this port. */
	long (*outcode)();	    /* Routine to output a note. */
	long (*editcode)();	    /* Routine to allow editing. */
	long (*closecode)();	    /* Routine to close port. */
	long (*opencode)();	    /* Routine to open port. */
	char countin;		    /* # of ports sending here. */
	char doin;		    /* Active for input flag. */
	char doout;		    /* Active for output flag. */
	char show;		    /* Voodoo magic. */
};
 
/*        Node types. */ 

#define NOTE       1 
#define SEQ        2 
#define TRACK      3 
 
/*         Track Mode Types. */ 
 
#define T_REC          1        /* Allow recording. */ 
#define T_PLAY         2        /* Playback. */ 
#define T_MUTE         4        /* Don't do anything. */ 
#define T_THRU         8        /* Pass note info on (while recording). */ 
#define T_TRANS        0x10     /* Allow transpositions. */ 
#define T_MATCH        0x20     /* This track is in match mode. */ 
#define T_1PLAY        0x40     /* One play mode, delete when done. */ 
#define T_ECHO         0x80     /* Use this as an echo template. */ 
#define T_CAUSETRANS   0x100    /* Cause transpositions. */ 
#define T_TRIGGER      0x200    /* Wait for a specific event, then play. */ 
 
/*        Midi Commands */ 
 
#define NOTEOFF             0x80 
#define NOTEON              0x90 
#define POLYPRESSURE        0xA0 
#define CONTROLCHANGE       0xB0 
#define PROGRAMCHANGE       0xC0 
#define AFTERTOUCH          0xD0 
#define PITCHWHEEL          0xE0 
#define SYSTEMX             0xF0 
#define SONGPOSITION        0xF2 
#define SONGSELECT          0xF3 
#define TUNE                0xF6 
#define EOX                 0xF7 
#define CLOCK               0xF8 
#define PUNCHIN             0xF9
#define START               0xFA 
#define CONTINUE            0xFB 
#define STOP                0xFC 
#define PUNCHOUT            0xFD
#define ACTIVESENSE         0xFE 
 
/*        Edit commands */ 
 
#define USEREDIT        1 
#define GETSTATE        2 
#define SETSTATE        3 
#define LOADSTATE       4 
#define SAVESTATE       5 

