public void ProcessReverb3d(CommandList context, ref Reverb3dState state) { Debug.Assert(Parameter.IsChannelCountValid()); if (IsEffectEnabled && Parameter.IsChannelCountValid()) { Span <IntPtr> inputBuffers = stackalloc IntPtr[Parameter.ChannelCount]; Span <IntPtr> outputBuffers = stackalloc IntPtr[Parameter.ChannelCount]; for (int i = 0; i < Parameter.ChannelCount; i++) { inputBuffers[i] = context.GetBufferPointer(InputBufferIndices[i]); outputBuffers[i] = context.GetBufferPointer(OutputBufferIndices[i]); } switch (Parameter.ChannelCount) { case 1: ProcessReverb3dMono(ref state, outputBuffers, inputBuffers, context.SampleCount); break; case 2: ProcessReverb3dStereo(ref state, outputBuffers, inputBuffers, context.SampleCount); break; case 4: ProcessReverb3dQuadraphonic(ref state, outputBuffers, inputBuffers, context.SampleCount); break; case 6: ProcessReverb3dSurround(ref state, outputBuffers, inputBuffers, context.SampleCount); break; default: throw new NotImplementedException(Parameter.ChannelCount.ToString()); } } else { for (int i = 0; i < Parameter.ChannelCount; i++) { if (InputBufferIndices[i] != OutputBufferIndices[i]) { context.CopyBuffer(OutputBufferIndices[i], InputBufferIndices[i]); } } } }
public void Process(CommandList context) { const int targetChannelCount = 2; ulong currentOffset = CurrentOffset; if (CircularBufferSize > 0) { for (int i = 0; i < InputCount; i++) { unsafe { float *inputBuffer = (float *)context.GetBufferPointer(Input[i]); ulong targetOffset = CircularBuffer + currentOffset; for (int y = 0; y < context.SampleCount; y++) { context.MemoryManager.Write(targetOffset + (ulong)y * targetChannelCount, PcmHelper.Saturate(inputBuffer[y])); } currentOffset += context.SampleCount * targetChannelCount; if (currentOffset >= CircularBufferSize) { currentOffset = 0; } } } } }
public void Process(CommandList context) { Span <float> depopBuffer = DepopBuffer.Span; uint bufferCount = Math.Min(MixBufferOffset + MixBufferCount, context.BufferCount); for (int i = (int)MixBufferOffset; i < bufferCount; i++) { float depopValue = depopBuffer[i]; if (depopValue != 0) { unsafe { float *buffer = (float *)context.GetBufferPointer(i); depopBuffer[i] = ProcessDepopMix(buffer, depopValue, context.SampleCount); } } } }