Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libsnes/bsnes/nall/dsp/resample/sinc.hpp
2 views
1
#ifdef NALL_DSP_INTERNAL_HPP
2
3
#include "lib/sinc.hpp"
4
5
struct ResampleSinc : Resampler {
6
inline void setFrequency();
7
inline void clear();
8
inline void sample();
9
inline ResampleSinc(DSP &dsp);
10
11
private:
12
inline void remakeSinc();
13
SincResample *sinc_resampler[8];
14
};
15
16
void ResampleSinc::setFrequency() {
17
remakeSinc();
18
}
19
20
void ResampleSinc::clear() {
21
remakeSinc();
22
}
23
24
void ResampleSinc::sample() {
25
for(unsigned c = 0; c < dsp.settings.channels; c++) {
26
sinc_resampler[c]->write(dsp.buffer.read(c));
27
}
28
29
if(sinc_resampler[0]->output_avail()) {
30
do {
31
for(unsigned c = 0; c < dsp.settings.channels; c++) {
32
dsp.output.write(c) = sinc_resampler[c]->read();
33
}
34
dsp.output.wroffset++;
35
} while(sinc_resampler[0]->output_avail());
36
}
37
38
dsp.buffer.rdoffset++;
39
}
40
41
ResampleSinc::ResampleSinc(DSP &dsp) : Resampler(dsp) {
42
for(unsigned n = 0; n < 8; n++) sinc_resampler[n] = 0;
43
}
44
45
void ResampleSinc::remakeSinc() {
46
assert(dsp.settings.channels < 8);
47
48
for(unsigned c = 0; c < dsp.settings.channels; c++) {
49
if(sinc_resampler[c]) delete sinc_resampler[c];
50
sinc_resampler[c] = new SincResample(dsp.settings.frequency, frequency, 0.85, SincResample::QUALITY_HIGH);
51
}
52
}
53
54
#endif
55
56