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

Method Process

Source/SamplePlayer.cpp:271–385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269}
270
271void 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

Callers

nothing calls this directly

Calls 15

ofLerpFunction · 0.85
ofClampFunction · 0.85
AddFunction · 0.85
IsGateOpenMethod · 0.80
sizeMethod · 0.80
BufferSizeMethod · 0.80
SetNumActiveChannelsMethod · 0.80
NumActiveChannelsMethod · 0.80
GetChannelMethod · 0.80
GetBufferMethod · 0.80
ConsumeDataMethod · 0.80
SetPlayPositionMethod · 0.80

Tested by

no test coverage detected