|
13 | 13 |
|
14 | 14 | namespace Kaixo::Processing { |
15 | 15 |
|
16 | | - // ------------------------------------------------ |
| 16 | + // ------------------------------------------------ |
17 | 17 |
|
18 | | - struct AudioBufferResampler { |
| 18 | + struct AudioBufferResampler { |
19 | 19 |
|
20 | | - // ------------------------------------------------ |
| 20 | + // ------------------------------------------------ |
21 | 21 |
|
22 | | - constexpr static std::int64_t WINDOW_SIZE = 64; // Windowed-Sinc Function window size. |
| 22 | + constexpr static std::int64_t WINDOW_SIZE = 64; // Windowed-Sinc Function window size. |
23 | 23 |
|
24 | | - // ------------------------------------------------ |
| 24 | + // ------------------------------------------------ |
25 | 25 |
|
26 | | - void reset() { index(0); } |
27 | | - void index(std::int64_t i) { playindex = i; lastinserted = i; finished = false; } |
| 26 | + void reset() { index(0); } |
| 27 | + void index(std::int64_t i) { playindex = i; lastinserted = i; finished = false; } |
28 | 28 |
|
29 | | - // ------------------------------------------------ |
30 | | - |
31 | | - bool reverse = false; |
| 29 | + // ------------------------------------------------ |
| 30 | + |
| 31 | + bool reverse = false; |
32 | 32 |
|
33 | | - // ------------------------------------------------ |
| 33 | + // ------------------------------------------------ |
34 | 34 |
|
35 | | - struct { |
36 | | - double in; |
37 | | - double out; |
38 | | - } samplerate; |
| 35 | + struct { |
| 36 | + double in; |
| 37 | + double out; |
| 38 | + } samplerate; |
39 | 39 |
|
40 | | - // ------------------------------------------------ |
| 40 | + // ------------------------------------------------ |
41 | 41 |
|
42 | | - Stereo generate(const AudioBuffer& buffer); |
| 42 | + Stereo generate(const AudioBuffer& buffer); |
43 | 43 |
|
44 | | - // ------------------------------------------------ |
45 | | - |
46 | | - std::int64_t position() const { return lastinserted; } |
47 | | - bool eof() const { return finished; } |
| 44 | + // ------------------------------------------------ |
| 45 | + |
| 46 | + std::int64_t position() const { return lastinserted; } |
| 47 | + bool eof() const { return finished; } |
48 | 48 |
|
49 | | - // ------------------------------------------------ |
| 49 | + // ------------------------------------------------ |
50 | 50 |
|
51 | | - private: |
52 | | - std::int64_t lastinserted = 0; |
53 | | - double playindex = 0; // Current non-integer index in input buffer. |
54 | | - bool finished = false; |
| 51 | + private: |
| 52 | + std::int64_t lastinserted = 0; |
| 53 | + double playindex = 0; // Current non-integer index in input buffer. |
| 54 | + bool finished = false; |
55 | 55 |
|
56 | | - // ------------------------------------------------ |
| 56 | + // ------------------------------------------------ |
57 | 57 |
|
58 | | - struct CircleBuffer { |
59 | | - Stereo data[WINDOW_SIZE]{}; |
60 | | - constexpr Stereo& operator[](std::int64_t i) { return data[(i + 10 * WINDOW_SIZE) % WINDOW_SIZE]; } |
61 | | - } buffer; |
| 58 | + struct CircleBuffer { |
| 59 | + Stereo data[WINDOW_SIZE]{}; |
| 60 | + constexpr Stereo& operator[](std::int64_t i) { return data[(i + 10 * WINDOW_SIZE) % WINDOW_SIZE]; } |
| 61 | + } buffer; |
62 | 62 |
|
63 | | - EllipticFilter aaf[2]{}; |
64 | | - EllipticParameters aafp[2]{}; |
| 63 | + EllipticFilter aaf[2]{}; |
| 64 | + EllipticParameters aafp[2]{}; |
65 | 65 |
|
66 | | - // ------------------------------------------------ |
| 66 | + // ------------------------------------------------ |
67 | 67 |
|
68 | | - void applyWindowedSinc(Stereo& in); |
| 68 | + void applyWindowedSinc(Stereo& in); |
69 | 69 |
|
70 | | - // ------------------------------------------------ |
| 70 | + // ------------------------------------------------ |
71 | 71 |
|
72 | | - }; |
| 72 | + }; |
73 | 73 |
|
74 | | - // ------------------------------------------------ |
| 74 | + // ------------------------------------------------ |
75 | 75 |
|
76 | 76 | } |
77 | 77 |
|
|
0 commit comments