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

Method Process

Source/SampleCapturer.cpp:58–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58void SampleCapturer::Process(double time)
59{
60 PROFILER(SampleCapturer);
61
62 IAudioReceiver* target = GetTarget();
63
64 if (target == nullptr)
65 return;
66
67 SyncBuffers();
68
69 if (!mEnabled)
70 {
71 for (int ch = 0; ch < GetBuffer()->NumActiveChannels(); ++ch)
72 {
73 Add(target->GetBuffer()->GetChannel(ch), GetBuffer()->GetChannel(ch), GetBuffer()->BufferSize());
74 GetVizBuffer()->WriteChunk(GetBuffer()->GetChannel(ch), GetBuffer()->BufferSize(), ch);
75 }
76
77 GetBuffer()->Reset();
78
79 return;
80 }
81
82 int bufferSize = GetBuffer()->BufferSize();
83
84 ChannelBuffer* out = target->GetBuffer();
85 gWorkChannelBuffer.SetNumActiveChannels(GetBuffer()->NumActiveChannels());
86 for (int ch = 0; ch < GetBuffer()->NumActiveChannels(); ++ch)
87 {
88 Add(out->GetChannel(ch), GetBuffer()->GetChannel(ch), GetBuffer()->BufferSize());
89 BufferCopy(gWorkChannelBuffer.GetChannel(ch), GetBuffer()->GetChannel(ch), GetBuffer()->BufferSize());
90 }
91
92 for (int i = 0; i < bufferSize; ++i)
93 {
94 if (mWantRecord)
95 {
96 for (int ch = 0; ch < GetBuffer()->NumActiveChannels(); ++ch)
97 {
98 if (mIsRecording || GetBuffer()->GetChannel(ch)[i] != 0)
99 {
100 auto& sample = mSamples[mCurrentSampleIndex];
101 if (!mIsRecording)
102 {
103 mIsRecording = true;
104 sample.mBuffer.SetNumActiveChannels(GetBuffer()->NumActiveChannels());
105 sample.mBuffer.Clear();
106 }
107
108 sample.mBuffer.GetChannel(ch)[sample.mRecordingLength] = GetBuffer()->GetChannel(ch)[i];
109 }
110 }
111
112 if (mIsRecording)
113 {
114 ++mSamples[mCurrentSampleIndex].mRecordingLength;
115 if (mSamples[mCurrentSampleIndex].mRecordingLength >= mSamples[mCurrentSampleIndex].mBuffer.BufferSize())

Callers

nothing calls this directly

Calls 11

AddFunction · 0.85
BufferCopyFunction · 0.85
NumActiveChannelsMethod · 0.80
GetChannelMethod · 0.80
GetBufferMethod · 0.80
BufferSizeMethod · 0.80
WriteChunkMethod · 0.80
SetNumActiveChannelsMethod · 0.80
sizeMethod · 0.80
ResetMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected