Example #1
0
ALvoid LoadReverbPreset(const char *name, ALeffect *effect)
{
    size_t i;

    if(strcasecmp(name, "NONE") == 0)
    {
        InitEffectParams(effect, AL_EFFECT_NULL);
        TRACE("Loading reverb '%s'\n", "NONE");
        return;
    }

    if(!DisabledEffects[EAXREVERB])
        InitEffectParams(effect, AL_EFFECT_EAXREVERB);
    else if(!DisabledEffects[REVERB])
        InitEffectParams(effect, AL_EFFECT_REVERB);
    else
        InitEffectParams(effect, AL_EFFECT_NULL);
    for(i = 0;i < COUNTOF(reverblist);i++)
    {
        const EFXEAXREVERBPROPERTIES *props;

        if(strcasecmp(name, reverblist[i].name) != 0)
            continue;

        TRACE("Loading reverb '%s'\n", reverblist[i].name);
        props = &reverblist[i].props;
        effect->Props.Reverb.Density   = props->flDensity;
        effect->Props.Reverb.Diffusion = props->flDiffusion;
        effect->Props.Reverb.Gain   = props->flGain;
        effect->Props.Reverb.GainHF = props->flGainHF;
        effect->Props.Reverb.GainLF = props->flGainLF;
        effect->Props.Reverb.DecayTime    = props->flDecayTime;
        effect->Props.Reverb.DecayHFRatio = props->flDecayHFRatio;
        effect->Props.Reverb.DecayLFRatio = props->flDecayLFRatio;
        effect->Props.Reverb.ReflectionsGain   = props->flReflectionsGain;
        effect->Props.Reverb.ReflectionsDelay  = props->flReflectionsDelay;
        effect->Props.Reverb.ReflectionsPan[0] = props->flReflectionsPan[0];
        effect->Props.Reverb.ReflectionsPan[1] = props->flReflectionsPan[1];
        effect->Props.Reverb.ReflectionsPan[2] = props->flReflectionsPan[2];
        effect->Props.Reverb.LateReverbGain   = props->flLateReverbGain;
        effect->Props.Reverb.LateReverbDelay  = props->flLateReverbDelay;
        effect->Props.Reverb.LateReverbPan[0] = props->flLateReverbPan[0];
        effect->Props.Reverb.LateReverbPan[1] = props->flLateReverbPan[1];
        effect->Props.Reverb.LateReverbPan[2] = props->flLateReverbPan[2];
        effect->Props.Reverb.EchoTime  = props->flEchoTime;
        effect->Props.Reverb.EchoDepth = props->flEchoDepth;
        effect->Props.Reverb.ModulationTime  = props->flModulationTime;
        effect->Props.Reverb.ModulationDepth = props->flModulationDepth;
        effect->Props.Reverb.AirAbsorptionGainHF = props->flAirAbsorptionGainHF;
        effect->Props.Reverb.HFReference = props->flHFReference;
        effect->Props.Reverb.LFReference = props->flLFReference;
        effect->Props.Reverb.RoomRolloffFactor = props->flRoomRolloffFactor;
        effect->Props.Reverb.DecayHFLimit = props->iDecayHFLimit;
        return;
    }

    WARN("Reverb preset '%s' not found\n", name);
}
void DeferredRendering::LoadContent()
{
	//Load Effect
	m_DREffect->LoadMaterial(m_GraphicDevice);
	InitEffectParams();

	DrawableGameComponent::LoadContent();
}
Example #3
0
AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
{
    ALCcontext *Context;
    ALsizei i=0;

    Context = GetContextSuspended();
    if(!Context) return;

    if(n < 0 || IsBadWritePtr((void*)effects, n * sizeof(ALuint)))
        alSetError(Context, AL_INVALID_VALUE);
    else
    {
        ALCdevice *device = Context->Device;
        ALenum err;

        while(i < n)
        {
            ALeffect *effect = calloc(1, sizeof(ALeffect));
            if(!effect)
            {
                alSetError(Context, AL_OUT_OF_MEMORY);
                alDeleteEffects(i, effects);
                break;
            }

            effect->effect = ALTHUNK_ADDENTRY(effect);
            err = InsertUIntMapEntry(&device->EffectMap, effect->effect, effect);
            if(err != AL_NO_ERROR)
            {
                ALTHUNK_REMOVEENTRY(effect->effect);
                memset(effect, 0, sizeof(ALeffect));
                free(effect);

                alSetError(Context, err);
                alDeleteEffects(i, effects);
                break;
            }

            effects[i++] = effect->effect;
            InitEffectParams(effect, AL_EFFECT_NULL);
        }
    }

    ProcessContext(Context);
}
Example #4
0
File: alEffect.c Project: m64/PEG
AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
{
    ALCcontext *Context;
    ALsizei i;

    Context = alcGetCurrentContext();
    SuspendContext(Context);

    if (n > 0)
    {
        // Check that enough memory has been allocted in the 'effects' array for n Effects
        if (!IsBadWritePtr((void*)effects, n * sizeof(ALuint)))
        {
            ALeffect **list = &g_EffectList;
            while(*list)
                list = &(*list)->next;

            i = 0;
            while(i < n)
            {
                *list = calloc(1, sizeof(ALeffect));
                if(!(*list))
                {
                    // We must have run out or memory
                    alDeleteEffects(i, effects);
                    alSetError(AL_OUT_OF_MEMORY);
                    break;
                }

                effects[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
                (*list)->effect = effects[i];

                InitEffectParams(*list, AL_EFFECT_NULL);
                g_EffectCount++;
                i++;

                list = &(*list)->next;
            }
        }
    }

    ProcessContext(Context);
}
Example #5
0
File: alEffect.c Project: m64/PEG
AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue)
{
    ALCcontext *Context;

    Context = alcGetCurrentContext();
    SuspendContext(Context);

    if (effect && alIsEffect(effect))
    {
        ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);

        if(param == AL_EFFECT_TYPE)
        {
            if(iValue == AL_EFFECT_NULL ||
               iValue == AL_EFFECT_REVERB)
                InitEffectParams(ALEffect, iValue);
            else
                alSetError(AL_INVALID_VALUE);
        }
        else if(ALEffect->type == AL_EFFECT_REVERB)
        {
            switch(param)
            {
            case AL_REVERB_DECAY_HFLIMIT:
                if(iValue == AL_TRUE || iValue == AL_FALSE)
                    ALEffect->Reverb.DecayHFLimit = iValue;
                else
                    alSetError(AL_INVALID_VALUE);
                break;

            default:
                alSetError(AL_INVALID_ENUM);
                break;
            }
        }
        else
            alSetError(AL_INVALID_ENUM);
    }
    else
        alSetError(AL_INVALID_NAME);

    ProcessContext(Context);
}
Example #6
0
AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint value)
{
    ALCcontext *Context;
    ALCdevice  *Device;
    ALeffect   *ALEffect;

    Context = GetContextRef();
    if(!Context) return;

    Device = Context->Device;
    LockEffectList(Device);
    if((ALEffect=LookupEffect(Device, effect)) == NULL)
        alSetError(Context, AL_INVALID_NAME, "Invalid effect ID %u", effect);
    else
    {
        if(param == AL_EFFECT_TYPE)
        {
            ALboolean isOk = (value == AL_EFFECT_NULL);
            ALint i;
            for(i = 0;!isOk && i < EFFECTLIST_SIZE;i++)
            {
                if(value == EffectList[i].val &&
                   !DisabledEffects[EffectList[i].type])
                    isOk = AL_TRUE;
            }

            if(isOk)
                InitEffectParams(ALEffect, value);
            else
                alSetError(Context, AL_INVALID_VALUE, "Effect type 0x%04x not supported", value);
        }
        else
        {
            /* Call the appropriate handler */
            ALeffect_setParami(ALEffect, Context, param, value);
        }
    }
    UnlockEffectList(Device);

    ALCcontext_DecRef(Context);
}
Example #7
0
AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint value)
{
    ALCcontext *Context;
    ALCdevice  *Device;
    ALeffect   *ALEffect;

    Context = GetContextRef();
    if(!Context) return;

    Device = Context->Device;
    if((ALEffect=LookupEffect(Device, effect)) == NULL)
        alSetError(Context, AL_INVALID_NAME);
    else
    {
        if(param == AL_EFFECT_TYPE)
        {
            ALboolean isOk = (value == AL_EFFECT_NULL);
            ALint i;
            for(i = 0;!isOk && EffectList[i].val;i++)
            {
                if(value == EffectList[i].val &&
                   !DisabledEffects[EffectList[i].type])
                    isOk = AL_TRUE;
            }

            if(isOk)
                InitEffectParams(ALEffect, value);
            else
                alSetError(Context, AL_INVALID_VALUE);
        }
        else
        {
            /* Call the appropriate handler */
            V(ALEffect,setParami)(Context, param, value);
        }
    }

    ALCcontext_DecRef(Context);
}
Example #8
0
ALenum InitEffect(ALeffect *effect)
{
    InitEffectParams(effect, AL_EFFECT_NULL);
    return AL_NO_ERROR;
}
Example #9
0
static ALeffect *AllocEffect(ALCcontext *context)
{
    ALCdevice *device = context->Device;
    EffectSubList *sublist, *subend;
    ALeffect *effect = NULL;
    ALsizei lidx = 0;
    ALsizei slidx;

    almtx_lock(&device->EffectLock);
    sublist = VECTOR_BEGIN(device->EffectList);
    subend = VECTOR_END(device->EffectList);
    for(;sublist != subend;++sublist)
    {
        if(sublist->FreeMask)
        {
            slidx = CTZ64(sublist->FreeMask);
            effect = sublist->Effects + slidx;
            break;
        }
        ++lidx;
    }
    if(UNLIKELY(!effect))
    {
        const EffectSubList empty_sublist = { 0, NULL };
        /* Don't allocate so many list entries that the 32-bit ID could
         * overflow...
         */
        if(UNLIKELY(VECTOR_SIZE(device->EffectList) >= 1<<25))
        {
            almtx_unlock(&device->EffectLock);
            alSetError(context, AL_OUT_OF_MEMORY, "Too many effects allocated");
            return NULL;
        }
        lidx = (ALsizei)VECTOR_SIZE(device->EffectList);
        VECTOR_PUSH_BACK(device->EffectList, empty_sublist);
        sublist = &VECTOR_BACK(device->EffectList);
        sublist->FreeMask = ~U64(0);
        sublist->Effects = al_calloc(16, sizeof(ALeffect)*64);
        if(UNLIKELY(!sublist->Effects))
        {
            VECTOR_POP_BACK(device->EffectList);
            almtx_unlock(&device->EffectLock);
            alSetError(context, AL_OUT_OF_MEMORY, "Failed to allocate effect batch");
            return NULL;
        }

        slidx = 0;
        effect = sublist->Effects + slidx;
    }

    memset(effect, 0, sizeof(*effect));
    InitEffectParams(effect, AL_EFFECT_NULL);

    /* Add 1 to avoid effect ID 0. */
    effect->id = ((lidx<<6) | slidx) + 1;

    sublist->FreeMask &= ~(U64(1)<<slidx);
    almtx_unlock(&device->EffectLock);

    return effect;
}
Example #10
0
void InitEffect(ALeffect *effect)
{
    InitEffectParams(effect, AL_EFFECT_NULL);
}
Example #11
0
ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue)
{
    ALCcontext *Context;

    Context = alcGetCurrentContext();
    SuspendContext(Context);

    if (effect && alIsEffect(effect))
    {
        ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);

        if(param == AL_EFFECT_TYPE)
        {
            ALboolean isOk = (iValue == AL_EFFECT_NULL ||
                (iValue == AL_EFFECT_EAXREVERB && !DisabledEffects[EAXREVERB]) ||
                (iValue == AL_EFFECT_REVERB && !DisabledEffects[REVERB]) ||
                (iValue == AL_EFFECT_ECHO && !DisabledEffects[ECHO]));

            if(isOk)
                InitEffectParams(ALEffect, iValue);
            else
                alSetError(AL_INVALID_VALUE);
        }
        else if(ALEffect->type == AL_EFFECT_EAXREVERB)
        {
            switch(param)
            {
            case AL_EAXREVERB_DECAY_HFLIMIT:
                if(iValue >= AL_EAXREVERB_MIN_DECAY_HFLIMIT &&
                   iValue <= AL_EAXREVERB_MAX_DECAY_HFLIMIT)
                    ALEffect->Reverb.DecayHFLimit = iValue;
                else
                    alSetError(AL_INVALID_VALUE);
                break;

            default:
                alSetError(AL_INVALID_ENUM);
                break;
            }
        }
        else if(ALEffect->type == AL_EFFECT_REVERB)
        {
            switch(param)
            {
            case AL_REVERB_DECAY_HFLIMIT:
                if(iValue >= AL_REVERB_MIN_DECAY_HFLIMIT &&
                   iValue <= AL_REVERB_MAX_DECAY_HFLIMIT)
                    ALEffect->Reverb.DecayHFLimit = iValue;
                else
                    alSetError(AL_INVALID_VALUE);
                break;

            default:
                alSetError(AL_INVALID_ENUM);
                break;
            }
        }
        else if(ALEffect->type == AL_EFFECT_ECHO)
        {
            switch(param)
            {
            default:
                alSetError(AL_INVALID_ENUM);
                break;
            }
        }
        else
            alSetError(AL_INVALID_ENUM);
    }
    else
        alSetError(AL_INVALID_NAME);

    ProcessContext(Context);
}
Example #12
0
AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue)
{
    ALCcontext *Context;
    ALCdevice  *Device;
    ALeffect   *ALEffect;

    Context = GetContextSuspended();
    if(!Context) return;

    Device = Context->Device;
    if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
    {
        if(param == AL_EFFECT_TYPE)
        {
            ALboolean isOk = (iValue == AL_EFFECT_NULL ||
                (iValue == AL_EFFECT_EAXREVERB && !DisabledEffects[EAXREVERB]) ||
                (iValue == AL_EFFECT_REVERB && !DisabledEffects[REVERB]) ||
                (iValue == AL_EFFECT_ECHO && !DisabledEffects[ECHO]) ||
                (iValue == AL_EFFECT_RING_MODULATOR && !DisabledEffects[MODULATOR]));

            if(isOk)
                InitEffectParams(ALEffect, iValue);
            else
                alSetError(Context, AL_INVALID_VALUE);
        }
        else if(ALEffect->type == AL_EFFECT_EAXREVERB)
        {
            switch(param)
            {
            case AL_EAXREVERB_DECAY_HFLIMIT:
                if(iValue >= AL_EAXREVERB_MIN_DECAY_HFLIMIT &&
                   iValue <= AL_EAXREVERB_MAX_DECAY_HFLIMIT)
                    ALEffect->Reverb.DecayHFLimit = iValue;
                else
                    alSetError(Context, AL_INVALID_VALUE);
                break;

            default:
                alSetError(Context, AL_INVALID_ENUM);
                break;
            }
        }
        else if(ALEffect->type == AL_EFFECT_REVERB)
        {
            switch(param)
            {
            case AL_REVERB_DECAY_HFLIMIT:
                if(iValue >= AL_REVERB_MIN_DECAY_HFLIMIT &&
                   iValue <= AL_REVERB_MAX_DECAY_HFLIMIT)
                    ALEffect->Reverb.DecayHFLimit = iValue;
                else
                    alSetError(Context, AL_INVALID_VALUE);
                break;

            default:
                alSetError(Context, AL_INVALID_ENUM);
                break;
            }
        }
        else if(ALEffect->type == AL_EFFECT_ECHO)
        {
            switch(param)
            {
            default:
                alSetError(Context, AL_INVALID_ENUM);
                break;
            }
        }
        else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
        {
            switch(param)
            {
            case AL_RING_MODULATOR_FREQUENCY:
            case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
                alEffectf(effect, param, (ALfloat)iValue);
                break;

            case AL_RING_MODULATOR_WAVEFORM:
                if(iValue >= AL_RING_MODULATOR_MIN_WAVEFORM &&
                   iValue <= AL_RING_MODULATOR_MAX_WAVEFORM)
                    ALEffect->Modulator.Waveform = iValue;
                else
                    alSetError(Context, AL_INVALID_VALUE);
                break;

            default:
                alSetError(Context, AL_INVALID_ENUM);
                break;
            }
        }
        else
            alSetError(Context, AL_INVALID_ENUM);
    }
    else
        alSetError(Context, AL_INVALID_NAME);

    ProcessContext(Context);
}