Esempio n. 1
0
// This processes the reverb state, given the input samples and an output
// buffer.
static ALvoid VerbProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS])
{
    ALverbState *State = (ALverbState*)effect;
    ALuint index;
    ALfloat early[4], late[4], out[4];
    const ALfloat *panGain = State->Gain;
    (void)Slot;

    for(index = 0;index < SamplesToDo;index++)
    {
        // Process reverb for this sample.
        VerbPass(State, SamplesIn[index], early, late);

        // Mix early reflections and late reverb.
        out[0] = (early[0] + late[0]);
        out[1] = (early[1] + late[1]);
        out[2] = (early[2] + late[2]);
        out[3] = (early[3] + late[3]);

        // Output the results.
        SamplesOut[index][FRONT_LEFT]   += panGain[FRONT_LEFT]   * out[0];
        SamplesOut[index][FRONT_RIGHT]  += panGain[FRONT_RIGHT]  * out[1];
        SamplesOut[index][FRONT_CENTER] += panGain[FRONT_CENTER] * out[3];
        SamplesOut[index][SIDE_LEFT]    += panGain[SIDE_LEFT]    * out[0];
        SamplesOut[index][SIDE_RIGHT]   += panGain[SIDE_RIGHT]   * out[1];
        SamplesOut[index][BACK_LEFT]    += panGain[BACK_LEFT]    * out[0];
        SamplesOut[index][BACK_RIGHT]   += panGain[BACK_RIGHT]   * out[1];
        SamplesOut[index][BACK_CENTER]  += panGain[BACK_CENTER]  * out[2];
    }
}
Esempio n. 2
0
void process_eax_buffer(IDirectSoundBufferImpl *dsb, float *buf, DWORD count)
{
    int i;
    float* out;
    float gain;

    if (dsb->device->eax.volume == 0.0f)
        return;

    if (dsb->mix_channels > 1) {
        WARN("EAX not yet supported for non-mono sources\n");
        return;
    }

    if (dsb->eax.reverb_update) {
        dsb->eax.reverb_update = FALSE;
        ReverbUpdate(dsb);
    }

    out = HeapAlloc(GetProcessHeap(), 0, sizeof(float)*count*4);

    for (i = 0; i < count; i++) {
        VerbPass(dsb, buf[i], &out[i*4]);
    }

    if (dsb->eax.reverb_mix == EAX_REVERBMIX_USEDISTANCE)
        gain = 1.0f; /* FIXME - should be calculated from distance */
    else
        gain = dsb->eax.reverb_mix;

    for (i = 0; i < count; i++) {
        buf[i] += gain * out[i*4];
    }

    HeapFree(GetProcessHeap(), 0, out);
}