Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libsnes/bsnes/nall/dsp/resample/cubic.hpp
2 views
1
#ifdef NALL_DSP_INTERNAL_HPP
2
3
struct ResampleCubic : Resampler {
4
inline void setFrequency();
5
inline void clear();
6
inline void sample();
7
ResampleCubic(DSP &dsp) : Resampler(dsp) {}
8
9
real fraction;
10
real step;
11
};
12
13
void ResampleCubic::setFrequency() {
14
fraction = 0.0;
15
step = dsp.settings.frequency / frequency;
16
}
17
18
void ResampleCubic::clear() {
19
fraction = 0.0;
20
}
21
22
void ResampleCubic::sample() {
23
while(fraction <= 1.0) {
24
real *channel = (real*)alloca(dsp.settings.channels * sizeof(real));
25
26
for(unsigned n = 0; n < dsp.settings.channels; n++) {
27
real a = dsp.buffer.read(n, -3);
28
real b = dsp.buffer.read(n, -2);
29
real c = dsp.buffer.read(n, -1);
30
real d = dsp.buffer.read(n, -0);
31
32
real mu = fraction;
33
34
real A = d - c - a + b;
35
real B = a - b - A;
36
real C = c - a;
37
real D = b;
38
39
channel[n] = A * (mu * 3) + B * (mu * 2) + C * mu + D;
40
}
41
42
dsp.write(channel);
43
fraction += step;
44
}
45
46
dsp.buffer.rdoffset++;
47
fraction -= 1.0;
48
}
49
50
#endif
51
52