1 #ifndef POLYPHASE_RESAMPLER_H
2 #define POLYPHASE_RESAMPLER_H
7 using uint
= unsigned int;
9 /* This is a polyphase sinc-filtered resampler. It is built for very high
10 * quality results, rather than real-time performance.
17 * -------------------+ ---------------------+
18 * p s * f f f f|f| | p s * f f f f f |
19 * | 0 * 0 0 0|0|0 | | 0 * 0 0 0 0|0| |
20 * v 0 * 0 0|0|0 0 | v 0 * 0 0 0|0|0 |
21 * s * f|f|f f f | s * f f|f|f f |
22 * 0 * |0|0 0 0 0 | 0 * 0|0|0 0 0 |
23 * --------+=+--------+ 0 * |0|0 0 0 0 |
24 * d . d .|d|. d . d ----------+=+--------+
29 * P_f(i,j) = q i mod p + pj
30 * P_s(i,j) = floor(q i / p) - j
31 * d[i=0..N-1] = sum_{j=0}^{floor((M - 1) / p)} {
32 * { f[P_f(i,j)] s[P_s(i,j)], P_f(i,j) < M
33 * { 0, P_f(i,j) >= M. }
36 struct PPhaseResampler
{
37 void init(const uint srcRate
, const uint dstRate
);
38 void process(const uint inN
, const double *in
, const uint outN
, double *out
);
40 explicit operator bool() const noexcept
{ return !mF
.empty(); }
44 std::vector
<double> mF
;
47 #endif /* POLYPHASE_RESAMPLER_H */