Csound Csound-dev Csound-tekno Search About

Re: fog code (take 3)

Date1998-04-17 10:47
Fromrasmus ekman
SubjectRe: fog code (take 3)
Code Spaz wrote:
> 
>         Could you perhaps cut'n'paste a couple of the surrounding lines for

Here's my present version of newpulse(), ie the last 50+ lines of Ugensa.c.
The new lines (with a more illuminating two-line comment than the one posted)
are 14-17 lines up from the last line (extra empty lines inserted before & after). 
Actually this comment+code could be inserted anywhere *after* the if-else block 
beginning at
    if (*p->kris >= onedsr && form != 0.0) {                /* init fnb ris */

Never mind, you won't need to work through the code to snip this.
Sorry for the hassle.

	re


static int newpulse(FOGS *p, OVERLAP *ovp, float  *amp,
                    float *fund, float *ptch)
{
    float	octamp = *amp, oct; 
    float	form = *ptch /sicvt, fogcvt = p->fogcvt;  /*added JMC for Fog*/
    long   rismps, newexp = 0;
    if ((ovp->timrem = (long)(*p->kdur * esr)) > p->durtogo)  /* ringtime    */
      return(0);
    if ((oct = *p->koct) > 0.0) {                   /* octaviation */
      long ioct = (long)oct, bitpat = ~(-1L << ioct);
      if (bitpat & ++p->fofcount)
        return(0);
      if ((bitpat += 1) & p->fofcount)
        octamp *= (1.0f + ioct - oct);
    }
    if (*fund == 0.0)                               /* formant phs */
      ovp->formphs = 0;
/* else ovp->formphs = (long)((p->fundphs * form / *fund) + p->spdphs) & PMASK; */
    else ovp->formphs = (long)(p->fundphs * form / *fund) & PMASK;
    ovp->forminc = (long)(*ptch * fogcvt);/*JMC for FOG*/
    /*ovp->forminc = *form * sicvt;*/
    if (*p->kband != p->prvband) {                    /* bw: exp dec */
      p->prvband = *p->kband;
      p->expamp = (float)exp(*p->kband * mpidsr);
      newexp = 1;
    }
    if (*p->kris >= onedsr && form != 0.0) {                /* init fnb ris */
      ovp->risphs = (unsigned long)(ovp->formphs / (fabs(form)) / *p->kris); /* JPff fix */
      ovp->risinc = (long)(sicvt / *p->kris);
      rismps = MAXLEN / ovp->risinc;
    }
    else {
      ovp->risphs = MAXLEN;
      rismps = 0;
    }

    /* p->spdphs (soundfile ftable index) must be added to 
       ovp->formphs (sound ftable reading rate) AFTER ovp-risphs is calculated */
    ovp->formphs = (ovp->formphs + p->spdphs) & PMASK;

    if (newexp || rismps != p->prvsmps) {            /* if new params */
      if (p->prvsmps = rismps)                     /*   redo preamp */
        p->preamp = (float)pow(p->expamp, -rismps);
      else p->preamp = 1.0f;
    }
    ovp->curamp = octamp * p->preamp;                /* set startamp  */
    ovp->expamp = p->expamp;
    if ((ovp->dectim = (long)(*p->kdec * esr)) > 0)          /*      fnb dec  */
      ovp->decinc = (long)(sicvt / *p->kdec);
    ovp->decphs = PMASK;
    return(1);
}