AEWavet.c++ 2.22 KB
/*****************************************************************************
 *  File:  AEWavet.c++ 
 *
 *  Implementation of AEWavet class
 ****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

#include "Assets.h"
#include "Mgrs.h"

/*****************************************************************************
 *
 *   Initialization Routines
 * 
 ****************************************************************************/
AEWavet::AEWavet()
{
    classType = AL_WAVETBL_CLASS;
    base = 0;
    length = 0;
    type = 0;
    flags = 0;
    loop = 0;
    book = 0;

    smplXRef = 0;

    assert(theU64Dev->AllocHdwr(this,AL_WAVETBL_CLASS) == 0);

}

AEWavet::~AEWavet()
{
    if(base)
        free(base);
    if(book)
        book->RemoveReference(this);
    if(loop)
        loop->RemoveReference(this);

    theU64Dev->DeallocHdwr(this);

}


/*****************************************************************************
 *
 *    Asset's Methods
 *
 ****************************************************************************/

void AEWavet::SetBase(char* b)
{
    base = b;
}

void AEWavet::SetLength(int l)
{
    length = l;
}

void AEWavet::SetType(int t)
{
    type = t;
}

void AEWavet::SetFlags(int f)
{
    flags = f;
}

char* AEWavet::GetBase(void)
{
    return base;
}

int AEWavet::GetLength(void)
{
    return length;
}

int AEWavet::GetType(void)
{
    return type;
}
int AEWavet::GetFlags(void)
{
    return flags;
}

void AEWavet::SetBook(AEBook *bookAsset)
{
    if(book)
        book->RemoveReference(this);
    bookAsset->AddReference(this);
    book = bookAsset;
}

void AEWavet::SetLoop(AELoop *loopAsset)
{
    if(loop)
        loop->RemoveReference(this);
    loopAsset->AddReference(this);
    loop = loopAsset;
}

AEBook* AEWavet::GetBook(void)
{
    return book;
}

AELoop* AEWavet::GetLoop(void)
{
    return loop;
}

int AEWavet::AllocSmpl(int slen)
{
    if(theU64Dev->AllocSmplMem(this,slen) != 0)
    {
        fprintf(stderr,"Failure allocating memory for sample data\n");
        return -1;
    }

    return 0;
}

void AEWavet::SetSmplXRef(void *xref)
{
    smplXRef = xref;
}

void* AEWavet::GetSmplXRef(void)
{
    return smplXRef;
}