AeInstAsset.c++ 5.19 KB
#include <assert.h>
#include <Vk/VkApp.h>

#include "AeAsset.h"
#include "GList.h"
#include "instIcon.xbm"


Pixmap AeInstAsset::fIcon = NULL;


AeInstAsset::AeInstAsset (const char * name, int volume, int pan, int priority,
			  int bendRange) : AeContainerAsset (name, kInstType)
{
    fVolume = volume;
    fPan = pan;
    fPriority = priority;
    fBendRange = bendRange;

    fTremType = kDefLFOType;
    fTremRate = kDefLFORate;
    fTremDepth = kDefLFODepth;
    fTremDelay = kDefLFODelay;

    fVibType = kDefLFOType;
    fVibRate = kDefLFORate;
    fVibDepth = kDefLFODepth;
    fVibDelay = kDefLFODelay;

    if (!fIcon)
    {
	fIcon = XCreateBitmapFromData (theApplication->display (),
				       DefaultRootWindow (theApplication->display ()),
				       (char *)instIcon_bits,
				       instIcon_width,
				       instIcon_height);
    }
}

AeInstAsset::~AeInstAsset (void)
{
    if (fParentList)
    {
	AeAsset *	parent;
	int		i;

	// nullify any references to this asset
	fParentList->Start (i, kReverse);
	while (fParentList->Prev (i, parent))
	{
	    if (((AeBankAsset *)parent)->GetPercussion () == this)
		((AeBankAsset *)parent)->SetPercussion (NULL);	
	}
    }
}


void
AeInstAsset::GetClassName (char * name)
{
    strcpy (name, "inst");
}


Boolean
AeInstAsset::IsParent (AeAsset * parent)
{
    assert (parent);
    return (((AeBankAsset *)parent)->GetPercussion () == this);
}


int
AeInstAsset::GetPatch (void)
{
    AeAsset *		parent;
    GList<AeAsset *> *	childList;
    int			patch = -1;

    assert (fParentList);

    if ((fParentList->GetNum() > 0) && (parent = (*fParentList)[0]))
    {
	assert (parent->CanContain ());

	childList = ((AeContainerAsset *)parent)->GetChildList ();
	if (childList->Find (this, patch))
	    patch++;				// make number one based
	else
	    patch = -1;
    }

    return patch;
}


int
AeInstAsset::GetPatchProc (AeAsset * asset)
{
    assert (asset != NULL);
    return ((AeInstAsset *)asset)->GetPatch ();
}

int
AeInstAsset::GetVolumeProc (AeAsset * asset)
{
    assert (asset != NULL);
    return ((AeInstAsset *)asset)->GetVolume ();
}

int
AeInstAsset::GetPanProc (AeAsset * asset)
{
    assert (asset != NULL);
    return ((AeInstAsset *)asset)->GetPan ();
}

int
AeInstAsset::GetPriorityProc (AeAsset * asset)
{
    assert (asset != NULL);
    return ((AeInstAsset *)asset)->GetPriority ();
}

int
AeInstAsset::GetBendRangeProc (AeAsset * asset)
{
    assert (asset != NULL);
    return ((AeInstAsset *)asset)->GetBendRange ();
}

int
AeInstAsset::GetTremTypeProc (AeAsset * asset)
{
    assert (asset != NULL);
    return ((AeInstAsset *)asset)->GetTremType ();
}

int
AeInstAsset::GetTremRateProc (AeAsset * asset)
{
    assert (asset != NULL);
    return ((AeInstAsset *)asset)->GetTremRate ();
}

int
AeInstAsset::GetTremDepthProc (AeAsset * asset)
{
    assert (asset != NULL);
    return ((AeInstAsset *)asset)->GetTremDepth ();
}

int
AeInstAsset::GetTremDelayProc (AeAsset * asset)
{
    assert (asset != NULL);
    return ((AeInstAsset *)asset)->GetTremDelay ();
}

int
AeInstAsset::GetVibTypeProc (AeAsset * asset)
{
    assert (asset != NULL);
    return ((AeInstAsset *)asset)->GetVibType ();
}

int
AeInstAsset::GetVibRateProc (AeAsset * asset)
{
    assert (asset != NULL);
    return ((AeInstAsset *)asset)->GetVibRate ();
}

int
AeInstAsset::GetVibDepthProc (AeAsset * asset)
{
    assert (asset != NULL);
    return ((AeInstAsset *)asset)->GetVibDepth ();
}

int
AeInstAsset::GetVibDelayProc (AeAsset * asset)
{
    assert (asset != NULL);
    return ((AeInstAsset *)asset)->GetVibDelay ();
}






void
AeInstAsset::SetVolumeProc (AeAsset * asset, int value)
{
    assert (asset != NULL);
    ((AeInstAsset *)asset)->SetVolume (value);
}

void
AeInstAsset::SetPanProc (AeAsset * asset, int value)
{
    assert (asset != NULL);
    ((AeInstAsset *)asset)->SetPan (value);
}

void
AeInstAsset::SetPriorityProc (AeAsset * asset, int value)
{
    assert (asset != NULL);
    ((AeInstAsset *)asset)->SetPriority (value);
}

void
AeInstAsset::SetBendRangeProc (AeAsset * asset, int value)
{
    assert (asset != NULL);
    ((AeInstAsset *)asset)->SetBendRange (value);
}

void
AeInstAsset::SetTremTypeProc (AeAsset * asset, int value)
{
    assert (asset != NULL);
    ((AeInstAsset *)asset)->SetTremType (value);
}

void
AeInstAsset::SetTremRateProc (AeAsset * asset, int value)
{
    assert (asset != NULL);
    ((AeInstAsset *)asset)->SetTremRate (value);
}

void
AeInstAsset::SetTremDepthProc (AeAsset * asset, int value)
{
    assert (asset != NULL);
    ((AeInstAsset *)asset)->SetTremDepth (value);
}

void
AeInstAsset::SetTremDelayProc (AeAsset * asset, int value)
{
    assert (asset != NULL);
    ((AeInstAsset *)asset)->SetTremDelay (value);
}

void
AeInstAsset::SetVibTypeProc (AeAsset * asset, int value)
{
    assert (asset != NULL);
    ((AeInstAsset *)asset)->SetVibType (value);
}

void
AeInstAsset::SetVibRateProc (AeAsset * asset, int value)
{
    assert (asset != NULL);
    ((AeInstAsset *)asset)->SetVibRate (value);
}

void
AeInstAsset::SetVibDepthProc (AeAsset * asset, int value)
{
    assert (asset != NULL);
    ((AeInstAsset *)asset)->SetVibDepth (value);
}

void
AeInstAsset::SetVibDelayProc (AeAsset * asset, int value)
{
    assert (asset != NULL);
    ((AeInstAsset *)asset)->SetVibDelay (value);
}