added CopyRateConverter (used if inrate == outrate)
svn-id: r9214
This commit is contained in:
parent
9865deb0bc
commit
81baae7ddc
3 changed files with 22 additions and 10 deletions
|
@ -107,7 +107,7 @@ int st_rate_flow(eff_t effp, AudioInputStream &input, st_sample_t *obuf, st_size
|
||||||
ilast[i] = rate->ilast[i];
|
ilast[i] = rate->ilast[i];
|
||||||
|
|
||||||
ostart = obuf;
|
ostart = obuf;
|
||||||
oend = obuf + *osamp;
|
oend = obuf + *osamp * 2;
|
||||||
|
|
||||||
while (obuf < oend && !input.eof()) {
|
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:
|
the_end:
|
||||||
*osamp = obuf - ostart;
|
*osamp = (obuf - ostart) / 2;
|
||||||
for (i = 0; i < channels; i++)
|
for (i = 0; i < channels; i++)
|
||||||
rate->ilast[i] = ilast[i];
|
rate->ilast[i] = ilast[i];
|
||||||
return (ST_SUCCESS);
|
return (ST_SUCCESS);
|
||||||
|
|
20
sound/rate.h
20
sound/rate.h
|
@ -81,4 +81,24 @@ public:
|
||||||
virtual int drain(st_sample_t *obuf, st_size_t *osamp, st_volume_t vol);
|
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
|
#endif
|
||||||
|
|
|
@ -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 Nout = 0; // The number of bytes we effectively output
|
||||||
long Nx; // The number of bytes we will read from input
|
long Nx; // The number of bytes we will read from input
|
||||||
long Nproc; // The number of bytes we process to generate Nout output bytes
|
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;
|
const long obufSize = *osamp;
|
||||||
#endif
|
|
||||||
|
|
||||||
TODO: adjust for the changes made to AudioInputStream; add support for stereo
|
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,
|
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;
|
r->Yposition = 0;
|
||||||
|
|
||||||
// Finally set *osamp to the number of samples we put into the output buffer
|
// 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;
|
*osamp = numOutSamples;
|
||||||
#endif
|
|
||||||
|
|
||||||
return (ST_SUCCESS);
|
return (ST_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue