20 #include <pluginterfaces/base/ftypes.h> 21 #include <pluginterfaces/vst/vsttypes.h> 28 using namespace Steinberg;
29 using namespace Steinberg::Vst;
52 explicit RateLimiter(uint32 iRateLimitInSamples = 0) : fRateLimitInSamples{iRateLimitInSamples}, fSampleCount{0}
61 fSampleCount += numSamples;
62 if(fSampleCount >= fRateLimitInSamples)
64 fSampleCount -= fRateLimitInSamples;
84 return static_cast<uint32>(ceil(fSampleRate * iMillis / 1000.0));
90 auto oneBarInSeconds = 240.0 / iTempo;
91 if(iTimeSigNumerator != iTimeSigDenominator && iTimeSigDenominator != 0)
93 oneBarInSeconds *= (static_cast<double>(iTimeSigNumerator) / static_cast<double>(iTimeSigDenominator));
95 return static_cast<uint32>(ceil(fSampleRate * oneBarInSeconds));
101 return static_cast<uint32>(ceil(iSampleCount * 1000.0 / fSampleRate));
113 fSampleRate = iSampleRate;
SampleRate getSampleRate() const
Definition: SampleRateBasedClock.h:105
RateLimiter(uint32 iRateLimitInSamples=0)
Definition: SampleRateBasedClock.h:52
uint32 getSampleCountFor(uint32 iMillis) const
Definition: SampleRateBasedClock.h:82
Definition: SampleRateBasedClock.h:49
SampleRateBasedClock(SampleRate iSampleRate)
Definition: SampleRateBasedClock.h:76
uint32 fSampleCount
Definition: SampleRateBasedClock.h:72
bool shouldUpdate(uint32 numSamples)
Definition: SampleRateBasedClock.h:59
void setSampleRate(SampleRate iSampleRate)
Definition: SampleRateBasedClock.h:111
uint32 getTimeForSampleCount(uint32 iSampleCount) const
Definition: SampleRateBasedClock.h:99
RateLimiter getRateLimiter(uint32 iMillis) const
Definition: SampleRateBasedClock.h:117
uint32 getSampleCountFor1Bar(double iTempo, int32 iTimeSigNumerator=4, int32 iTimeSigDenominator=4) const
Definition: SampleRateBasedClock.h:88
Definition: SampleRateBasedClock.h:34
SampleRate fSampleRate
Definition: SampleRateBasedClock.h:123
uint32 fRateLimitInSamples
Definition: SampleRateBasedClock.h:71