Fix a typo in the changelog
[openal-soft.git] / common / polyphase_resampler.h
blobe9833d12d89ab07c199230c54c8dd6f3b187092c
1 #ifndef POLYPHASE_RESAMPLER_H
2 #define POLYPHASE_RESAMPLER_H
4 #include <vector>
7 /* This is a polyphase sinc-filtered resampler. It is built for very high
8 * quality results, rather than real-time performance.
10 * Upsample Downsample
12 * p/q = 3/2 p/q = 3/5
14 * M-+-+-+-> M-+-+-+->
15 * -------------------+ ---------------------+
16 * p s * f f f f|f| | p s * f f f f f |
17 * | 0 * 0 0 0|0|0 | | 0 * 0 0 0 0|0| |
18 * v 0 * 0 0|0|0 0 | v 0 * 0 0 0|0|0 |
19 * s * f|f|f f f | s * f f|f|f f |
20 * 0 * |0|0 0 0 0 | 0 * 0|0|0 0 0 |
21 * --------+=+--------+ 0 * |0|0 0 0 0 |
22 * d . d .|d|. d . d ----------+=+--------+
23 * d . . . .|d|. . . .
24 * q->
25 * q-+-+-+->
27 * P_f(i,j) = q i mod p + pj
28 * P_s(i,j) = floor(q i / p) - j
29 * d[i=0..N-1] = sum_{j=0}^{floor((M - 1) / p)} {
30 * { f[P_f(i,j)] s[P_s(i,j)], P_f(i,j) < M
31 * { 0, P_f(i,j) >= M. }
34 struct PPhaseResampler {
35 using uint = unsigned int;
37 void init(const uint srcRate, const uint dstRate);
38 void process(const uint inN, const double *in, const uint outN, double *out);
40 private:
41 uint mP, mQ, mM, mL;
42 std::vector<double> mF;
45 #endif /* POLYPHASE_RESAMPLER_H */