コード例 #1
0
ファイル: Distorsion.cpp プロジェクト: beatwise/ZynWise
/*
 * Effect output
 */
void Distorsion::out(const Stereo<float *> &smp)
{
    int      i;
    REALTYPE l, r, lout, rout;

    REALTYPE inputvol = pow(5.0, (Pdrive - 32.0) / 127.0);
    if(Pnegate != 0)
        inputvol *= -1.0;

    if(Pstereo != 0) { //Stereo
        for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
            efxoutl[i] = smp.l[i] * inputvol * panning;
            efxoutr[i] = smp.r[i] * inputvol * (1.0 - panning);
        }
    }
    else {
        for(i = 0; i < SOUND_BUFFER_SIZE; i++)
            efxoutl[i] =
                (smp.l[i] * panning + smp.r[i] * (1.0 - panning)) * inputvol;
        ;
    }

    if(Pprefiltering != 0)
        applyfilters(efxoutl, efxoutr);

    //no optimised, yet (no look table)
    waveshapesmps(SOUND_BUFFER_SIZE, efxoutl, Ptype + 1, Pdrive);
    if(Pstereo != 0)
        waveshapesmps(SOUND_BUFFER_SIZE, efxoutr, Ptype + 1, Pdrive);

    if(Pprefiltering == 0)
        applyfilters(efxoutl, efxoutr);

    if(Pstereo == 0)
        for(i = 0; i < SOUND_BUFFER_SIZE; i++)
            efxoutr[i] = efxoutl[i];

    REALTYPE level = dB2rap(60.0 * Plevel / 127.0 - 40.0);
    for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
        lout = efxoutl[i];
        rout = efxoutr[i];
        l    = lout * (1.0 - lrcross) + rout * lrcross;
        r    = rout * (1.0 - lrcross) + lout * lrcross;
        lout = l;
        rout = r;

        efxoutl[i] = lout * 2.0 * level;
        efxoutr[i] = rout * 2.0 * level;
    }
}
コード例 #2
0
ファイル: OscilGen.cpp プロジェクト: AHudon/SOEN6471_LMMS
/*
 * Waveshape
 */
void OscilGen::waveshape()
{
    int i;

    oldwaveshapingfunction = Pwaveshapingfunction;
    oldwaveshaping = Pwaveshaping;
    if(Pwaveshapingfunction == 0)
        return;

    oscilFFTfreqs.c[0] = 0.0; //remove the DC
    //reduce the amplitude of the freqs near the nyquist
    for(i = 1; i < OSCIL_SIZE / 8; i++) {
        REALTYPE tmp = i / (OSCIL_SIZE / 8.0);
        oscilFFTfreqs.s[OSCIL_SIZE / 2 - i] *= tmp;
        oscilFFTfreqs.c[OSCIL_SIZE / 2 - i] *= tmp;
    }
    fft->freqs2smps(oscilFFTfreqs, tmpsmps);

    //Normalize
    REALTYPE max = 0.0;
    for(i = 0; i < OSCIL_SIZE; i++)
        if(max < fabs(tmpsmps[i]))
            max = fabs(tmpsmps[i]);
    if(max < 0.00001)
        max = 1.0;
    max = 1.0 / max;
    for(i = 0; i < OSCIL_SIZE; i++)
        tmpsmps[i] *= max;

    //Do the waveshaping
    waveshapesmps(OSCIL_SIZE, tmpsmps, Pwaveshapingfunction, Pwaveshaping);

    fft->smps2freqs(tmpsmps, oscilFFTfreqs); //perform FFT
}