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

Method Process

Source/SamplerGrid.cpp:77–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77void SamplerGrid::Process(double time)
78{
79 PROFILER(SamplerGrid);
80
81 IAudioReceiver* target = GetTarget();
82
83 if (target == nullptr)
84 return;
85
86 SyncBuffers();
87
88 if (!mEnabled)
89 {
90 for (int ch = 0; ch < GetBuffer()->NumActiveChannels(); ++ch)
91 {
92 Add(target->GetBuffer()->GetChannel(ch), GetBuffer()->GetChannel(ch), GetBuffer()->BufferSize());
93 GetVizBuffer()->WriteChunk(GetBuffer()->GetChannel(ch), GetBuffer()->BufferSize(), ch);
94 }
95
96 GetBuffer()->Reset();
97
98 return;
99 }
100
101 ComputeSliders(0);
102
103 int bufferSize = GetBuffer()->BufferSize();
104
105 Clear(gWorkBuffer, gBufferSize);
106
107 float volSq = mVolume * mVolume;
108
109 for (int i = 0; i < gBufferSize; ++i)
110 {
111 for (int j = 0; j < mRows * mCols; ++j)
112 {
113 GridSample& sample = mGridSamples[j];
114 float rampVal = sample.mRamp.Value(time);
115 if (rampVal > 0 && sample.mPlayhead < sample.mSampleEnd)
116 {
117 gWorkBuffer[i] += sample.mSampleData[sample.mPlayhead] * rampVal * volSq;
118 ++sample.mPlayhead;
119 if (sample.mRamp.Target(time) == 1 &&
120 sample.mPlayhead + SAMPLE_RAMP_MS / gInvSampleRateMs >= sample.mSampleEnd)
121 sample.mRamp.Start(time, 0, time + SAMPLE_RAMP_MS);
122 }
123 }
124 time += gInvSampleRateMs;
125 }
126
127 if (mRecordingSample != -1)
128 {
129 GridSample& sample = mGridSamples[mRecordingSample];
130 for (int i = 0; i < gBufferSize; ++i)
131 {
132 if (GetBuffer()->GetChannel(0)[i] != 0)
133 sample.mHasSample = true;
134 if (sample.mPlayhead < MAX_SAMPLER_GRID_LENGTH && sample.mHasSample)

Callers

nothing calls this directly

Calls 11

AddFunction · 0.85
ClearFunction · 0.85
NumActiveChannelsMethod · 0.80
GetChannelMethod · 0.80
GetBufferMethod · 0.80
BufferSizeMethod · 0.80
WriteChunkMethod · 0.80
TargetMethod · 0.80
ResetMethod · 0.45
ValueMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected