AeSoundAsset.c++ 2.88 KB
#include <assert.h>
#include <Vk/VkApp.h>

#include "AeAsset.h"
#include "sndIcon.xbm"


Pixmap AeSoundAsset::fIcon = NULL;


AeSoundAsset::AeSoundAsset (const char * name, int volume, int pan,
			    AeEnvAsset * envelope,
			    AeKeymapAsset * keymap,
			    AeWaveAsset * wave) :
    AeAsset (name, kSoundType)
{
    fVolume = volume;
    fPan = pan;
    fEnvelope = envelope;
    fKeymap = keymap;
    fWave = wave;

    if (!fIcon)
    {
	fIcon = XCreateBitmapFromData (theApplication->display (),
				       DefaultRootWindow (theApplication->display ()),
				       (char *)sndIcon_bits,
				       sndIcon_width,
				       sndIcon_height);
    }
}

AeSoundAsset::~AeSoundAsset (void)
{
    if (fEnvelope)
	fEnvelope->RemoveParent (this);

    if (fKeymap)
	fKeymap->RemoveParent (this);

    if (fWave)
	fWave->RemoveParent (this);
}


void
AeSoundAsset::GetClassName (char * name)
{
    strcpy (name, "sound");
}


void
AeSoundAsset::SetEnvelope (AeEnvAsset * envelope)
{
    if (fEnvelope)
	fEnvelope->RemoveParent (this);

    fEnvelope = envelope;

    if (fEnvelope)
	fEnvelope->AppendParent (this);
}


void
AeSoundAsset::SetKeymap (AeKeymapAsset * keymap)
{
    if (fKeymap)
	fKeymap->RemoveParent (this);

    fKeymap = keymap;

    if (fKeymap)
	fKeymap->AppendParent (this);
}


void
AeSoundAsset::SetWave (AeWaveAsset * wave)
{
    if (fWave)
	fWave->RemoveParent (this);

    fWave = wave;

    if (fWave)
	fWave->AppendParent (this);
}


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

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

AeAsset *
AeSoundAsset::GetEnvelopeProc (AeAsset * asset)
{
    assert (asset != NULL);
    return (AeAsset *)((AeSoundAsset *)asset)->GetEnvelope ();
}

AeAsset *
AeSoundAsset::GetKeymapProc (AeAsset * asset)
{
    assert (asset != NULL);
    return (AeAsset *)((AeSoundAsset *)asset)->GetKeymap ();
}

AeAsset *
AeSoundAsset::GetWaveProc (AeAsset * asset)
{
    assert (asset != NULL);
    return (AeAsset *)((AeSoundAsset *)asset)->GetWave ();
}

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

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

void
AeSoundAsset::SetEnvelopeProc (AeAsset * asset, AeAsset * envelope)
{
    assert (asset != NULL);
    ((AeSoundAsset *)asset)->SetEnvelope ((AeEnvAsset *)envelope);
}

void
AeSoundAsset::SetKeymapProc (AeAsset * asset, AeAsset * keymap)
{
    assert (asset != NULL);
    ((AeSoundAsset *)asset)->SetKeymap ((AeKeymapAsset *)keymap);
}

void
AeSoundAsset::SetWaveProc (AeAsset * asset, AeAsset * wave)
{
    assert (asset != NULL);
    ((AeSoundAsset *)asset)->SetWave ((AeWaveAsset *)wave);
}