1 #ifndef POLYPHASE_RESAMPLER_H
2 #define POLYPHASE_RESAMPLER_H
9 using uint
= unsigned int;
11 /* This is a polyphase sinc-filtered resampler. It is built for very high
12 * quality results, rather than real-time performance.
19 * -------------------+ ---------------------+
20 * p s * f f f f|f| | p s * f f f f f |
21 * | 0 * 0 0 0|0|0 | | 0 * 0 0 0 0|0| |
22 * v 0 * 0 0|0|0 0 | v 0 * 0 0 0|0|0 |
23 * s * f|f|f f f | s * f f|f|f f |
24 * 0 * |0|0 0 0 0 | 0 * 0|0|0 0 0 |
25 * --------+=+--------+ 0 * |0|0 0 0 0 |
26 * d . d .|d|. d . d ----------+=+--------+
31 * P_f(i,j) = q i mod p + pj
32 * P_s(i,j) = floor(q i / p) - j
33 * d[i=0..N-1] = sum_{j=0}^{floor((M - 1) / p)} {
34 * { f[P_f(i,j)] s[P_s(i,j)], P_f(i,j) < M
35 * { 0, P_f(i,j) >= M. }
38 struct PPhaseResampler
{
39 void init(const uint srcRate
, const uint dstRate
);
40 void process(const al::span
<const double> in
, const al::span
<double> out
);
42 explicit operator bool() const noexcept
{ return !mF
.empty(); }
45 uint mP
{}, mQ
{}, mM
{}, mL
{};
46 std::vector
<double> mF
;
49 #endif /* POLYPHASE_RESAMPLER_H */