AeWaveFile.h 2.15 KB
#ifndef __AeWaveFile__
#define __AeWaveFile__


#include <stdio.h>
#include <dmedia/audiofile.h>
#include "aiffc.h"
#include "AeFile.h"


enum
{
    kAeFileTooManyLoops = -2000,
    kAeFileBadLoopVersion = -2001,
    kAeFileBadBookVersion = -2002,
    kAeFileBadMarker = -2003
};


class AeWaveAsset;
class AeRaw16WaveAsset;
class AeADPCMWaveAsset;
class AeLoopAsset;
class AeADPCMLoopAsset;
class AeADPCMBookAsset;
class AeKeymapAsset;


class AeWaveFile : public AeAssetFile
{
  public:
                        AeWaveFile (char *); 
    virtual	       	~AeWaveFile (void);
   
    virtual AeErr	ReadList (GList<AeAsset *> *&);
    virtual AeErr       Read (AeAsset *&);
    AeErr		ReadSampleData (char *& buffer, long & nbytes);

    AeWaveAsset *	GetWave (void) { return fWave; }
    AeKeymapAsset *	GetKeymap (void) { return fKeymap; }

    virtual void	ReportError (AeErr);

private:
    AeErr		afRead (void);
    AeErr		aeRead (void);
    
    AeErr		afReadSampleData (char *& buffer, long & nbytes);
    AeErr		aeReadSampleData (char *& buffer, long & nbytes);

    // routines using the Audio File library
    AeErr		newWaveAsset (AFfilehandle);
    AeErr		newKeymapAsset (void);

    void		afReadWaveParams (AFfilehandle, AeWaveAsset *);
    void		afReadInstParams (AFfilehandle);
    void		afReadRaw16Params (AFfilehandle, AeRaw16WaveAsset *);
    void		afReadADPCMParams (AFfilehandle, AeADPCMWaveAsset *);
    void		afReadLoop (AFfilehandle, AeLoopAsset *);
    void		afReadADPCMLoop (void *, AeADPCMLoopAsset *);
    void		afReadADPCMBook (void *, AeADPCMBookAsset *);
    void *		afReadPString (void *, char *&);
    long		afReadLong (void * data);
    short		afReadShort (void * data);

    // routines using custom parser
    void		aeReadInstParams (FILE *);
    void		aeReadLoop (AeLoopAsset * asset, Marker *, short nmarkers);
    void		aeReadADPCMLoop (FILE *, AeADPCMLoopAsset *);
    void		aeReadADPCMBook (FILE *, AeADPCMBookAsset *);
    void		aeReadMarkers (FILE *, Marker **, short *);
    char *		aeReadPString (FILE *);
    int		        findMarkerSample (long *, MarkerID, Marker *, int);

    AeWaveAsset *	fWave;
    AeKeymapAsset *	fKeymap;
    Loop		fLoop;
};


#endif