MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / DoCompute

Method DoCompute

Source/Slider.cpp:602–642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

600}
601
602void FloatSlider::DoCompute(int samplesIn /*= 0*/)
603{
604 if (mLastComputeTime == gTime && mLastComputeSamplesIn == samplesIn)
605 return; //we've just calculated this, no need to do it again! earlying out avoids wasted work and circular modulation loops
606
607 if (mLFOControl && mLFOControl->Active() && mLFOControl->InLowResMode() && samplesIn != 0)
608 return; //only do the math on Compute(0) for low res mode
609
610 mLastComputeTime = gTime;
611 mLastComputeSamplesIn = samplesIn;
612
613 float oldVal = *mVar;
614
615 const bool kUseCache = true;
616 if (kUseCache && IsAudioThread() && samplesIn >= 0 && samplesIn < gBufferSize && mLastComputeCacheTime[samplesIn] == gTime)
617 {
618 *mVar = mLastComputeCacheValue[samplesIn];
619 }
620 else
621 {
622 if (mModulator && mModulator->Active())
623 {
624 if (mIsSmoothing)
625 mSmoothTarget = mModulator->Value(samplesIn);
626 else
627 *mVar = mModulator->Value(samplesIn);
628 }
629
630 if (mIsSmoothing)
631 *mVar = mRamp.Value(gTime + samplesIn * gInvSampleRateMs);
632
633 if (IsAudioThread() && samplesIn >= 0 && samplesIn < gBufferSize && mLastComputeCacheTime[samplesIn] != gTime)
634 {
635 mLastComputeCacheValue[samplesIn] = *mVar;
636 mLastComputeCacheTime[samplesIn] = gTime;
637 }
638 }
639
640 if (oldVal != *mVar)
641 mOwner->FloatSliderUpdated(this, oldVal, gTime + samplesIn * gInvSampleRateMs);
642}
643
644float* FloatSlider::GetModifyValue()
645{

Callers

nothing calls this directly

Calls 5

IsAudioThreadFunction · 0.85
InLowResModeMethod · 0.80
ActiveMethod · 0.45
ValueMethod · 0.45
FloatSliderUpdatedMethod · 0.45

Tested by

no test coverage detected