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

Method Process

Source/BufferShuffler.cpp:86–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86void BufferShuffler::Process(double time)
87{
88 PROFILER(BufferShuffler);
89
90 IAudioReceiver* target = GetTarget();
91
92 if (target == nullptr)
93 return;
94
95 SyncBuffers();
96 mInputBuffer.SetNumActiveChannels(GetBuffer()->NumActiveChannels());
97
98 int bufferSize = target->GetBuffer()->BufferSize();
99
100 if (mEnabled)
101 {
102 int writePosition = GetWritePositionInSamples(time);
103
104 for (int i = 0; i < bufferSize; ++i)
105 {
106 ComputeSliders(0);
107
108 if (mPlaybackSampleStartTime != -1 && time >= mPlaybackSampleStartTime)
109 {
110 int numSlices = GetNumSlices();
111 int slicePosIndex = mQueuedSlice;
112 if (mQueuedPlaybackStyle != PlaybackStyle::None)
113 mPlaybackStyle = mQueuedPlaybackStyle;
114 mQueuedPlaybackStyle = PlaybackStyle::None;
115 if (GetSlicePlaybackRate() < 0)
116 slicePosIndex += 1;
117 float slicePos = (slicePosIndex % numSlices) / (float)numSlices;
118 mPlaybackSampleIndex = int(GetLengthInSamples() * slicePos);
119 mPlaybackSampleStartTime = -1;
120 mSwitchAndRamp.StartSwitch();
121 if (mDrawDebug)
122 AddDebugLine(ofToString(gTime) + " switch and ramp for slice start", 10);
123 }
124
125 if (mPlaybackSampleStopTime != -1 && time >= mPlaybackSampleStopTime)
126 {
127 mPlaybackSampleIndex = -1;
128 mPlaybackSampleStopTime = -1;
129 mSwitchAndRamp.StartSwitch();
130 if (mDrawDebug)
131 AddDebugLine(ofToString(gTime) + " switch and ramp for slice end", 10);
132 }
133
134 for (int ch = 0; ch < GetBuffer()->NumActiveChannels(); ++ch)
135 {
136 if (!mFreezeInput)
137 mInputBuffer.GetChannel(ch)[writePosition] = GetBuffer()->GetChannel(ch)[i];
138
139 float outputSample = mOnlyPlayWhenTriggered ? 0 : GetBuffer()->GetChannel(ch)[i];
140 if (mPlaybackSampleIndex != -1)
141 {
142 outputSample = GetInterpolatedSample(mPlaybackSampleIndex, mInputBuffer.GetChannel(ch), GetLengthInSamples());
143 }

Callers

nothing calls this directly

Calls 13

ofToStringFunction · 0.85
GetInterpolatedSampleFunction · 0.85
ofLerpFunction · 0.85
FloatWrapFunction · 0.85
AddFunction · 0.85
SetNumActiveChannelsMethod · 0.80
NumActiveChannelsMethod · 0.80
BufferSizeMethod · 0.80
GetBufferMethod · 0.80
StartSwitchMethod · 0.80
GetChannelMethod · 0.80
WriteChunkMethod · 0.80

Tested by

no test coverage detected