예제 #1
0
int
main()
{
	int i;
	struct boardmem x;
	if (initbbsinfo(&bbsinfo) < 0)
		return -1;
	shm_bcache = bbsinfo.bcacheshm;
	if (shm_bcache->number <= 0)
		return -1;
	initfilter(MY_BBS_HOME "/etc/filtertitle");
	srand(time(NULL));
	for (i = 0; i < shm_bcache->number; i++) {
		x = shm_bcache->bcache[i];
		if (!testperm(&x))
			continue;
		bzero(&lastmarklist[numlastmarkb], sizeof (lastmarklist[0]));
		strcpy(lastmarklist[numlastmarkb].board, x.header.filename);
		strcpy(lastmarklist[numlastmarkb].boardtitle, x.header.title);
		lastmarklist[numlastmarkb].bnum = i;
		lastmarklist[numlastmarkb].score = x.score;
		strsncpy(lastmarklist[numlastmarkb].sec1, x.header.sec1,
			 sizeof (lastmarklist[numlastmarkb].sec1));
		strsncpy(lastmarklist[numlastmarkb].sec2, x.header.sec2,
			 sizeof (lastmarklist[numlastmarkb].sec2));
		if (!(x.header.flag & CLOSECLUB_FLAG))
			readlastmark(&lastmarklist[numlastmarkb]);
		numlastmarkb++;
	}
	makeallseclastmark(&sectree);
	return 0;
}
//-------------------------------------------------------------------------------
void initializations(void)
{
initreferences();
initmatrices();
initbuffer();
initScrambler();
initTwindleMatrix();
initwindow();
initfilter();
}
예제 #3
0
파일: SUBnote.cpp 프로젝트: peter1000/Carla
void SUBnote::setup(float freq,
                    float velocity,
                    int portamento_,
                    int midinote,
                    bool legato)
{
    this->velocity = velocity;
    portamento  = portamento_;
    NoteEnabled = ON;
    volume      = powf(0.1f, 3.0f * (1.0f - pars.PVolume / 96.0f)); //-60 dB .. 0 dB
    volume     *= VelF(velocity, pars.PAmpVelocityScaleFunction);
    if(pars.PPanning != 0)
        panning = pars.PPanning / 127.0f;
    else
        panning = RND;
    if(!legato) {
        numstages = pars.Pnumstages;
        stereo    = pars.Pstereo;
        start     = pars.Pstart;
        firsttick = 1;
    }
    int pos[MAX_SUB_HARMONICS];

    if(pars.Pfixedfreq == 0)
        basefreq = freq;
    else {
        basefreq = 440.0f;
        int fixedfreqET = pars.PfixedfreqET;
        if(fixedfreqET) { //if the frequency varies according the keyboard note
            float tmp = (midinote - 69.0f) / 12.0f
                * (powf(2.0f, (fixedfreqET - 1) / 63.0f) - 1.0f);
            if(fixedfreqET <= 64)
                basefreq *= powf(2.0f, tmp);
            else
                basefreq *= powf(3.0f, tmp);
        }
    }
    int BendAdj = pars.PBendAdjust - 64;
    if (BendAdj % 24 == 0)
        BendAdjust = BendAdj / 24;
    else
        BendAdjust = BendAdj / 24.0f;
    float offset_val = (pars.POffsetHz - 64)/64.0f;
    OffsetHz = 15.0f*(offset_val * sqrtf(fabsf(offset_val)));
    float detune = getdetune(pars.PDetuneType,
                             pars.PCoarseDetune,
                             pars.PDetune);
    basefreq *= powf(2.0f, detune / 1200.0f); //detune
//    basefreq*=ctl.pitchwheel.relfreq;//pitch wheel

    //global filter
    GlobalFilterCenterPitch = pars.GlobalFilter->getfreq() //center freq
                              + (pars.PGlobalFilterVelocityScale / 127.0f
                                 * 6.0f)                                           //velocity sensing
                              * (VelF(velocity,
                                      pars.PGlobalFilterVelocityScaleFunction)
                                 - 1);

    if(!legato) {
        GlobalFilterL = NULL;
        GlobalFilterR = NULL;
        GlobalFilterEnvelope = NULL;
    }

    int harmonics = 0;

    //select only harmonics that desire to compute
    for(int n = 0; n < MAX_SUB_HARMONICS; ++n) {
        if(pars.Phmag[n] == 0)
            continue;
        pos[harmonics++] = n;
    }
    if(!legato)
        firstnumharmonics = numharmonics = harmonics;
    else {
        if(harmonics > firstnumharmonics)
            numharmonics = firstnumharmonics;
        else
            numharmonics = harmonics;
    }


    if(numharmonics == 0) {
        NoteEnabled = OFF;
        return;
    }


    if(!legato) {
        lfilter = memory.valloc<bpfilter>(numstages * numharmonics);
        if(stereo)
            rfilter = memory.valloc<bpfilter>(numstages * numharmonics);
    }

    //how much the amplitude is normalised (because the harmonics)
    float reduceamp = 0.0f;

    for(int n = 0; n < numharmonics; ++n) {
        float freq =  basefreq * pars.POvertoneFreqMult[pos[n]];
        overtone_freq[n] = freq;
        overtone_rolloff[n] = computerolloff(freq);

        //the bandwidth is not absolute(Hz); it is relative to frequency
        float bw =
            powf(10, (pars.Pbandwidth - 127.0f) / 127.0f * 4) * numstages;

        //Bandwidth Scale
        bw *= powf(1000 / freq, (pars.Pbwscale - 64.0f) / 64.0f * 3.0f);

        //Relative BandWidth
        bw *= powf(100, (pars.Phrelbw[pos[n]] - 64.0f) / 64.0f);

        if(bw > 25.0f)
            bw = 25.0f;

        //try to keep same amplitude on all freqs and bw. (empirically)
        float gain = sqrt(1500.0f / (bw * freq));

        float hmagnew = 1.0f - pars.Phmag[pos[n]] / 127.0f;
        float hgain;

        switch(pars.Phmagtype) {
            case 1:
                hgain = expf(hmagnew * logf(0.01f));
                break;
            case 2:
                hgain = expf(hmagnew * logf(0.001f));
                break;
            case 3:
                hgain = expf(hmagnew * logf(0.0001f));
                break;
            case 4:
                hgain = expf(hmagnew * logf(0.00001f));
                break;
            default:
                hgain = 1.0f - hmagnew;
        }
        gain      *= hgain;
        reduceamp += hgain;

        for(int nph = 0; nph < numstages; ++nph) {
            float amp = 1.0f;
            if(nph == 0)
                amp = gain;
            initfilter(lfilter[nph + n * numstages], freq + OffsetHz, bw,
                       amp, hgain);
            if(stereo)
                initfilter(rfilter[nph + n * numstages], freq + OffsetHz, bw,
                           amp, hgain);
        }
    }

    if(reduceamp < 0.001f)
        reduceamp = 1.0f;
    volume /= reduceamp;

    oldpitchwheel = 0;
    oldbandwidth  = 64;
    if(!legato) {
        if(pars.Pfixedfreq == 0)
            initparameters(basefreq);
        else
            initparameters(basefreq / 440.0f * freq);
    }
    else {
        if(pars.Pfixedfreq == 0)
            freq = basefreq;
        else
            freq *= basefreq / 440.0f;

        if(pars.PGlobalFilterEnabled) {
            globalfiltercenterq      = pars.GlobalFilter->getq();
            GlobalFilterFreqTracking = pars.GlobalFilter->getfreqtracking(
                basefreq);
        }
    }

    oldamplitude = newamplitude;
}
예제 #4
0
SUBnote::SUBnote(SUBnoteParameters *parameters,
                 Controller *ctl_,
                 REALTYPE freq,
                 REALTYPE velocity,
                 int portamento_,
                 int midinote,
                 bool besilent)
{
    ready=0;

    tmpsmp=new REALTYPE[SOUND_BUFFER_SIZE];
    tmprnd=new REALTYPE[SOUND_BUFFER_SIZE];

	this->velocity=velocity;
	this->freq = freq;

    // Initialise some legato-specific vars
    Legato.msg=LM_Norm;
    Legato.fade.length=(int)(SAMPLE_RATE*0.005);// 0.005 seems ok.
    if (Legato.fade.length<1) Legato.fade.length=1;// (if something's fishy)
    Legato.fade.step=(1.0/Legato.fade.length);
    Legato.decounter=-10;
    Legato.param.freq=freq;
    Legato.param.vel=velocity;
    Legato.param.portamento=portamento_;
    Legato.param.midinote=midinote;
    Legato.silent=besilent;

    pars=parameters;
    ctl=ctl_;
    portamento=portamento_;
    NoteEnabled=ON;
    volume=pow(0.1,3.0*(1.0-pars->PVolume/96.0));//-60 dB .. 0 dB
    volume*=VelF(velocity,pars->PAmpVelocityScaleFunction);
    if (pars->PPanning!=0) panning=pars->PPanning/127.0;
    else panning=RND;
    numstages=pars->Pnumstages;
    stereo=pars->Pstereo;
    start=pars->Pstart;
    firsttick=1;
    //int pos[MAX_SUB_HARMONICS];

    if (pars->Pfixedfreq==0) basefreq=freq;
    else {
        basefreq=440.0;
        int fixedfreqET=pars->PfixedfreqET;
        if (fixedfreqET!=0) {//if the frequency varies according the keyboard note
            REALTYPE tmp=(midinote-69.0)/12.0*(pow(2.0,(fixedfreqET-1)/63.0)-1.0);
            if (fixedfreqET<=64) basefreq*=pow(2.0f,tmp);
            else basefreq*=pow(3.0f,tmp);
        };

    };
    REALTYPE detune=getdetune(pars->PDetuneType,pars->PCoarseDetune,pars->PDetune);
    basefreq*=pow(2.0,detune/1200.0);//detune
//    basefreq*=ctl->pitchwheel.relfreq;//pitch wheel

    //global filter
    GlobalFilterCenterPitch=pars->GlobalFilter->getfreq()+//center freq
                            (pars->PGlobalFilterVelocityScale/127.0*6.0)* //velocity sensing
                            (VelF(velocity,pars->PGlobalFilterVelocityScaleFunction)-1);

    GlobalFilterL=NULL;
    GlobalFilterR=NULL;
    GlobalFilterEnvelope=NULL;

    //select only harmonics that desire to compute
    numharmonics=0;
    for (int n=0;n<MAX_SUB_HARMONICS;n++) {
        if (pars->Phmag[n]==0)continue;
        if (n*basefreq>SAMPLE_RATE/2.0) break;//remove the freqs above the Nyquist freq
        pos[numharmonics++]=n;
    };
    firstnumharmonics=numharmonics;//(gf)Useful in legato mode.

    if (numharmonics==0) {
        NoteEnabled=OFF;
        return;
    };


    lfilter=new bpfilter[numstages*numharmonics];
    if (stereo!=0) rfilter=new bpfilter[numstages*numharmonics];

    //how much the amplitude is normalised (because the harmonics)
    reduceamp=0.0;

    for (int n=0;n<numharmonics;n++) {

        REALTYPE freq=basefreq*(pos[n]+1);

        //the bandwidth is not absolute(Hz); it is relative to frequency
        REALTYPE bw=pow(10,(pars->Pbandwidth-127.0)/127.0*4)*numstages;

        //Bandwidth Scale
        bw*=pow(1000/freq,(float)((pars->Pbwscale-64.0)/64.0*3.0));

        //Relative BandWidth
        bw*=pow(100,(float)((pars->Phrelbw[pos[n]]-64.0)/64.0));

        if (bw>25.0) bw=25.0;

        //try to keep same amplitude on all freqs and bw. (empirically)
        gain=sqrt(1500.0/(bw*freq));

        hmagnew=1.0-pars->Phmag[pos[n]]/127.0;
        //hgain;

        switch (pars->Phmagtype) {
        case 1:
            hgain=exp(hmagnew*log(0.01));
            break;
        case 2:
            hgain=exp(hmagnew*log(0.001));
            break;
        case 3:
            hgain=exp(hmagnew*log(0.0001));
            break;
        case 4:
            hgain=exp(hmagnew*log(0.00001));
            break;
        default:
            hgain=1.0-hmagnew;
        };
        gain*=hgain;
        reduceamp+=hgain;

        for (int nph=0;nph<numstages;nph++) {
            REALTYPE amp=1.0;
            if (nph==0) amp=gain;
            initfilter(lfilter[nph+n*numstages],freq,bw,amp,hgain);
            if (stereo!=0) initfilter(rfilter[nph+n*numstages],freq,bw,amp,hgain);
        };
    };

    if (reduceamp<0.001) reduceamp=1.0;
    volume/=reduceamp;

    oldpitchwheel=0;
    oldbandwidth=64;
    if (pars->Pfixedfreq==0) initparameters(basefreq);
    else initparameters(basefreq/440.0*freq);

    oldamplitude=newamplitude;
    ready=1;
};
예제 #5
0
// SUBlegatonote: This function is (mostly) a copy of SUBnote(...) and
// initparameters(...) stuck together with some lines removed so that
// it only alter the already playing note (to perform legato). It is
// possible I left stuff that is not required for this.
void SUBnote::SUBlegatonote(REALTYPE freq,
                            REALTYPE velocity,
                            int portamento_,
                            int midinote,
                            bool externcall)
{
    //SUBnoteParameters *parameters=pars;
    //Controller *ctl_=ctl;

    // Manage legato stuff
    if (externcall) Legato.msg=LM_Norm;
    if (Legato.msg!=LM_CatchUp) {
        Legato.lastfreq=Legato.param.freq;
        Legato.param.freq=freq;
        Legato.param.vel=velocity;
        Legato.param.portamento=portamento_;
        Legato.param.midinote=midinote;
        if (Legato.msg==LM_Norm) {
            if (Legato.silent) {
                Legato.fade.m=0.0;
                Legato.msg=LM_FadeIn;
            } else {
                Legato.fade.m=1.0;
                Legato.msg=LM_FadeOut;
                return;
            }
        }
        if (Legato.msg==LM_ToNorm) Legato.msg=LM_Norm;
    }

    portamento=portamento_;
	this->freq = freq;

    volume=pow(0.1,3.0*(1.0-pars->PVolume/96.0));//-60 dB .. 0 dB
    volume*=VelF(velocity,pars->PAmpVelocityScaleFunction);
    if (pars->PPanning!=0) panning=pars->PPanning/127.0;
    else panning=RND;

    ///start=pars->Pstart;

    //int pos[MAX_SUB_HARMONICS];

    if (pars->Pfixedfreq==0) basefreq=freq;
    else {
        basefreq=440.0;
        int fixedfreqET=pars->PfixedfreqET;
        if (fixedfreqET!=0) {//if the frequency varies according the keyboard note
            REALTYPE tmp=(midinote-69.0)/12.0*(pow(2.0,(fixedfreqET-1)/63.0)-1.0);
            if (fixedfreqET<=64) basefreq*=pow(2.0f,tmp);
            else basefreq*=pow(3.0f,tmp);
        };
    };
    REALTYPE detune=getdetune(pars->PDetuneType,pars->PCoarseDetune,pars->PDetune);
    basefreq*=pow(2.0,detune/1200.0);//detune

    //global filter
    GlobalFilterCenterPitch=pars->GlobalFilter->getfreq()+//center freq
                            (pars->PGlobalFilterVelocityScale/127.0*6.0)* //velocity sensing
                            (VelF(velocity,pars->PGlobalFilterVelocityScaleFunction)-1);


    int legatonumharmonics=0;
    for (int n=0;n<MAX_SUB_HARMONICS;n++) {
        if (pars->Phmag[n]==0)continue;
        if (n*basefreq>SAMPLE_RATE/2.0) break;//remove the freqs above the Nyquist freq
        pos[legatonumharmonics++]=n;
    };
    if (legatonumharmonics>firstnumharmonics) numharmonics=firstnumharmonics;
    else numharmonics=legatonumharmonics;

    if (numharmonics==0) {
        NoteEnabled=OFF;
        return;
    };


    //how much the amplitude is normalised (because the harmonics)
    reduceamp=0.0;

    for (int n=0;n<numharmonics;n++) {

        REALTYPE freq=basefreq*(pos[n]+1);

        //the bandwidth is not absolute(Hz); it is relative to frequency
        REALTYPE bw=pow(10,(pars->Pbandwidth-127.0)/127.0*4)*numstages;

        //Bandwidth Scale
        bw*=pow(1000/freq,(float)((pars->Pbwscale-64.0)/64.0*3.0));

        //Relative BandWidth
        bw*=pow(100,(float)((pars->Phrelbw[pos[n]]-64.0)/64.0));

        if (bw>25.0) bw=25.0;

        //try to keep same amplitude on all freqs and bw. (empirically)
        gain=sqrt(1500.0/(bw*freq));

        hmagnew=1.0-pars->Phmag[pos[n]]/127.0;
        

        switch (pars->Phmagtype) {
        case 1:
            hgain=exp(hmagnew*log(0.01));
            break;
        case 2:
            hgain=exp(hmagnew*log(0.001));
            break;
        case 3:
            hgain=exp(hmagnew*log(0.0001));
            break;
        case 4:
            hgain=exp(hmagnew*log(0.00001));
            break;
        default:
            hgain=1.0-hmagnew;
        };
        gain*=hgain;
        reduceamp+=hgain;

        for (int nph=0;nph<numstages;nph++) {
            REALTYPE amp=1.0;
            if (nph==0) amp=gain;
            initfilter(lfilter[nph+n*numstages],freq,bw,amp,hgain);
            if (stereo!=0) initfilter(rfilter[nph+n*numstages],freq,bw,amp,hgain);
        };
    };

    if (reduceamp<0.001) reduceamp=1.0;
    volume/=reduceamp;

    oldpitchwheel=0;
    oldbandwidth=64;

    if (pars->Pfixedfreq==0) freq=basefreq;
    else freq*=basefreq/440.0;


    ///////////////
    // Altered initparameters(...) content:

    if (pars->PGlobalFilterEnabled!=0) {
        globalfiltercenterq=pars->GlobalFilter->getq();
        GlobalFilterFreqTracking=pars->GlobalFilter->getfreqtracking(basefreq);
    };

    // end of the altered initparameters function content.
    ///////////////

    oldamplitude=newamplitude;

    // End of the SUBlegatonote function.
};