| 75 | } |
| 76 | |
| 77 | void 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) |
nothing calls this directly
no test coverage detected