#pragma once #ifndef DSY_SR_REDUCER_H #define DSY_SR_REDUCER_H #include #ifdef __cplusplus /** @file sampleratereducer.h */ namespace daisysp { /** @brief Sample rate reducer. @author Ben Sergentanis @date Jan 2021 Ported from pichenettes/eurorack/plaits/dsp/fx/sample_rate_reducer.h \n to an independent module. \n Original code written by Emilie Gillet in 2014. \n */ class SampleRateReducer { public: SampleRateReducer() {} ~SampleRateReducer() {} /** Initialize the module */ void Init(); /** Get the next floating point sample \param in Sample to be processed. */ float Process(float in); /** Set the new sample rate. \param Works over 0-1. 1 is full quality, .5 is half sample rate, etc. */ void SetFreq(float frequency); private: float frequency_; float phase_; float sample_; float previous_sample_; float next_sample_; }; } // namespace daisysp #endif #endif