Path: blob/master/libsnes/bsnes/nall/dsp/resample/sinc.hpp
2 views
#ifdef NALL_DSP_INTERNAL_HPP12#include "lib/sinc.hpp"34struct ResampleSinc : Resampler {5inline void setFrequency();6inline void clear();7inline void sample();8inline ResampleSinc(DSP &dsp);910private:11inline void remakeSinc();12SincResample *sinc_resampler[8];13};1415void ResampleSinc::setFrequency() {16remakeSinc();17}1819void ResampleSinc::clear() {20remakeSinc();21}2223void ResampleSinc::sample() {24for(unsigned c = 0; c < dsp.settings.channels; c++) {25sinc_resampler[c]->write(dsp.buffer.read(c));26}2728if(sinc_resampler[0]->output_avail()) {29do {30for(unsigned c = 0; c < dsp.settings.channels; c++) {31dsp.output.write(c) = sinc_resampler[c]->read();32}33dsp.output.wroffset++;34} while(sinc_resampler[0]->output_avail());35}3637dsp.buffer.rdoffset++;38}3940ResampleSinc::ResampleSinc(DSP &dsp) : Resampler(dsp) {41for(unsigned n = 0; n < 8; n++) sinc_resampler[n] = 0;42}4344void ResampleSinc::remakeSinc() {45assert(dsp.settings.channels < 8);4647for(unsigned c = 0; c < dsp.settings.channels; c++) {48if(sinc_resampler[c]) delete sinc_resampler[c];49sinc_resampler[c] = new SincResample(dsp.settings.frequency, frequency, 0.85, SincResample::QUALITY_HIGH);50}51}5253#endif545556