added CopyRateConverter (used if inrate == outrate)

svn-id: r9214
This commit is contained in:
Max Horn 2003-07-28 01:50:46 +00:00
parent 9865deb0bc
commit 81baae7ddc
3 changed files with 22 additions and 10 deletions

View file

@ -107,7 +107,7 @@ int st_rate_flow(eff_t effp, AudioInputStream &input, st_sample_t *obuf, st_size
ilast[i] = rate->ilast[i];
ostart = obuf;
oend = obuf + *osamp;
oend = obuf + *osamp * 2;
while (obuf < oend && !input.eof()) {
@ -159,7 +159,7 @@ int st_rate_flow(eff_t effp, AudioInputStream &input, st_sample_t *obuf, st_size
}
the_end:
*osamp = obuf - ostart;
*osamp = (obuf - ostart) / 2;
for (i = 0; i < channels; i++)
rate->ilast[i] = ilast[i];
return (ST_SUCCESS);

View file

@ -81,4 +81,24 @@ public:
virtual int drain(st_sample_t *obuf, st_size_t *osamp, st_volume_t vol);
};
class CopyRateConverter : public RateConverter {
public:
virtual int flow(AudioInputStream &input, st_sample_t *obuf, st_size_t *osamp, st_volume_t vol) {
int16 tmp;
st_size_t len = *osamp;
while (!input.eof() && len--) {
tmp = input.read() * vol / 256;
clampedAdd(*obuf++, tmp);
if (input.isStereo())
tmp = input.read() * vol / 256;
clampedAdd(*obuf++, tmp);
}
return (ST_SUCCESS);
}
virtual int drain(st_sample_t *obuf, st_size_t *osamp, st_volume_t vol) {
return (ST_SUCCESS);
}
};
#endif

View file

@ -268,11 +268,7 @@ int st_resample_flow(eff_t effp, AudioInputStream &input, st_sample_t *obuf, st_
long Nout = 0; // The number of bytes we effectively output
long Nx; // The number of bytes we will read from input
long Nproc; // The number of bytes we process to generate Nout output bytes
#if 1 // FIXME: Hack to generate stereo output
const long obufSize = *osamp / 2;
#else
const long obufSize = *osamp;
#endif
TODO: adjust for the changes made to AudioInputStream; add support for stereo
initially, could just average the left/right channel -> bad for quality of course,
@ -394,11 +390,7 @@ printf("osamp = %ld, Nout = %ld\n", obufSize, Nout);
r->Yposition = 0;
// Finally set *osamp to the number of samples we put into the output buffer
#if 1 // FIXME: Hack to generate stereo output
*osamp = numOutSamples * 2;
#else
*osamp = numOutSamples;
#endif
return (ST_SUCCESS);
}