!! sysx.txt: sysx formats and tool structures for tools that respond to sysx, !! or that should or might respond someday. !! for reference here are the controller structures... struct ControllerInfo { BYTE controller; /* respond to this midi controller number */ UBYTE range; /* range of data allowed */ UBYTE type; /* CITYPE_ */ UBYTE flags; /* there will undoubtedly be some... */ }; /*** bits for ControllerInfo.type ***/ /* switches are 64..120 */ #define CITYPE_SWITCH 1 /* 7-bit continuous are 0..63 */ #define CITYPE_CONTIN 2 /* 14-bit continuous MSBs are 0..31 */ #define CITYPE_CONT14 4 /* don't care to distinguish between switch and continuous 0..120; off=-1 */ #define CITYPE_NODIFF 8 /* set by UpdateControllers() if switch is 63, or continuous is -1 */ #define CITYPE_OFF 64 /*** ranges for CITYPE_s ***/ #define CI_SWITCHRANGE 57 #define CI_CONTINRANGE 64 #define CI_CONT14RANGE 32 #define CI_NODIFFRANGE 121 /*** bits for ControllerInfo.flags ***/ /* this is the last element in the array */ #define CIFLAG_LAST 64 /* this array element has been initialized */ #define CIFLAG_INIT 2 /* throw away these controller inputs after use */ #define CIFLAG_DISCARD 1 ========================================================================= ----- GATE ----- Byte 1 0xF0 SysEx status byte Byte 2 0x01 Manufacturer ID Byte 3-6 0x47 0x41 0x54 0x45 ToolID Byte 7 State: <64=Open; >63=Closed Byte 8 Trigger: 1=Note; 2=Velocity; 3=Control; 4=Aftertouch Byte 9 Threshold/Controller. If Byte8=3, only valid MIDI switch controller numbers (64..119) are accepted. Otherwise, the controller number is not changed. Byte 10 Inputs: <64=Pass; >63=Discard. Byte 11 Real Time Control: <64=off; >63=on. Byte 12 0xF7 End of Exclusive byte. struct GateTool { /* a structure for the tool */ struct Tool tool; struct ControlConfig config; struct ControllerInfo cinfo[4]; UBYTE flags; UBYTE controller; UBYTE notenum; UBYTE velocity; UBYTE touch; }; /* trigger event types for low nibble of flags */ #define TRIG_NOTE 0 #define TRIG_VELOCITY 1 #define TRIG_CONTROL 2 #define TRIG_ATOUCH 3 /*** flag bits ***/ #define GATE_CLOSED 16 /* let the branch-in input proceed */ #define PASS_TRIGGER 32 /* respond to real-time controllers */ #define REALTIME_CONTROL 64 /* respond to sysex messages */ #define REALTIME_SYSEX 128 #define TRIG_MASK 0x0F #define MAX_TRIG TRIG_ATOUCH ----- MIDI Event Filter ----- Byte 1 0xF0 SysEx status byte Byte 2 0x01 Manufacturer ID Byte 3-6 0x44 0x41 0x46 0x43 ToolID ('DAFC') Byte 7 tool.action (bits 0 through 4 mutually exclusive; bit7 valid only if tool.high is less than tool.low) Byte 8 tool.event (0==note,1==ctrl,2==pgm chg,3==mono touch,4==pbend) Byte 9 status byte of midi messages to filter Byte 10 controller # (used only if byte8 == 1) Byte 11 which data byte(s) to test (byte1==1,byte2==2) Byte 12 low end of range (0..127) Byte 13 high end of range (0..127) Byte 14 fold value (0..36) Byte 15 fix value (0..127) Byte 16 0xF7 End of Exclusive status byte struct FiltTool { struct Tool tool; UBYTE action; /* bits for what to do */ UBYTE event; /* what event to filter */ UBYTE control; /* status byte for channel messages */ UBYTE controller; /* controller number */ UBYTE data; /* bits for which bytes to do it to */ UBYTE low; /* low end of range */ UBYTE high; /* high end of range */ UBYTE fold; /* increment/decrement for folding */ UBYTE fix; /* value for fixing data */ }; /* bits for tool->action */ #define ACT_FOLD 1 #define ACT_FIX 2 #define ACT_BRANCH 4 #define ACT_DISCARD 8 /* set when hidata */ #define DATA_BYTE1 1 #define DATA_BYTE2 2 ----- PC MASK ----- Byte 1 0xF0 SysEx status byte Byte 2 0x01 Manufacturer ID Byte 3-6 0x50 0x43 0x4D 0x63 ToolID ('PCMc') Byte 7 6-bit mask for first hexachord of Permit: bit0 is C; bit5 is F. Bit set means permitted. Byte 8 6-bit mask for second hexachord of Permit: bit0 is F#; bit5 is B. Bit set means permitted. Byte 9 bit mask for tool Action: 1=Branch; 2=Discard; 4=Controls; 8=SysEx. if (tool.action & ACT_CONTROL) then cinfo[] is here: Bytes 10-13 cinfo[0] (All) Bytes 14-17 cinfo[1] (Not) Bytes 18-21 cinfo[2] (Rotate L) Bytes 22-25 cinfo[3] (Rotate R) Bytes 26-29 cinfo[4] (Shift L) Bytes 30-33 cinfo[5] (Shift R) Bytes 34-37 cinfo[6] (Action) Byte 10/38 0xF7 End of Exclusive status byte. #define CTRL_COUNT 7 struct MaskTool { /* a Tool structure for the tool */ struct Tool tool; struct ControllerInfo cinfo[CTRL_COUNT]; UWORD mask; /* mask of pitch classes to pass */ UWORD undo; UBYTE action; /* bits for what to do */ UBYTE on[12]; /* counts of pitch classes that are on */ }; /* bits for tool.action */ #define ACT_BRANCH 1 #define ACT_DISCARD 2 #define ACT_CONTROL 4 /* respond to controllers */ #define ACT_SYSEX 8 /* respond to sysex */ ----- SPACE ----- Byte 1 0xF0 SysEx status byte Byte 2 0x01 Manufacturer ID Byte 3-6 0x53 0x50 0x41 0x53 (ToolID) Byte 7 virtual x controller value (0..127) Byte 8 virtual y controller value (0..127) Byte 9 "left" track: 1==track; 2==branch Byte 10 bit mask for Duplicate and Discard gadgets: bit 1 == 1 == Duplicate Notes bit 2 == 1 == Duplicate Controls bit 3 == 1 == Duplicate Channel messsages bit 4 == 1 == Duplicate All messages bit 5 == 1 == Discard Inputs Note that, when set, bit 4 has priority over bits 1 through 3. The same duplication exclusion rules are applied when decoding SysEx messages as when the tool is edited via the control window. Bits 1 and 2 may both be set, but bits 3 and 4 exclude all other bits 1 through 4. Byte 11 virtual x controller number (0..63) Byte 12 virtual y controller number + 1 (0..64; 0==off) Byte 13 track output controller number (0..63) Byte 14 branch output controller number (0..63) Byte 15 0xF7 End of Exclusive status byte. /* * note that angle and theta are still in the tool structure for upward * compatability (hah) */ struct SpaceTool { /* a Tool structure for the tool */ struct Tool tool; UBYTE in; /* controller to interpret as virtual x location */ UBYTE distance; /* controller to read as virtual y location */ UBYTE angle; /* controller to use as speaker separation angle */ UBYTE tout; /* controller to send on master track */ UBYTE bout; /* controller to send on branch track */ UBYTE master; /* which track gets to be "left"? */ UBYTE trash; /* free the incoming control message? */ UBYTE dupe; /* duplicate notes and send to branch? */ double x; /* last virtual x coordinate */ double y; /* last virtual y coordinate */ double theta; /* last speaker-spread angle value (radians) */ }; /* bits for which track is the left */ #define MTRACK 1 #define MBRANCH 2 /* bits for which MIDI events to duplicate and send to the branch */ #define DUPE_NOTE 1 #define DUPE_CONTROL 2 #define DUPE_CHANNEL 4 #define DUPE_ALL 8 ----- BYPASS ----- 9 bytes + 7 bytes overhead = 16 byte total message length 1: 0xF0 2: 0x01 3-6 "BYPS" 7-10 destination toolid 11 ordinal position of the proper instance of the destination tool 12 state bits 13 midi_route bits 14 state controller # 15 rr_controller # 16 0xF7 struct BypassTool { /* a Tool structure for the tool */ struct Tool tool; struct Tool *destination; long id; /* destination's tool id */ UBYTE state; /* bit for pass/bypass state, and various flags */ UBYTE midi_route; /* flags for which midi events to reroute */ UBYTE controller; /* cc# which changes tool state */ BYTE rr_controller; /* cc# for controllers to reroute; -1 = all */ long bp_route_pad; /* flags for b&p events to reroute -- not implemented, but here to support backward compatibility later */ }; /* this bit is set in tool.state if destination holds a tool id instead of an address (i.e., loaded from disk and not yet initialized) so inittool() knows to try to find the appropriate tool in the pipeline. */ #define TOOL_BOGUS 128 /* this bit set in tool.state if we notice the selected destination tool has mysteriously vanished */ #define TOOL_DELETED 64 /* free my sysex or controller messages */ #define DISCARD_SYSEX 32 #define DISCARD_CTRL 16 /* real state bit */ #define ST_BYPASS 1 /*** bits for midi_route ***/ #define MR_NOTE 1 #define MR_BEND 2 #define MR_MTOUCH 4 #define MR_PTOUCH 8 #define MR_PGM 16 #define MR_CCHG 32 #define MR_SYSEX 64 ----- CROSSFADE ----- struct PanTool { /* a Tool structure for the tool */ struct Tool tool; UBYTE in; /* controller to respond to */ UBYTE out; /* controller to send */ UBYTE master; /* which track gets to be "left"? */ UBYTE trash; /* free the incoming control message? */ }; /* bits for which track is the master (left) */ #define MTRACK 1 #define MBRANCH 2 ----- MIDI EVENT FILTER ----- struct FiltTool { /* a Tool structure for the tool */ struct Tool tool; UBYTE action; /* bits for what to do */ UBYTE event; /* what event to filter */ UBYTE control; /* status byte for channel messages */ UBYTE controller; /* controller number */ UBYTE data; /* bits for which bytes to do it to */ UBYTE low; /* low end of range */ UBYTE high; /* high end of range */ UBYTE fold; /* increment/decrement for folding */ UBYTE fix; /* value for fixing data */ }; /* bits for tool->action */ #define ACT_FOLD 1 #define ACT_FIX 2 #define ACT_BRANCH 4 #define ACT_DISCARD 8 #define ACT_NOTCH 128 /* set when hidata */ #define DATA_BYTE1 1 #define DATA_BYTE2 2 ----- WYE ----- 1: 0xF0 2: state 3: controller # (switches valid) 4: 0xF7 struct YTool { /* a Tool structure for the tool */ struct Tool tool; UBYTE state; UBYTE controller; }; #define ST_WYE 1 #define ST_DISCARD 2 /* set this bit to branch only note on/off messages, or all channel voice messages will be branched */ #define ST_NOTEONLY 4 ----- REORG ----- Byte 1 first Byte 2 high byte of wait Byte 3 low byte of wait struct ReorgTool { /* a Tool structure for the tool */ struct Tool tool; UBYTE running; /* transport running? */ UBYTE first; /* what event has priority */ UWORD wait; /* ticks to wait before releasing without receiving another */ LONG timer; /* downcounter to see if we should release an event */ ULONG lasttime; /* what time was it last time we cared? */ struct NoteEvent *q; /* event we're holding to test against the next event */ }; ----- RANDOM CHORDS ----- struct ChordTool { struct Tool tool; /* parameters for generators that need them */ /* these must be immediately after the Tool! */ double randparm; double randparm2; ULONG flags; long (*getrand)(long, struct ChordTool *); /* random number generator */ struct ChordEvent *prevchord; /* tool parameters */ long ratemax; long ratemin; long time; UBYTE memmax; UBYTE memmin; UBYTE rootmax; UBYTE rootmin; UBYTE smallmax; UBYTE smallmin; UBYTE largemax; UBYTE largemin; UBYTE randgen; /* id bit for random number generator */ BYTE prevroot; }; /* flag bits */ /* rate */ #define RHYTHMB 1 #define TAPB 2 #define RANDOMB 4 #define CYCLEB 8 /* members */ #define RANDMEMB 0x10 #define FIXMEMB 0x20 /* root */ #define RHYTHMROOTB 0x40 #define TAPROOTB 0x80 #define RANDROOTB 0x100 #define REUSEB 0x200 #define FIXROOTB 0x400 /* small and large */ #define RANDSMALLB 0x800 #define FIXSMALLB 0x1000 #define RANDLARGEB 0x2000 #define FIXLARGEB 0x4000 /* posting */ #define TRACKB 0x8000 #define SONGB 0x10000 #define CHORDLISTB 0x20000 /* force number of chord members */ #define FORCEB 0x40000 /* is we is, or is we ain't */ #define RUNNING 0x80000 /* flag bit masks */ #define RATEMASK 0xF #define MEMBERMASK 0x30 #define ROOTMASK 0x7C0 #define SMALLMASK 0x1800 #define LARGEMASK 0x6000 #define POSTMASK 0x38000 /* random number generators */ #define RANDNUMB 1 #define RANDRANDB 2 #define LINEARB 4 #define POISSONB 8 #define BETAB 16 #define TRIANGLEB 32 #define WEIBULLB 64 ----- TRIGGER ----- Byte 1: trigger (tool->flags & TRIG_MASK) Byte 2: threshold (tool->threshold) Byte 3: controller Byte 4: flush? (tool->flags & DO_FLUSH) struct TrigTool { /* a structure for the tool */ struct Tool tool; struct NoteEvent *q; /* head of list of queued events */ struct NoteEvent *qtail; /* tail... */ UBYTE flags; /* behavior and state */ UBYTE threshold; /* how big does it have to be to change state */ UBYTE controller; /* controller number; valid for TRIG_CONTROL */ }; /* trigger event types for low nibble of flags */ #define TRIG_NOTE 0 #define TRIG_VELOCITY 1 #define TRIG_CONTROL 2 #define TRIG_ATOUCH 3 #define MAX_TRIG TRIG_ATOUCH #define TRIG_MASK 0x0F /*** flag bits for behavior and state ***/ #define RUNNING 16 #define DO_FLUSH 32 #define QUEUE_EVENTS 128