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

Method Process

Source/SlowLayers.cpp:63–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63void SlowLayers::Process(double time)
64{
65 PROFILER(SlowLayers);
66
67 IAudioReceiver* target = GetTarget();
68
69 if (!mEnabled || target == nullptr)
70 return;
71
72 ComputeSliders(0);
73 SyncBuffers();
74
75 int bufferSize = GetBuffer()->BufferSize();
76 float* out = target->GetBuffer()->GetChannel(0);
77
78 int loopLengthInSamples = LoopLength();
79
80 int layers = 4;
81 for (int i = 0; i < bufferSize; ++i)
82 {
83 float smooth = .001f;
84 mSmoothedVol = mSmoothedVol * (1 - smooth) + mVol * smooth;
85 float volSq = mSmoothedVol * mSmoothedVol;
86
87 double measurePos = TheTransport->GetMeasureTime(time);
88 measurePos = DoubleWrap(measurePos, 1 << layers * mNumBars);
89 int offset = measurePos * loopLengthInSamples;
90
91 mBuffer[offset % loopLengthInSamples] += GetBuffer()->GetChannel(0)[i] * mFeedIn;
92
93 float output = (1 - mFeedIn) * GetBuffer()->GetChannel(0)[i];
94 for (int j = 0; j < layers; ++j)
95 output += GetInterpolatedSample(offset / float(1 << j), mBuffer, loopLengthInSamples);
96
97 output *= volSq;
98
99 out[i] += output;
100
101 time += gInvSampleRateMs;
102 }
103
104 Add(out, GetBuffer()->GetChannel(0), bufferSize);
105
106 GetVizBuffer()->WriteChunk(GetBuffer()->GetChannel(0), bufferSize, 0);
107
108 GetBuffer()->Reset();
109}
110
111int SlowLayers::LoopLength() const
112{

Callers

nothing calls this directly

Calls 9

DoubleWrapFunction · 0.85
GetInterpolatedSampleFunction · 0.85
AddFunction · 0.85
BufferSizeMethod · 0.80
GetChannelMethod · 0.80
GetBufferMethod · 0.80
GetMeasureTimeMethod · 0.80
WriteChunkMethod · 0.80
ResetMethod · 0.45

Tested by

no test coverage detected