AudioApp.h 2.16 KB
/*
 * midiApp.h
 */
#ifndef _AE_AudioApp_h
#define _AE_AudioApp_h

#include <libaudio.h>
#include <dmedia/midi.h>
#include <audiotools.h>
#include <ramrom.h>
#include  "spec.h"



#define     MAX_MIDI_MSGS   16
#define     STATUS_TYPE     1
#define     SYSEX_TYPE      2


#define     WRITE_BLOCK         1
#define     WRITE_RAMROM        2
#define     INIT_AUDIO          3
#define     START_SEQUENCE      4
#define     SET_BANK            5 /* presumes all pointers are already set. */
#define     RESET_BANK          6 /* used when sequence is currently running */
#define     SET_FX_PARAM        7
#define     LOAD_BANKFILE       8
#define     LOAD_INST_VOL       9
#define     LOAD_INST_PAN       10
#define     LOAD_INST_PRIORITY  11
#define     LOAD_INST_BENDRANGE 12


#define  TRUE   1
#define  FALSE  0


#ifndef MIN
#define   MIN(a,b) (((a)<(b))?(a):(b))
#endif

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

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

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


typedef  struct
{
    int         pcktType;
    union {
	midiBlock    mb;
	SysExReq     sysr;
    } d;
} CommPckt;


typedef struct 
{
    ALLink      node;
    int         startAddr;
    u32         lastFrame;
    char        *ptr;
} DMABuffer;

typedef struct 
{
    u8          initialized;
    DMABuffer   *firstUsed;
    DMABuffer   *firstFree;

} DMAState;

/* 
 * The number of bytes needed to store a 16 byte aligned midiblock
 * and a 16 byte align u32.
 */

#define  CACHE_ALIGN_UP(a) ((a+15) & ~15)

#define  CACHE_ALIGN_DOWN(a) (a & ~15)

#define TRANSFER_SPACE_SIZE  (((sizeof(CommPckt)/16) + 3) * 16)

#define RDRAM_MEMORY_END     0x80300000

typedef  struct
{
    char           *audioHeap;
    int            heapSize;
    int            frameSize;       /* in samples per frame */
    int            maxCmdListSize; /* in commands, not bytes */
    int            numDMABuffs;   
    int            dmaBufSize;
    int            dmaQSize;
    int            frameLag;
    ALSynConfig    synConfig;
    ALSeqpConfig   seqpConfig;
} AudioConfig;

#endif