| 84 | } |
| 85 | |
| 86 | void 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 | } |
nothing calls this directly
no test coverage detected