2011-09-24 09:51:08 +00:00
|
|
|
#ifdef NALL_DSP_INTERNAL_HPP
|
|
|
|
|
|
|
|
#include "lib/sinc.hpp"
|
|
|
|
|
|
|
|
struct ResampleSinc : Resampler {
|
|
|
|
inline void setFrequency();
|
|
|
|
inline void clear();
|
|
|
|
inline void sample();
|
2013-05-02 11:25:45 +00:00
|
|
|
inline ResampleSinc(DSP& dsp);
|
2011-09-24 09:51:08 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
inline void remakeSinc();
|
2013-05-02 11:25:45 +00:00
|
|
|
SincResample* sinc_resampler[8];
|
2011-09-24 09:51:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void ResampleSinc::setFrequency() {
|
|
|
|
remakeSinc();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResampleSinc::clear() {
|
|
|
|
remakeSinc();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResampleSinc::sample() {
|
|
|
|
for(unsigned c = 0; c < dsp.settings.channels; c++) {
|
|
|
|
sinc_resampler[c]->write(dsp.buffer.read(c));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(sinc_resampler[0]->output_avail()) {
|
|
|
|
do {
|
|
|
|
for(unsigned c = 0; c < dsp.settings.channels; c++) {
|
|
|
|
dsp.output.write(c) = sinc_resampler[c]->read();
|
|
|
|
}
|
|
|
|
dsp.output.wroffset++;
|
|
|
|
} while(sinc_resampler[0]->output_avail());
|
|
|
|
}
|
|
|
|
|
|
|
|
dsp.buffer.rdoffset++;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
ResampleSinc::ResampleSinc(DSP& dsp) : Resampler(dsp) {
|
2013-03-15 13:11:33 +00:00
|
|
|
for(unsigned n = 0; n < 8; n++) sinc_resampler[n] = nullptr;
|
2011-09-24 09:51:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ResampleSinc::remakeSinc() {
|
|
|
|
assert(dsp.settings.channels < 8);
|
|
|
|
|
|
|
|
for(unsigned c = 0; c < dsp.settings.channels; c++) {
|
|
|
|
if(sinc_resampler[c]) delete sinc_resampler[c];
|
|
|
|
sinc_resampler[c] = new SincResample(dsp.settings.frequency, frequency, 0.85, SincResample::QUALITY_HIGH);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|