| 269 | } |
| 270 | |
| 271 | void SamplePlayer::Process(double time) |
| 272 | { |
| 273 | PROFILER(SamplePlayer); |
| 274 | |
| 275 | IAudioReceiver* target = GetTarget(); |
| 276 | |
| 277 | //recording input gate processing |
| 278 | bool gateWasOpen = false; |
| 279 | bool gateIsOpen = false; |
| 280 | if (mRecordAsClips) |
| 281 | { |
| 282 | gateWasOpen = mRecordGate.IsGateOpen(); |
| 283 | mRecordGate.ProcessAudio(time, GetBuffer()); |
| 284 | gateIsOpen = mRecordGate.IsGateOpen(); |
| 285 | } |
| 286 | |
| 287 | if (mDoRecording) |
| 288 | { |
| 289 | bool acceptInput = true; |
| 290 | if (mRecordAsClips) |
| 291 | { |
| 292 | acceptInput = gateIsOpen; |
| 293 | |
| 294 | if (gateIsOpen && !gateWasOpen) |
| 295 | { |
| 296 | if (mRecordAsClipsCueIndex < (int)mSampleCuePoints.size()) |
| 297 | { |
| 298 | SetCuePoint(mRecordAsClipsCueIndex, float(mRecordingLength) / gSampleRate, 0, 1); |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | if (!gateIsOpen && gateWasOpen) |
| 303 | { |
| 304 | if (mRecordAsClipsCueIndex < (int)mSampleCuePoints.size()) |
| 305 | mSampleCuePoints[mRecordAsClipsCueIndex].lengthSeconds = (float(mRecordingLength) / gSampleRate) - mSampleCuePoints[mRecordAsClipsCueIndex].startSeconds; |
| 306 | mRecordingLength += 200; //add silence gap |
| 307 | ++mRecordAsClipsCueIndex; |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | if (acceptInput) |
| 312 | { |
| 313 | for (int i = 0; i < GetBuffer()->BufferSize(); ++i) |
| 314 | { |
| 315 | int chunkIndex = mRecordingLength / kRecordingChunkSize; |
| 316 | int chunkPos = mRecordingLength % kRecordingChunkSize; |
| 317 | mRecordChunks[chunkIndex]->SetNumActiveChannels(GetBuffer()->NumActiveChannels()); |
| 318 | for (int ch = 0; ch < GetBuffer()->NumActiveChannels(); ++ch) |
| 319 | mRecordChunks[chunkIndex]->GetChannel(ch)[chunkPos] = GetBuffer()->GetChannel(ch)[i]; |
| 320 | ++mRecordingLength; |
| 321 | } |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | if (mEnabled && target != nullptr && mSample != nullptr) |
| 326 | { |
| 327 | mNoteInputBuffer.Process(time); |
| 328 |
nothing calls this directly
no test coverage detected