Пример #1
0
static ALvoid ALequalizerState_update(ALequalizerState *state, ALCdevice *device, const ALeffectslot *slot)
{
    ALfloat frequency = (ALfloat)device->Frequency;
    ALfloat gain = sqrtf(1.0f / device->NumChan) * slot->Gain;

    SetGains(device, gain, state->Gain);

    /* Calculate coefficients for the each type of filter */
    ALfilterState_setParams(&state->filter[0], ALfilterType_LowShelf,
                            sqrtf(slot->EffectProps.Equalizer.LowGain),
                            slot->EffectProps.Equalizer.LowCutoff/frequency,
                            0.0f);

    ALfilterState_setParams(&state->filter[1], ALfilterType_Peaking,
                            sqrtf(slot->EffectProps.Equalizer.Mid1Gain),
                            slot->EffectProps.Equalizer.Mid1Center/frequency,
                            slot->EffectProps.Equalizer.Mid1Width);

    ALfilterState_setParams(&state->filter[2], ALfilterType_Peaking,
                            sqrtf(slot->EffectProps.Equalizer.Mid2Gain),
                            slot->EffectProps.Equalizer.Mid2Center/frequency,
                            slot->EffectProps.Equalizer.Mid2Width);

    ALfilterState_setParams(&state->filter[3], ALfilterType_HighShelf,
                            sqrtf(slot->EffectProps.Equalizer.HighGain),
                            slot->EffectProps.Equalizer.HighCutoff/frequency,
                            0.0f);
}
Пример #2
0
static void
AVTunerMethodFunc( void         *ctx,
                   ComaMethodID  method,
                   void         *arg,
                   unsigned int  magic )
{
    int             ret;
    AVTuner        *tuner     = ctx;
    IComaComponent *component = tuner->component;

    switch (method) {
    case AV_TUNER_SETFREQUENCY:
        ret = SetFrequency( ctx, arg );
        break;

    case AV_TUNER_SETGAINS:
        ret = SetGains( ctx, arg );
        break;

    default:
        ret = DR_NOIMPL;
        break;
    }

    component->Return( component, ret, magic );
}
Пример #3
0
static ALvoid ALmodulatorState_update(ALmodulatorState *state, ALCdevice *Device, const ALeffectslot *Slot)
{
    ALfloat gain, cw, a;

    if(Slot->EffectProps.Modulator.Waveform == AL_RING_MODULATOR_SINUSOID)
        state->Waveform = SINUSOID;
    else if(Slot->EffectProps.Modulator.Waveform == AL_RING_MODULATOR_SAWTOOTH)
        state->Waveform = SAWTOOTH;
    else if(Slot->EffectProps.Modulator.Waveform == AL_RING_MODULATOR_SQUARE)
        state->Waveform = SQUARE;

    state->step = fastf2u(Slot->EffectProps.Modulator.Frequency*WAVEFORM_FRACONE /
                          Device->Frequency);
    if(state->step == 0) state->step = 1;

    /* Custom filter coeffs, which match the old version instead of a low-shelf. */
    cw = cosf(F_2PI * Slot->EffectProps.Modulator.HighPassCutoff / Device->Frequency);
    a = (2.0f-cw) - sqrtf(powf(2.0f-cw, 2.0f) - 1.0f);

    state->Filter.b[0] = a;
    state->Filter.b[1] = -a;
    state->Filter.b[2] = 0.0f;
    state->Filter.a[0] = 1.0f;
    state->Filter.a[1] = -a;
    state->Filter.a[2] = 0.0f;

    gain = sqrtf(1.0f/Device->NumChan) * Slot->Gain;
    SetGains(Device, gain, state->Gain);
}
Пример #4
0
static ALvoid ALdistortionState_update(ALdistortionState *state, ALCdevice *Device, const ALeffectslot *Slot)
{
    ALfloat frequency = (ALfloat)Device->Frequency;
    ALfloat bandwidth;
    ALfloat cutoff;
    ALfloat edge;
    ALfloat gain;

    /* Store distorted signal attenuation settings */
    state->attenuation = Slot->EffectProps.Distortion.Gain;

    /* Store waveshaper edge settings */
    edge = sinf(Slot->EffectProps.Distortion.Edge * (F_PI_2));
    edge = minf(edge, 0.99f);
    state->edge_coeff = 2.0f * edge / (1.0f-edge);

    /* Lowpass filter */
    cutoff = Slot->EffectProps.Distortion.LowpassCutoff;
    /* Bandwidth value is constant in octaves */
    bandwidth = (cutoff / 2.0f) / (cutoff * 0.67f);
    ALfilterState_setParams(&state->lowpass, ALfilterType_LowPass, 1.0f,
                            cutoff / (frequency*4.0f), bandwidth);

    /* Bandpass filter */
    cutoff = Slot->EffectProps.Distortion.EQCenter;
    /* Convert bandwidth in Hz to octaves */
    bandwidth = Slot->EffectProps.Distortion.EQBandwidth / (cutoff * 0.67f);
    ALfilterState_setParams(&state->bandpass, ALfilterType_BandPass, 1.0f,
                            cutoff / (frequency*4.0f), bandwidth);

    gain = sqrtf(1.0f / Device->NumChan) * Slot->Gain;
    SetGains(Device, gain, state->Gain);
}
Пример #5
0
static ALvoid ALcompressorState_update(ALcompressorState *state, ALCdevice *Device, const ALeffectslot *Slot)
{
    ALfloat gain;

    state->Enabled = Slot->EffectProps.Compressor.OnOff;

    gain = sqrtf(1.0f / Device->NumChan) * Slot->Gain;
    SetGains(Device, gain, state->Gain);
}
Пример #6
0
static ALvoid ALautowahState_update(ALautowahState *state, ALCdevice *device, const ALeffectslot *slot)
{
    ALfloat attackTime, releaseTime;
    ALfloat gain;

    attackTime = slot->EffectProps.Autowah.AttackTime * state->Frequency;
    releaseTime = slot->EffectProps.Autowah.ReleaseTime * state->Frequency;

    state->AttackRate = 1.0f / attackTime;
    state->ReleaseRate = 1.0f / releaseTime;
    state->PeakGain = slot->EffectProps.Autowah.PeakGain;
    state->Resonance = slot->EffectProps.Autowah.Resonance;

    gain = sqrtf(1.0f / device->NumChan) * slot->Gain;
    SetGains(device, gain, state->Gain);
}
Пример #7
0
// -----------------------------------------------------------------------------
// Implementation of the base class ChSteeringController
// -----------------------------------------------------------------------------
ChSteeringController::ChSteeringController()
    : m_dist(0), m_sentinel(0, 0, 0), m_target(0, 0, 0), m_err(0), m_errd(0), m_erri(0), m_collect(false), m_csv(NULL) {
    // Default PID controller gains all zero (no control).
    SetGains(0, 0, 0);
}