/*      Bars.h

	© 1989,1991 The Blue Ribbon SoundWorks, Ltd.

	Header file for Bars&Pipes Professional Tools and Accessories
*/

#define MIDI_NOTEOFF    0x80
#define MIDI_NOTEON     0x90
#define MIDI_PTOUCH     0xA0
#define MIDI_CCHANGE    0xB0
#define MIDI_PCHANGE    0xC0
#define MIDI_MTOUCH     0xD0
#define MIDI_PBEND      0xE0
#define MIDI_SYSX       0xF0
#define MIDI_MTC        0xF1
#define MIDI_SONGPP     0xF2
#define MIDI_SONGS      0xF3
#define MIDI_EOX        0xF7
#define MIDI_CLOCK      0xF8
#define MIDI_START      0xFA
#define MIDI_CONTINUE   0xFB
#define MIDI_STOP       0xFC
#define MIDI_SENSE      0xFE

#define EVENT_ONTIME    0x10            /* This event is an on-time event. */
#define EVENT_BRANCH    0x20            /* This event is traversing a branch. */
#define EVENT_PADEDIT   0x40            /* Not a real time event. */
#define EVENT_PLAYONLY  0x80            /* Discard event when recording. */
#define EVENT_VOICE     1               /* Performance event */
#define EVENT_SYSX      2               /* System exclusive event. */
#define EVENT_LYRIC     3               /* Lyric string. */
#define EVENT_TIMESIG   4               /* Time signature change event. */
#define EVENT_KEY       5               /* Key change event. */
#define EVENT_CHORD     6               /* Chord change event. */
#define EVENT_RHYTHM    7               /* Rhythm template event. */
#define EVENT_DYNAMICS  8               /* Dynamics event. */


struct Event {
    struct Event *next;                 /* The next event in the list. */
    long time;                          /* When this event occurs. */
    char type;                          /* What type of event. */
    unsigned char status;               /* MIDI status. */
    unsigned char byte1;                /* First byte of data. */
    unsigned char byte2;                /* Second byte of data. */
    long data;                          /* Data storage. */
    struct Tool *tool;                  /* Tool that processes this next. */
};

struct EventList {
    struct Event *first;                /* First in list. */
    struct Event *point;                /* Current position in list. */
};


struct NoteEvent {
    struct NoteEvent *next;             /* The next event in the list. */
    long time;                          /* When this event occurs. */
    char type;                          /* What type of event. */
    unsigned char status;               /* MIDI status. */
    unsigned char value;                /* Note value. */
    unsigned char velocity;             /* Note velocity. */
    unsigned short duration;            /* The duration of this event. */
    short data;                         /* Data storage. */
    struct Tool *tool;                  /* Tool that processes this next. */
};

struct String {
    unsigned short length;              /* The length of the string that follows. */
    char string[1];                     /* This is actually a variable length array. */
};

struct StringEvent {
    struct StringEvent *next;           /* The next event in the list. */
    long time;                          /* When this event occurs. */
    char type;                          /* What type of event. */
    unsigned char status;               /* For SysEx. */
    short length;                       /* Display length. */
    struct String *string;              /* Pointer to string. */
    struct Tool *tool;                  /* Tool that processes this next. */
};

struct SysEx {
    unsigned long length;               /* The length of the packet. */
    struct Task *task;                  /* Sending task, for signaling. */
    short signal;                       /* Signal number. */
    char done;                          /* Done flag. */
    char *data;                         /* The data. */
};

struct SysExEvent {
    struct SysExEvent *next;            /* The next event in the list. */
    long time;                          /* When this event occurs. */
    char type;                          /* What type of event. */
    unsigned char status;               /* For SysEx. */
    short length;                       /* Display length. */
    struct SysEx *sysex;               /* Pointer to data. */
    struct Tool *tool;                  /* Tool that processes this next. */
};

struct Chord {
    struct Chord *next;                 /* Next in list. */
    struct String *name;                /* Chord name. */
    unsigned long pattern;              /* Bit pattern of chord. */
    unsigned short id;                  /* Chord identifier. */
    char count;                         /* Number of notes in chord. */
};

struct ChordEvent {
    struct ChordEvent *next;            /* The next event in the list. */
    long time;                          /* When this event occurs. */
    char type;                          /* What type of event. */
    unsigned char root;                 /* Root note. */
    char flats;                         /* Chord root is a flat. */
    char pad;
    unsigned long chordid;              /* Chord id. */
    struct Chord *chord;                /* Chord. */
};

struct KeyEvent {
    struct KeyEvent *next;              /* The next event in the list. */
    long time;                          /* When this event occurs. */
    char type;                          /* What type of event. */
    unsigned char root;                 /* Root note. */
    char flats;                         /* Display the key with flats. */
    char pad;
    unsigned long scaleid;              /* Scale id. */
    struct Chord *scale;                /* Pointer to Scale definition. */
};


struct TimeSigEvent {
    struct TimeSigEvent *next;          /* The next event in the list. */
    long time;                          /* When this event occurs. */
    char type;                          /* What type of event. */
    unsigned char beatcount;            /* Number of beats per measure. */
    unsigned char beat;                 /* What note gets beat. */
    char pad;
    unsigned short clocks;              /* Clocks per beat. */
    unsigned short measures;            /* Measures till next. */
    unsigned long totalclocks;          /* Clocks till next. */
};

struct TimeSigList {
    struct TimeSigEvent *first;         /* First in list. */
    struct TimeSigEvent *point;         /* Current position in list. */
    unsigned short measure;             /* Current measure. */
    unsigned short beat;                /* Current beat. */
    unsigned short clock;               /* Current clock. */
};

struct Rhythm {
    struct Rhythm *next;                /* Next in list of templates. */
    struct String *name;                /* Name of this rhythm. */
    struct NoteEvent *notes;            /* List of notes. */
    long length;                        /* Loop length. */
    short id;                           /* Identifier. */
};

struct RhythmEvent {
    struct RhythmEvent *next;           /* The next event in the list. */
    long time;                          /* When this event occurs. */
    char type;                          /* What type of event. */
    char pad;                           /* Empty. */
    unsigned short rhythmid;            /* Id of rhythm clip. */
    struct Rhythm *rhythm;              /* Rhythm. */
    struct NoteEvent *point;            /* Current position in rhythm. */
};

struct DynamicsEvent {
    struct DynamicsEvent *next;         /* The next event in the list. */
    long time;                          /* When this event occurs. */
    char type;                          /* What type of event. */
    unsigned char value;                /* Dynamic value. */
    unsigned char lastvalue;            /* Previous dynamic value. */
    unsigned char nextvalue;            /* Next Dynamic value. */
    long lasttime;                      /* Previous time. */
    long nexttime;                      /* Next time. */
};


struct Clip {
    struct Clip *next;                  /* List of clips. */
    struct EventList events;            /* Event list. */
    struct EventList chords;            /* List of bass chords. */
    struct EventList keys;              /* List of keys. */
    struct EventList lyrics;            /* List of lyrics. */
    struct EventList rhythm;            /* List of rhythm templates. */
    struct EventList dynamics;          /* List of dynamic changes. */
    struct TimeSigList timesig;         /* List of time signatures. */
    struct String *name;                /* Name of this clip. */
    struct String *notes;               /* Notes for this clip. */
    long begin;                         /* Time this begins. */
    long end;                           /* Time this ends. */
    unsigned char highnote;             /* Highest note, for display. */
    unsigned char lownote;              /* Lowest note, for display. */
    char locked;                        /* Locked during record. */
};

/*      For handling a linked list of clips in parallel: */

struct ClipList {
    struct ClipList *next;              /* Next Clip or ClipList. */
    long cliplisttag;                   /* Tag to identify ClipList. */
    struct Clip *cliplist;              /* List of clips. */
};


struct Tool {
    struct Tool *next;                  /* Next tool used by this track. */
    struct Tool *branch;                /* Tool on other track. */
    struct Tool *parent;                /* Parent tool (for macros.) */
    struct ToolMaster *toolmaster;      /* Pointer to actual tool. */
    struct Clip *clip;                  /* Clip to be worked on. */
    struct String *name;                /* Name of this tool. */
    struct Window *window;              /* Edit window. */
    struct Track *track;                /* Track that owns this tool. */
    long toolid;                        /* Tool ID. */
    unsigned short left,top;            /* Position of edit window. */
    unsigned short width,height;        /* Size of edit window. */
    unsigned short x,y;                 /* Position in pipe display. */
    unsigned short xindex;              /* How far down list this is. */
    unsigned short yindex;              /* How far down track list this is. */
    short branchindex;                  /* How far away branch tool is. */
    unsigned short id;                  /* ID for file io. */
    char intool;                        /* True if inlist, false if outlist. */
    char inedit;                        /* Flag to indicate editing now. */
    char touched;                       /* This tool has been edited. */
    char selected;                      /* Icon selected in graph. */
    long tooltype;                      /* Sequence? Input? Branch? */
					/* More tool unique stuff here... */
};

#define TOUCH_EDIT              1       /* Tool has been edited. */
#define TOUCH_INIT              2       /* Tool has been initialised. */

#define TOOL_SEQUENCE           1       /* This is actually the track. */
#define TOOL_INPUT              2       /* This is an input tool. */
#define TOOL_OUTPUT             4       /* This is an output tool. */
#define TOOL_NORMAL             8       /* This is a normal tool. */
#define TOOL_ONTIME             0x10    /* This tool doesn't accept early events. */
#define TOOL_BRANCHIN           0x20    /* This tool merges two inputs. */
#define TOOL_BRANCHOUT          0x40    /* This tool has two outputs. */
#define TOOL_MACRO              0x80    /* This tool is a macro tool. */
#define TOOL_MACROOUT           0x100   /* This is the output of macro. */
#define TOOL_MACROBRANCH        0x200   /* This is the branch output of macro. */
#define TOOL_MACROIN            0x400   /* This is the input of macro. */
#define TOOL_GROUPIN            0x800   /* This tool part of group input. */
#define TOOL_MIDI               0x1000  /* This tool is MIDI capable. */
#define TOOL_NOTPAD             0x2000  /* This can not go in the toolpad. */
#define TOOL_STOOL              0x4000  /* This is a sequencer tool. */
#define TOOL_NOTPIPE            0x8000  /* This tool can not go in pipeline. */

struct ToolMaster {
    struct ToolMaster *next;            /* Next tool in this list. */
    long toolid;                        /* Tool ID. */
    struct Image *image;                /* Icon for this tool. */
    struct Image *upimage;              /* Icon for branching up. */
    short x,y;                          /* Position in toolbox for display. */
    char name[100];                     /* Tool name. */
    char filename[100];                 /* Where it is stored on disk. */
    struct Tool *(*createtool)();       /* Routine to allocate a new tool. */
    void (*edittool)();                 /* Routine to edit tool parameters. */
    struct Event *(*processevent)();    /* Routine to process an event. */
    struct Event *(*processlist)();     /* Routine to process a list of events. */
    void (*deletetool)();               /* Routine to delete a tool. */
    void (*removetool)();               /* Routine to close down. */
    long (*savesize)();                 /* Returns size prior to save. */
    long (*savetool)();                 /* Routine to save to disk. */
    struct Tool *(*loadtool)();         /* Routine to load from disk. */
    void (*readsysex)();                /* Pass sysex byte */
    long (*expandb)();                  /* Clear environment */
    long (*expandc)();                  /* Install environment */
    long segment;                       /* This tool's segment list. */
    long altsegment;                    /* For later.. */
    struct Track *intrack;              /* Input track for this tool. */
    short toolsize;                     /* Tool size for loading and saving. */
    char inedit;                        /* Flag to indicate editing now. */
    char selected;                      /* Icon selected in graph. */
    long tooltype;                      /* Type of tool. */
};

struct Track {
    struct Track *next;                 /* Next Track in the list. */
    struct Edit *edit;                  /* Edit structure for this track. */
    struct Clip clip;                   /* A clip that defines the sequence. */
    struct Clip cut;                    /* A clip for global editing. */
    struct Clip undo;                   /* A clip for undo command. */
    struct EventList record;            /* Event list for recording. */
    struct Tool *toollist;              /* List of tools. */
    struct Tool tool;                   /* Sequence tool. */
    struct Tool *point;                 /* For making display. */
    unsigned char channelin;            /* MIDI Channel coming in. */
    unsigned char channelout;           /* MIDI Channel going out. */
    unsigned char mode;                 /* Mute | Through | Record. */
    unsigned char selected;             /* Track is highlighted. */
    long group;                         /* Group bits. */
    unsigned long marks[20];            /* For figuring out display. */
    short markindex;                    /* Farthest right bit in marks. */
    short height;                       /* Height in display. */
    short nameleft;                     /* Left edge of name. */
    short namewidth;                    /* Width of name field. */
    short nameindent;                   /* Indentation into name field. */
    short channelinleft;                /* Left edge of channel in. */
    short toolsinleft;                  /* Left edge of toolsin. */
    short toolsinwidth;                 /* Width of toolsin field. */
    short toolsinindent;                /* Indentation into toolsin field. */
    short playrecordleft;               /* Left edge of play/record. */
    short sequenceleft;                 /* Left edge of sequence. */
    short sequencewidth;                /* Width of sequence field. */
    long sequenceindent;                /* Indentation into sequence field. */
    short muteleft;                     /* Left edge of mute/through. */
    short toolsoutleft;                 /* Left edge of toolsout. */
    short toolsoutwidth;                /* Width of toolsout field. */
    short toolsoutindent;               /* Indentation into toolsout field. */
    short toolsouttotalwidth;           /* Total width of tools out. */
    short channeloutleft;               /* Left edge of channel out. */
};

#define TRACK_MUTE      1
#define TRACK_THROUGH   2
#define TRACK_RECORD    4
#define TRACK_SOLOMUTE  8               /* Track was muted for solo. */
#define TRACK_INEDIT    16
#define TRACK_REALTIME  32
#define TRACK_MERGE     64              /* Merge while recording. */

#define TB_NOUNDO               1     /* This track has no undo buffer. */
#define TB_PRINTEDIT            2     /* This track has a FALSE edit structure. */
#define TB_STOOL                4     /* There's a sequence tool for this track. */

struct Accessory {
    struct Accessory *next;             /* Next accessory in this list. */
    long id;                            /* Accessory ID. */
    struct Image *image;                /* Icon for this accessory. */
    struct Image *onimage;              /* Icon for when selected. */
    char name[100];                     /* Name. */
    char filename[100];                 /* Where it is stored on disk. */
    struct Window *window;
    unsigned short left,top;            /* Position of edit window. */
    unsigned short width,height;        /* Size of edit window. */
    unsigned short x,y;                 /* Position in access box. */
    long (*remove)();
    long (*edit)();                     /* Routine to edit accessory. */
    long (*open)();                     /* Routine to open it. */
    long (*close)();
    long (*size)();
    long (*save)();
    long (*load)();
    long (*install)();                  /* Install in environment. */
    long (*clear)();                    /* Clear from environment. */
    long (*expandc)();                  /* Future routine? */
    long segment;                       /* This accessory's segment list. */
    long altsegment;                    /* Alternate segment list. */
    char selected;                      /* Icon selected in graph. */
};

#define TC_START        1
#define TC_STOP         2
#define TC_POSITION     3
#define TC_RECORDON     4
#define TC_RECORDOFF    5
#define TC_PLAY         6
#define TC_TICK         7

/*      There is a linked list of Tempo nodes.  Each specifies a clock cycle,
	buffer size, and repeat count.  The last cycles forever.
*/

struct Tempo {
    struct Tempo *next;                 /* Next Tempo in list. */
    long time;                          /* Time, in clocks, this starts. */
    unsigned short cycle;               /* Sample rate. */
    unsigned short bpm;                 /* Beats per minute. */
    long repeat;                        /* Repeat count. */
    unsigned long frame;                /* Frame this starts on. */
};

/*      For editing the Tempo, the user sets Tempo Changes. */

struct TempoChange {
    struct TempoChange *next;
    long time;                          /* When this occurs, in clicks. */
    char eventtype;                     /* What type of event. */
    char type;                          /* Type of change. */
    short bpm;                          /* Beats per minute. */
    long duration;                      /* How long the change should take. */
    struct Tempo *tempos;               /* Pointer into list of tempos. */
};

#define TC_INSTANT      1
#define TC_LINEAR       2
#define TC_EXPCURVE     3
#define TC_LOGCURVE     4

struct SMPTE {
    unsigned char hours, minutes, seconds, frames;
};

struct Section {
    struct Section *next;
    long time;
    char type;                          /* What type of event. */
    char pattern;
    char pad[2];
    struct String *string;              /* Pointer to string. */
    long length;                        /* Length of this section. */
};

/*      Array of pointers to shared data, functions and library pointers,
	so all tools can share these. */
struct RastPort;
struct Gadget;
struct Functions {
    char locked;
    char measureres;                    /* Cuts resolve to measures. */
    char recording;                     /* Set when recording. */
    char running;                       /* Set when running. */
    char punchenabled;                  /* Auto punch in and out enabled. */
    char loopenabled;                   /* Loop mode turned on. */
    char clicking;                      /* Click track on? */
    char seeclick;                      /* Visual metronome. */
    char multiin;                       /* Multiple inputs? */
    char clickchannel;                  /* MIDI CLick channel. */
    char midiclock;                     /* Sync to MIDI clocks. */
    char smpteclock;                    /* Sync to SMPTE. */
    char sendmidiclock;                 /* Send out MIDI clocks. */
    char smptetype;                     /* Which SMPTE format. */
    char countdown;                     /* Do count down. */
    char midiclick;                     /* Use MIDI for click track. */
    char chop;
    long leadinstart;                   /* Length of lead in. */
    long timenow;                       /* Current time. */
    unsigned long markone;              /* Auto locate register. */
    unsigned long marktwo;              /* Auto locate register. */
    unsigned long punchin;              /* Punch in point. */
    unsigned long punchout;             /* Punch out point. */
    unsigned long loopin;               /* Loop in point. */
    unsigned long loopout;              /* Loop out point. */
    unsigned long cutin;                /* Cut in point. */
    unsigned long cutout;               /* Cut out point. */
    long starttime;                     /* Where to play from. */
    long stoptime;                      /* Marker to stop at. */
    unsigned long padcutin;             /* For non real time edits. */
    unsigned long padcutout;            /* For non real time edits. */
    unsigned long songlength;
    long startoffset;                   /* Starting hi res clock offset. */
    unsigned short tempos[4];
    unsigned short tempo;               /* Current tempo. */
    unsigned short inittempo;           /* Initial tempo. */
    char songname[100];
    char author[100];
    short palette[8];                   /* Colors. */
    char remotecontrol[128];            /* Table of remote controls. */
    unsigned long markthree;            /* Auto locate register. */
    unsigned long markfour;             /* Auto locate register. */
    unsigned char volumenum;            /* Mix Maestro Volume CC. */
    unsigned char pannum;               /* Mix Maestro Pan CC. */
    unsigned char subdivide;            /* Metronome subdivision. */
    char bypassmix;
    long savestop;                      /* Place to save stop sign. */
    long printflags;                    /* Print flags. */
    long more[11];                      /* Expansion space. */
    long songlist;                      /* For time-line stuff. */
    unsigned long clockcycles;          /* Time in clock cycles! */
    char useclip;                       /* Use the ClipBoard. */
    char externclock;                   /* External clock flag. */
    short timeroffset;                  /* For external clock. */
    long coordlist;
    struct Track *tracklist;            /* Top track in list. */
    struct Clip masterclip;             /* Master key, chord, signature. */
    struct Clip masterundo;
    struct Clip mastercut;
    struct Edit *masteredit;
    struct Tool *edittools[16];         /* 16 Tools to edit with. */
    unsigned short toolid;              /* Global tool id. */
    short groupid;                      /* Currently selected group. */
    struct Chord *scalelist;            /* All scales. */
    struct Chord *chordlist;            /* All chords. */
    struct Rhythm *rhythmlist;          /* All rhythms. */
    struct Section *sectionlist;        /* ABA list. */
    struct TempoChange *tempochangelist;/* Tempo Change list. */

    long whoops;                        /* Time line song list used to be here. */
    unsigned long frame;                /* Current frame. */
    unsigned long hirestime;            /* Hi res clock. */
    char version;
    long SysBase;                       /* Exec library. */
    long DOSBase;                       /* DOS library. */
    long IntuitionBase;
    long GfxBase;
    long LayersBase;
    long standardout;                   /* Ignore. */
    long pipequeue;                     /* Ignore. */
    long earlyqueue;                    /* Ignore. */
    struct Screen *screen;              /* Screen we all exist in. */
    struct Window *window;              /* Main (backdrop) window. */
    struct ToolMaster *toolmasterlist;  /* All ToolMasters. */
    struct Accessory *accesslist;       /* All Accessories. */
    struct Tool *midiouttool;           /* Tool to send MIDI clocks. */
    long (*stealmidi)();                /* Steal serial interrupt. */
    long (*releasemidi)();              /* Release MIDI. */

/*      New additions. */

    long (*audioclick)();               /* Play click sound. */

    struct Track *selectedtrack;        /* Track currently selected. */

    long flags;                         /* Additional flags. */
    long pad[74];                       /* Room for more. */

    long (*installtransportp)();        /* Install prioritized transport handler. */

    long (*fastgets)();                 /* fgets() */
    long (*fastseek)();                 /* Fast seek file io. */

    void (*adddisplayserver)();
    void (*removedisplayserver)();

    long (*dragtool)();
    void (*addtoolserver)();            /* Server for dragging tools. */
    void (*removetoolserver)();

    long (*editsysex)();                /* Open sysex requester. */
    struct Event *(*dupeevent)();       /* Duplicate an event. */

    long (*frametotime)();              /* Convert frame to time. */
    long (*timetoframe)();              /* Convert time to frame. */
    long (*frametohmsf)();              /* Convert frame to hmsf. */
    long (*hirestotime)();              /* Hires clock to time. */
    long (*timetohires)();              /* Time to hires. */
    long (*hirestoframe)();             /* Hires clock to frame. */
    long (*frametohires)();             /* Frame to hires clock. */

    long (*deletetool)();               /* Delete a tool. */
    long (*createtool)();               /* Allocate a new tool. */
    long (*sizetool)();                 /* Returns size prior to save. */
    long (*savetool)();                 /* Save a Tool to disk. */
    long (*loadtool)();                 /* Load a Tool from disk. */

    long (*gettoolmaster)();            /* Returns selected ToolMaster. */

/*      Old routines: */

    long (*processsmpteclock)();        /* Process a SMPTE event. */
    long (*processmidiclock)();         /* Process a MIDI clock event .*/
    long (*processsysex)();             /* Handle a sysex packet. */
    long (*processinputevent)();        /* Process a PipeLine input event. */

    long (*clearenvironment)();         /* Clear the environment. */
    long (*installenvironment)();       /* Replace the environment. */
    long (*loadsong)();
    long (*savesong)();

    long (*installtransport)();         /* Install transport handler. */
    long (*removetransport)();          /* Remove transport handler. */
    long (*transportcommand)();         /* Send command to handlers. */

    long (*qevent)();                   /* Put event in queue. */
    long (*allocevent)();               /* Allocate an event. */
    long (*fastallocevent)();           /* Allocate an event from interrupt. */
    long (*freeevent)();                /* Free an event. */
    long (*sorteventlist)();            /* Sort a list of events. */
    long (*freelist)();                 /* Free a list of events. */
    long (*dupelist)();                 /* Duplicate a list. */

    long (*allocstring)();              /* Allocate a string. */
    long (*freestring)();               /* Free a string. */
    long (*replacestring)();            /* Replace a string with another. */
    long (*dupestring)();               /* Duplicate a string. */
    long (*stringtext)();               /* Get string. */

    long (*clearclip)();                /* Clear a clip. */
    long (*dupeclip)();                 /* Duplicate a clip. */
    long (*cutclip)();                  /* Clip cut operation. */
    long (*copyclip)();                 /* Clip copy operation. */
    long (*pasteclip)();                /* Clip paste operation. */
    long (*mixclip)();                  /* Clip mix operation. */
    long (*loadclip)();                 /* Load a clip from disk. */
    long (*saveclip)();                 /* Save a clip. */
    long (*clipboard)();                /* Clipboard operation. */

    long (*createtrack)();              /* Create a track. */
    long (*deletetrack)();              /* Delete a track. */

    long (*myalloc)();                  /* Internal allocation routine. */
    long (*myfree)();                   /* Internal free routine. */

    long (*doscall)();                  /* Make a DOS command. */
    long (*fastopen)();                 /* Fast file open. */
    long (*fastwrite)();                /* Fast file write. */
    long (*fastread)();                 /* Fast file read. */
    long (*fastclose)();                /* Fast file close. */

    long (*popupkey)();
    long (*popupnote)();
    long (*popupoctave)();
    long (*popupchord)();
    long (*popuprhythm)();
    long (*popupscale)();

    long (*measuretotime)();
    long (*timetomeasure)();
    long (*totalbeatstotime)();
    long (*timetototalbeats)();
    long (*lengthtostring)();
    long (*stringtolength)();
    long (*timetostring)();
    long (*stringtotime)();
    long (*frametostring)();
    long (*stringtoframe)();
    long (*notetostring)();
    long (*stringtonote)();

    long (*noteinkey)();                /* Check for note in key. */
    long (*noteinchord)();              /* Check for note in chord. */
    long (*noteinrhythm)();             /* Align note with rhythm. */
    long (*timetokey)();
    long (*timetochord)();
    long (*timetodynamics)();
    long (*nextrhythmbeat)();
    long (*scaletotwelve)();
    long (*twelvetoscale)();
    long (*random)();                   /* Return random number. */

    long (*areyousure)();               /* Put up "are you sure?" requester. */
    long (*openwait)();                 /* Open wait requester. */
    long (*closewait)();                /* Close wait requester. */

    long (*display)();                  /* Display main window. */
    long (*ScrollingPopUpMenu)();
    long (*DragSlider)();
    long (*DrawSlider)();
/*      Inovatools 1 routines. */
    long (*Itoa)();
    long (*Atoi)();
    long (*RefreshGadget)();
    long (*GetGadget)();
    long (*GetStringInfo)();
    long (*SetStringInfo)();
    long (*GetStringInfoNumber)();
    long (*SetStringInfoNumber)();
    long (*GetPropInfo)();
    long (*SetPropInfo)();
    long (*GetSelectIntuiMessage)();
    long (*GetIntuiMessage)();
    long (*ClearIntuiMessages)();
    long (*GetMenu)();
    long (*GetMenuItem)();
    long (*CheckMenuItem)();
    long (*EnableMenuItem)();
    long (*EnableMenu)();
    long (*EnableGadget)();
    long (*SelectGadget)();
    long (*DupeNewWindow)();
    long (*DeleteNewWindow)();
    long (*DupeMenu)();
    long (*DeleteMenu)();
    long (*SendCloseWindow)();
    long (*List_Len)();
    long (*List_Position)();
    long (*List_Pred)();
    long (*List_Index)();
    long (*List_Cat)();
    long (*List_Insert)();
    long (*List_Remove)();
    long (*SetScrollBar)();
    long (*DrawList)();
    long (*ScrollList)();
    long (*SizeList)();
    long (*InitListInfo)();
    long (*RemoveListInfo)();
    long (*GetListItem)();
    long (*ClickList)();
    long (*InsertListItem)();
    long (*RemoveListItem)();
    long (*PopUpMenu)();
    long (*DragGadget)();
    long (*FileName)();
    long (*FlashyOpenWindow)();
    long (*FlashyCloseWindow)();
    long (*WhichWindow)();
    long (*DupeListInfo)();
    long (*DeleteListInfo)();
    long (*RealTimeScroll)();
    void (*EmbossOn)(struct Window *,short ,short );
    void (*EmbossOff)(struct Window *,short );
    void (*DrawEmbossed)(struct Window *,short );
    void (*EnableEmbossed)(struct Window *,short ,short );
    void (*SelectEmbossed)(struct Window *,short ,short );
    void (*ModifyEmbossedProp)(struct Window *,short,long,long,long,long,long,long);
    long (*DragEmbossedProp)(struct Window *,short );
    long (*DrawEmbossedProp)(struct Window *,short );
    long (*ShiftEmbossedPropOnce)(struct Window *,short,short,short );
    long (*ShiftEmbossedProp)(struct Window *,short,short ,short );
    long (*EmbossedPropOn)(struct Window *,short,long (*)(void),unsigned short ,
	 unsigned short );
    void (*FatEmbossedPropOn)(struct Window *,short ,short ,short ,
	long (*)(void),unsigned short ,char );
    void (*EmbossedPropOff)(struct Window *,short );
    void (*FatEmbossedPropOff)(struct Window *,short ,short ,short );
    void (*DrawEmbossedRect)(struct RastPort *,short ,short ,short ,short ,short );
    void (*DrawEmbossedWindow)(struct Window *,short );
    void (*EmbossWindowOff)(struct Window *);
    void (*EmbossWindowOn)(struct Window *,
	long ,char *,unsigned short ,unsigned short ,long (*)(void),long (*)(void));
    void (*EmbossRequestOn)(struct Window *,char *);
    void (*RefreshEmbossedWindowFrame)(struct Window *);
    int (*SystemGadgets)(struct Window *,long ,struct Gadget *,long);
    void (*ModifyWindowProps)(struct Window *,unsigned long ,unsigned long ,
	unsigned long ,unsigned long ,unsigned long ,unsigned long );
    void (*EmbossedWindowTitle)(struct Window *,char *);
    void (*EmbossedWindowText)(struct Window *,char *,short );
};

/* Media Madness Flags */

#define MMCMD_COPYALLFILES      0x0001  /* pass the path name to copy to */
#define MMCMD_INSTALLHITLIST    0x0002  /* no parameters */
#define MMCMD_CONVERTTOHIRES    0x0003  /* no parameters */
#define MMCMD_CONVERTFROMHIRES  0x0004  /* no parameters */


#define HITNAMESIZE   30

  struct HitName {
      struct HitName *next;             /* Linked list. */
      unsigned char note;               /* Equivalent MIDI value. */
      char name[HITNAMESIZE];           /* Text. */
  };

  typedef struct PatchNames {
      struct PatchNames *next;          /* Next in list. */
      char name[20];                    /* Name of list. */
      short usecount;                   /* # of tools using this. */
      unsigned char names[128][14];     /* Array of names. */
  } PatchNames;
