| 196 | } |
| 197 | |
| 198 | void Looper::Process(double time) |
| 199 | { |
| 200 | PROFILER(Looper); |
| 201 | |
| 202 | IAudioReceiver* target = GetTarget(); |
| 203 | |
| 204 | if (target == nullptr) |
| 205 | return; |
| 206 | |
| 207 | if (!mEnabled) |
| 208 | { |
| 209 | SyncBuffers(); |
| 210 | |
| 211 | for (int ch = 0; ch < GetBuffer()->NumActiveChannels(); ++ch) |
| 212 | { |
| 213 | Add(target->GetBuffer()->GetChannel(ch), GetBuffer()->GetChannel(ch), GetBuffer()->BufferSize()); |
| 214 | GetVizBuffer()->WriteChunk(GetBuffer()->GetChannel(ch), GetBuffer()->BufferSize(), ch); |
| 215 | } |
| 216 | |
| 217 | GetBuffer()->Reset(); |
| 218 | |
| 219 | return; |
| 220 | } |
| 221 | |
| 222 | ComputeSliders(0); |
| 223 | int numChannels = MAX(GetBuffer()->NumActiveChannels(), mBuffer->NumActiveChannels()); |
| 224 | if (mRecorder) |
| 225 | numChannels = MAX(numChannels, mRecorder->GetRecordBuffer()->NumChannels()); |
| 226 | GetBuffer()->SetNumActiveChannels(numChannels); |
| 227 | SyncBuffers(); |
| 228 | mBuffer->SetNumActiveChannels(GetBuffer()->NumActiveChannels()); |
| 229 | mWorkBuffer.SetNumActiveChannels(GetBuffer()->NumActiveChannels()); |
| 230 | mUndoBuffer->SetNumActiveChannels(GetBuffer()->NumActiveChannels()); |
| 231 | |
| 232 | bool doGranular = mGranulator != nullptr && mGranulator->IsActive(); |
| 233 | |
| 234 | if (mWantBakeVolume) |
| 235 | BakeVolume(); |
| 236 | if (mWantShiftDownbeat) |
| 237 | DoShiftDownbeat(); |
| 238 | |
| 239 | int bufferSize = GetBuffer()->BufferSize(); |
| 240 | |
| 241 | float oldLoopPos = mLoopPos; |
| 242 | int sampsPerBar = mLoopLength / mNumBars; |
| 243 | if (!doGranular || !mGranulator->ShouldFreeze()) |
| 244 | mLoopPos = sampsPerBar * ((TheTransport->GetMeasure(time) % mNumBars) + TheTransport->GetMeasurePos(time)); |
| 245 | |
| 246 | double speed = GetPlaybackSpeed(); |
| 247 | |
| 248 | if (oldLoopPos > mLoopLength - bufferSize * speed - 1 && mLoopPos < oldLoopPos) |
| 249 | { |
| 250 | ++mLoopCount; |
| 251 | /*if (mLoopCount > 6 && mMute == false && mDecay) |
| 252 | mVol *= ofMap(TheTransport->GetTempo(), 80.0f, 160.0f, .95f, .99f, true);*/ |
| 253 | if (mMute == false) |
| 254 | mVol *= 1 - mDecay; |
| 255 |
nothing calls this directly
no test coverage detected