midiApp.h 5.73 KB
/*
 * midiApp.h
 */




#define	STACKSIZE	0x1000

#ifdef _LANGUAGE_C

#include <audiotools.h>

#define MAX_VOICES          32
#define MAX_SEQ_CHANNELS    16
#define MAX_BUFFER_LENGTH   1024
#define DMA_QUEUE_SIZE      50
#define MAX_UPDATES         128
#define MAX_SEQP_EVENTS     128
#define FX_BUFFER_SIZE      8192
#define AUDIO_HEAP_SIZE     400000
#define MAX_CLIST_SIZE      5000
#define MAX_AUDIO_LENGTH    640
#define OUTPUT_RATE         44100
#define FRAME_SIZE          320 /* Best if a multiple of 160 */

#define     MAX_PORTS    4
#define     MAX_MSGS     16

#define     STATUS_TYPE  1
#define     SYSEX_TYPE   2

#define     GET_OFFSET  20
#define     GET_8       21
#define     GET_16      22
#define     GET_32      23
#define     SET_8       24 
#define     SET_16      25 
#define     SET_32      26
#define     GET_BLOCK   27


#define  TRUE   1
#define  FALSE  0

typedef struct {
    char    commandID;
    char    channel;
    char    *data;
    char    *parameter;
    double  dvalue;
    char    cvalue;
    void    *avalue;
} SysexRecord;

typedef  struct
{
    unsigned char  midiByte[4];
} midiMess;

typedef  struct
{
    int         pcktType;
    int         numEvts;
    midiMess    mess[MAX_MSGS];
} midiBlock;

typedef  struct
{
    int         pcktType;
    int         reqType;
    int         offset;
    int         value;
} SysExReq;

typedef struct {
    u32     validFlag;
    char    *fileName;
} ALRamRomObj;

typedef struct {
    ALSymFileObj    SFObj;
    int             deleteFlag;
    char            *data;
    union {
        int         allocInsts;
        int         allocSnds;
        ALRamRomObj *ramromObj;
        int         value;
    } allocCts;
} ALSymObj;

typedef struct { char array[32]; }array32;


void ReadFiles(char *fileName);
ALSymObj *MatchHashName(char *name);
char *BuildClassList(int class);
char *BuildInstList(char *name);
char *BuildSoundList(char *name);
char *GetStrFromOffset(u32 offset);
void GetBlock(u32 offset,char *blockBuf,int numBytes);
void DecRefCtFromOffset(u32 offset);
int mdInit(void);
void ProcessSysEx(int whichMsg);

void AckPresent(char *param);

void HandleGetString(char *param,int strType);
void HandleGetNumber(char *param,int strType);
void HandleSetString(char *param,int strType,char *data);
void HandleSetNumber(char *param,int strType,double dvalue);

void HandleGetBank(char *param);
void HandleSetBank(char *param,char *data,double dvalue);
void HandleGetInst(char *param);
void HandleSetInst(char *param,char *data,double dvalue);
void HandleGetSnd(char *param);
void HandleSetSnd(char *param,char *data,double dvalue);
void HandleGetEnvlp(char *param);
void HandleSetEnvlp(char *param,double dvalue);
void HandleGetKmap(char *param);
void HandleSetKmap(char *param,double dvalue);

int CheckString(char **requestStr, array32 *list, int maxStr);
void SendClassList(int class, char *param);
void SendSoundList(char *param);
void SendInstList(char *param);
void SetValue(u32 offset,int type,u32 value);
void ReplyValue(char *param,u32 value);
void ReplyString(char *param,char *ptr);
u32 GetValue(u32 offset,int type);
char *parsename(char *name,char *nameStr);
int GetNumber(char **hdl);
void CreateBankObj(char *param,char *data);
void CreateInstObj(char *param,char *data);
void CreateSndObj(char *param,char *data);
void CreateKmapObj(char *param,char *data);
void CreateEnvlpObj(char *param,char *data);
void CreateWavetblObj(char *param,char *data);
void DeleteObject(char *name);
ALSymObj *SymObjFromOffset(u32 offset);
void CheckMemory(int mirrorSize);
void CompactMirror(void);
u32 AddName(char *str);
int AddHash(char *str, ALSymObj *obj);

#define NO_CLASS        0
#define BANK_CLASS      1
#define INST_CLASS      2
#define SOUND_CLASS     3
#define KEYMAP_CLASS    4
#define WAVETBL_CLASS   5
#define LOOP_CLASS      6
#define BNKFILE_CLASS   7
#define ENVLP_CLASS     8
#define BOOK_CLASS      9
#define SNDFILE_CLASS   10


#define MAX_BANK_STRS        5
#define BANK_INST_STR_LEN    10
#define BANK_PERC_PARAM      1
#define BANK_INST_CT_PARAM   2
#define BANK_RATE_PARAM      3
#define BANK_INST_PARAM      4
#define BANK_ALLOC_PARAM     5


#define MAX_INST_STRS        6
#define INST_SND_STR_LEN     5
#define INST_VOLUME_PARAM    1
#define INST_PAN_PARAM       2
#define INST_PRIOR_PARAM     3
#define INST_SNDCOUNT_PARAM  4
#define INST_SNDARRAY_PARAM  5
#define INST_ALLOC_PARAM     6


#define MAX_SOUND_STRS       5
#define SND_SAMPLE_PARAM     1
#define SND_KEYMAP_PARAM     2
#define SND_ENVLP_PARAM      3
#define SND_PAN_PARAM        4
#define SND_VOLUME_PARAM     5


#define MAX_ENVLP_STRS       5
#define ENVLP_ATTCK_TIME     1
#define ENVLP_ATTCK_LVL      2
#define ENVLP_DECAY_TIME     3
#define ENVLP_DECAY_LVL      4
#define ENVLP_REL_TIME       5


#define MAX_KMAP_STRS        6
#define KMAP_VEL_MIN         1
#define KMAP_VEL_MAX         2
#define KMAP_KEY_MIN         3
#define KMAP_KEY_MAX         4
#define KMAP_KEYBASE         5
#define KMAP_DETUNE          6

#define CREATE_BANK_STR_LEN     11
#define CREATE_INST_STR_LEN     17
#define CREATE_SND_STR_LEN      12
#define CREATE_ENVLP_STR_LEN    15
#define CREATE_KMAP_STR_LEN     13
#define CREATE_WAVETBL_STR_LEN  16
#define DELETE_BANK_STR_LEN     11
#define DELETE_INST_STR_LEN     17
#define DELETE_SND_STR_LEN      12
#define DELETE_ENVLP_STR_LEN    15
#define DELETE_KMAP_STR_LEN     13
#define DELETE_WAVETBL_STR_LEN  16


/*
 * Symbol generated by "makerom" to indicate the end of the code segment
 * in virtual (and physical) memory
 */
extern char _codeSegmentEnd[];

/*
 * Symbols generated by "makerom" to tell us where the segments are
 * in ROM.
 */
extern char _seqSegmentRomStart[], _seqSegmentRomEnd[];
extern char _midibankSegmentRomStart[], _midibankSegmentRomEnd[];
extern char _miditableSegmentRomStart[], _miditableSegmentRomEnd[];


#endif