previous mod was techincally incorrect, this one should be better (but might still be buggy?)

svn-id: r9408
This commit is contained in:
Max Horn 2003-08-02 11:38:23 +00:00
parent 36d7287960
commit d00a9923cc

View File

@ -144,7 +144,7 @@ int st_rate_flow(eff_t effp, AudioInputStream &input, st_sample_t *obuf, st_size
resume:
// Loop as long as the outpos trails behind, and as long as there is
// still space in the output buffer.
while (rate->ipos > rate->opos && obuf < oend) {
while (rate->ipos > rate->opos) {
// interpolate
out = (st_sample_t) (ilast[0] + (((icur[0] - ilast[0]) * rate->opos_frac + (1UL << (FRAC_BITS-1))) >> FRAC_BITS));
@ -168,6 +168,9 @@ resume:
tmp = rate->opos_frac + rate->opos_inc_frac;
rate->opos = rate->opos + rate->opos_inc + (tmp >> FRAC_BITS);
rate->opos_frac = tmp & ((1UL << FRAC_BITS) - 1);
if (obuf < oend)
goto the_end;
}
// Increment input position again (for the sample we read now)
@ -179,13 +182,11 @@ resume:
the_end:
*osamp = (obuf - ostart) / 2;
if (!input.eof()) {
rate->ilast[0] = ilast[0];
rate->icur[0] = input.read();
if (stereo) {
rate->ilast[1] = ilast[1];
rate->icur[1] = input.read();
}
rate->ilast[0] = ilast[0];
rate->icur[0] = icur[0];
if (stereo) {
rate->ilast[1] = ilast[1];
rate->icur[1] = icur[1];
}
return (ST_SUCCESS);
}