I barely need to say that I'm not an expert, but by a closer inspection I realized that most of the code is equivalent except that there is a notorious difference in the way the ampp array is indexed: 5.08 do { if (denom > FL(0.0002) || denom < -FL(0.0002)) { *ar++ = last = num / denom * scal; } else if (last<0) *ar++ = last = - *ampp; else *ar++ = last = *ampp; if (p->ampcod) scal = p->rsumr * *(++ampp); .... } while (--nn); 5.09: for (n=0;;) { ... if (denom > FL(0.0002) || denom < -FL(0.0002)) { ar[n] = last = num / denom * scal; } else if (last<0) ar[n] = last = - ampp[n]; else ar[n] = last = ampp[n]; .... if (++n>=nn) break; if (p->ampcod) scal = p->rsumr * ampp[n]; .... } Notice that in 5.08 ampp is advanced only if p->ampcod (I assume the condition means that in this case ampp is a-rate instead of i/k-rate). But in 5.09 n is incremented after each iteration, so ampp[n] will reference positions beyond 0 even if ampp is i/k-rate. I think this is causing the problem I experienced because replacing ampp[n] for ampp[0] gbuzz works fine for i-rate amps. One fix can be going back to 5.08 for the ampp stuff: 52c52 < ar[n] = last = - ampp[n]; --- > ar[n] = last = - *ampp; 54c54 < ar[n] = last = ampp[n]; --- > ar[n] = last = *ampp; 58c58 < scal = p->rsumr * ampp[n]; --- > scal = p->rsumr * *(++ampp) You have the last word. Regards -Carlos On Wed, Nov 5, 2008 at 12:07 PM, Carlos Pita wrote: > Hi, > > I've been having problems with gbuzz with kmul ~ 1. You can see the > details in my recent 'gbuzz with kmul = 1' posts to the users' list. I > noticed that the ill behavior only occurs in version 5.09 (both for > float and double samples). A diff for gbuzz function in ugens4.c > comparing .08 against .09 shows a number of recent changes. So I > replaced the .09 implementation with the old one and recompiled. That > fixed the issue. I've no time now to further isolate the specific > cause, I'll continue later. Following is the aforementioned diff. > > Regards > -Carlos > > < long phs, inc, lobits, lenmask, k, km1, kpn, kpnm1, nn; > < long n; > --- >> int32 phs, inc, lobits, lenmask, k, km1, kpn, kpnm1, nn; >> int32 n; > 9c9 > < long lphs = p->lphs; > --- >> int32 lphs = p->lphs; > 12,14c12 > < if (ftp==NULL) { > < return csound->PerfError(csound, Str("gbuzz: not initialised")); > < } > --- >> if (ftp==NULL) goto err1; > 20,21c18,19 > < k = (long)*p->kk; /* fix k and n */ > < if ((n = (long)*p->kn)<0) n = -n; > --- >> k = (int32)*p->kk; /* fix k and n */ >> if ((n = (int32)*p->kn)<0) n = -n; > 29c27 > < p->twor = r * FL(2.0); > --- >> p->twor = r + r; > 31c29 > < p->rtn = intpow(r, n); > --- >> p->rtn = intpowp(r, n); > 37c35 > < p->prvn = (short)n; > --- >> p->prvn = (int16)n; > 40c38 > < inc = (long)(*cpsp * csound->sicvt); > --- >> inc = (int32)(*cpsp * csound->sicvt); > 43c41 > < do { > --- >> for (n=0;;) { > 45,49c43,47 > < denom = p->rsqp1 - p->twor * *(ftbl + phs); > < num = *(ftbl + (phs * k & lenmask)) > < - r * *(ftbl + (phs * km1 & lenmask)) > < - p->rtn * *(ftbl + (phs * kpn & lenmask)) > < + p->rtnp1 * *(ftbl + (phs * kpnm1 & lenmask)); > --- >> denom = p->rsqp1 - p->twor * ftbl[phs]; >> num = ftbl[(phs * k & lenmask)] >> - r * ftbl[(phs * km1 & lenmask)] >> - p->rtn * ftbl[(phs * kpn & lenmask)] >> + p->rtnp1 * ftbl[(phs * kpnm1 & lenmask)]; > 51c49 > < *ar++ = last = num / denom * scal; > --- >> ar[n] = last = num / denom * scal; > 54c52 > < *ar++ = last = - *ampp; > --- >> ar[n] = last = - ampp[n]; > 56c54,56 > < *ar++ = last = *ampp; > --- >> ar[n] = last = ampp[n]; >> lphs = (lphs+inc) & PHMASK; >> if (++n>=nn) break; > 58,60c58 > < scal = p->rsumr * *(++ampp); > < lphs += inc; > < lphs &= PHMASK; > --- >> scal = p->rsumr * ampp[n]; > 62,63c60,61 > < inc = (long)(*(++cpsp) * csound->sicvt); > < } while (--nn); > --- >> inc = (int32)(cpsp[n] * csound->sicvt); >> } > 66a65,66 >> err1: >> return csound->PerfError(csound, Str("gbuzz: not initialised")); > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net