Assets.h 7.54 KB

#ifndef _AE_Assets_h
#define _AE_Assets_h

#include <libaudio.h>
#include <audiotools.h>

#define REFERENCE_DATA   AL_NUM_CLASSES + 1
#define ALIGN8BYTE(a)    ((a+7) & ~7)

class Node 
{
  public:
    Node        *next;
    Node        *prev;                                 
    void        *data;

    Node();
};

class AssetNode : public Node
{
  public:
    int        dataType;
    
    AssetNode();
};


class List 
{
  public:    
    Node        *head;
    Node        *tail;
    int         count;    

    List();
    
    Node*  Append(void *data);  // creates a node
    Node*  Prepend(void *data); // creates a node
    void   Remove(Node *node);  // deletes the node
    void   Unhook(Node *node);  // leaves node intact

};

class RefList : public List
{
  public:
    int    RemoveByData(void *data); // deletes the node

};

class AssetList : public RefList
{
  public:
    Node*  Append(void *data, int assetType);  // creates a node
    Node*  Prepend(void *data, int assetType); // creates a node
};

class AEAsset
{
  private:
    RefList   *refList;
    void      *hdwrXRef;
    char      *name;

  public:
    int       classType;
    Node      *AssetMgrNode;

    AEAsset();
    ~AEAsset();

    void    SetName(char *name);
    char*   GetName(void);

    void    AddReference(AEAsset *asset);
    void    RemoveReference(AEAsset *asset);
    int     GetRefCt(void);

    void    SetHdwrXRef(void*);
    void*   GetHdwrXRef(void);
    int     GetClass(void);
};

class AEReverb
{
  private:
    int     type;
    s32     *params;
    int     maxParam;
  public:
    AEReverb();
    ~AEReverb();

    void    SetType(int t);
    int     GetType(void);
    void    AllocParamBuf(int numSections);
    s32*    GetParamBuf(void);
    void    SetParam(int index, s32 value);
    int     GetParam(int index, s32 *value);
};

typedef struct {
    char   *name;
    AEAsset  *asset;
} AssetPair;


class AEBook : public AEAsset
{
  private:
    int     order;
    int     npredictors;
    short   *bookData;
    
  public:
    AEBook();
    ~AEBook();

    void    SetBook(int ord, int npds, short *data);
    int     GetOrder(void);
    int     GetNPredictors(void);
    int     GetBookData(short *data);
    int     GetNumBookItems(void);
    
};

class AELoop : public AEAsset
{
  private:
    int          start;
    int          count;
    int          end;
    ADPCM_STATE  state;

  public:
    AELoop();
    ~AELoop();
    
    void    SetStart(int s);
    void    SetEnd(int e);
    void    SetCount(int c);
    void    SetState(short *st);

    int     GetStart(void);
    int     GetEnd(void);
    int     GetCount(void);
    void    GetState(short *st);

};

class AEWavet : public AEAsset
{
  private:
    AEBook        *book;
    AELoop        *loop;
    char          *base;    
    int           length;
    int           type;
    int           flags;
    void          *smplXRef;
    
  public:
    AEWavet();
    ~AEWavet();

    void      SetBase(char* base);
    void      SetLength(int len);
    void      SetType(int type);
    void      SetFlags(int flags);
    char*     GetBase(void);
    int       GetLength(void);
    int       GetType(void);
    int       GetFlags(void);

    void      SetBook(AEBook *bookAsset);
    void      SetLoop(AELoop *loopAsset);
    AEBook*   GetBook(void);
    AELoop*   GetLoop(void);

    void      SetSmplXRef(void *xref);
    void*     GetSmplXRef(void);
    int       AllocSmpl(int slen);
    void      DeallocSmpl(void);
};

class AEKeymap : public AEAsset
{
  private:
    int     velocityMin;
    int     velocityMax;
    int     keyMin;
    int     keyMax;
    int     keyBase;
    int     detune;
    
  public:
    AEKeymap();
    ~AEKeymap();
    
    void    SetVelMin(int vel);
    void    SetVelMax(int vel);
    void    SetKeyMin(int key);
    void    SetKeyMax(int key);
    void    SetKeyBase(int key);
    void    SetDetune(int detune);

    int     GetVelMin(void);
    int     GetVelMax(void);
    int     GetKeyMin(void);
    int     GetKeyMax(void);
    int     GetKeyBase(void);
    int     GetDetune(void);

};

class AEEnvlp : public AEAsset
{
  private:
    int     attackTime;
    int     attackLevel;
    int     decayTime;
    int     decayLevel;
    int     releaseTime;
  
  public:
    AEEnvlp();
    ~AEEnvlp();
    
    void    SetAttackTime(int time);
    void    SetAttackLevel(int level);
    void    SetDecayTime(int time);
    void    SetDecayLevel(int level);
    void    SetReleaseTime(int time);

    int     GetAttackTime(void);
    int     GetAttackLevel(void);
    int     GetDecayTime(void);
    int     GetDecayLevel(void);
    int     GetReleaseTime(void);

};

class AESound : public AEAsset
{
  private:
    int          samplePan;
    int          sampleVolume;
    int          flags;
    AEKeymap     *keymap;
    AEEnvlp      *envlp;
    AEWavet      *wavet;

  public:
    AESound();
    ~AESound();

    void    SetPan(int pan);
    void    SetVol(int vol);
    void    SetFlags(int flags);
    void    SetKeymap(AEKeymap *kmap);
    void    SetEnvlp(AEEnvlp *env);
    void    SetWavet(AEWavet *wvt);

    int        GetPan(void);
    int        GetVol(void);
    int        GetFlags(void);
    AEKeymap*  GetKeymap(void);
    AEEnvlp*   GetEnvlp(void);
    AEWavet*   GetWavet(void);

};

class AEInst : public AEAsset
{
  private:   
    int      volume;
    int      pan;
    int      priority;
    int      flags;
    int      tremType;
    int      tremRate;
    int      tremDepth;
    int      tremDelay;
    int      vibType;
    int      vibRate;
    int      vibDepth;
    int      vibDelay;
    int      bendRange;
    RefList  *soundList;

  public:
    AEInst();
    ~AEInst();

    void    AddSound(AESound *sound);
    void    RemoveSound(AESound *sound);
    
    void    SetVol(int vol);
    void    SetPan(int pan);
    void    SetPriority(int priority);
    void    SetBendRange(int bendRange);
    void    SetFlags(int flags);
    void    SetTremType(int tremType);
    void    SetTremRate(int tremRate);
    void    SetTremDepth(int tremDepth);
    void    SetTremDelay(int tremDelay);
    void    SetVibType(int vibType);
    void    SetVibRate(int vibRate);
    void    SetVibDepth(int vibDepth);
    void    SetVibDelay(int vibDelay);

    int     GetVol(void);
    int     GetPan(void);
    int     GetPriority(void);
    int     GetFlags(void);
    int     GetBendRange(void);
    int     GetTremType(void);
    int     GetTremRate(void);
    int     GetTremDepth(void);
    int     GetTremDelay(void);
    int     GetVibType(void);
    int     GetVibRate(void);
    int     GetVibDepth(void);
    int     GetVibDelay(void);

    AssetPair* GetSounds(int  *numSounds);
    int      GetNumSounds(void);
    
};

class AEBank : public AEAsset
{
  private:
    int      flags;
    int      sampleRate;
    RefList  *instList;
    AEInst   *percussion;

  public:
    AEBank();
    ~AEBank();

    void    AddInstrument(AEInst *inst);
    void    RemoveInstrument(AEInst *inst);

    void    SetPercussion(AEInst *inst);
    void    SetSampleRate(int sampleRate);
    void    SetFlags(int flags);

    AEInst* GetPercussion(void);
    int     GetSampleRate(void);
    int     GetFlags(void);

    AssetPair* GetInstruments(int *numInsts);
    int      GetNumInsts(void);
    
};


class AEBankFile : public AEAsset
{
  private:
    int       revision;
    RefList   *bankList;
    
  public:
    AEBankFile();
    ~AEBankFile();

    void      AddBank(AEBank *bank);
    void      RemoveBank(AEBank *bank);
    AssetPair*  GetBanks(int *numBanks);
    void      SetRevision(int rev);
    int       GetRevision(void);
    int       GetNumBanks(void);
    
};

#endif