19 #include <ucommon/ucommon.h>
20 #include <ucommon/export.h>
24 using namespace UCOMMON_NAMESPACE;
26 Audio::resample::resample(Audio::rate_t div, Audio::rate_t mul)
32 while(!(mul & 0x01) && !(div & 0x01)) {
33 mul = (Audio::rate_t)(mul >> 1);
34 div = (Audio::rate_t)(div >> 1);
38 while(!(mul % 3) && !(div % 3)) {
39 mul = (Audio::rate_t)(mul / 3);
40 div = (Audio::rate_t)(div / 3);
44 while(!(mul % 5) && !(div %5)) {
45 mul = (rate_t)(mul / 5);
46 div = (rate_t)(div / 5);
52 mfact = (unsigned)mul;
53 dfact = (unsigned)div;
60 buffer =
new Audio::sample_t[max];
62 memset(buffer, 0, max * 2);
66 Audio::resample::~resample()
71 size_t Audio::resample::estimate(
size_t count)
75 return (count / dfact) + 1;
78 size_t Audio::resample::process(linear_t from, linear_t dest,
size_t count)
81 sample_t diff, current;
87 diff = (current - last) / mfact;
91 buffer[ppos++] = current;
98 dpos = max - (gpos - ppos);
100 *(dest++) = buffer[gpos];
#define BAYONNE_NAMESPACE
GNU Bayonne library namespace.