public void Process(CommandList context) { Span <BiquadFilterState> states = _biquadFilterStates.Span; ReadOnlySpan <float> inputBuffer = context.GetBuffer(_inputBufferIndex); Span <float> outputBuffer = context.GetBuffer(_outputBufferIndex); for (int i = 0; i < _parameters.Length; i++) { if (!_isInitialized[i]) { states[i] = new BiquadFilterState(); } } // NOTE: Nintendo also implements a hot path for double biquad filters, but no generic path when the command definition suggests it could be done. // As such we currently only implement a generic path for simplicity. // TODO: Implement double biquad filters fast path. if (_parameters.Length == 1) { BiquadFilterHelper.ProcessBiquadFilter(ref _parameters[0], ref states[0], outputBuffer, inputBuffer, context.SampleCount); } else { BiquadFilterHelper.ProcessBiquadFilter(_parameters, states, outputBuffer, inputBuffer, context.SampleCount); } }
public void Process(CommandList context) { ReadOnlySpan <float> inputBuffer = context.GetBuffer(InputBufferIndex); Span <float> outputBuffer = context.GetBuffer(OutputBufferIndex); State.Span[0].LastSamples[LastSampleIndex] = ProcessMixRamp(outputBuffer, inputBuffer, (int)context.SampleCount); }
public void Process(CommandList context) { ReadOnlySpan <float> inputBuffer = context.GetBuffer(InputBufferIndex); Span <float> outputBuffer = context.GetBuffer(OutputBufferIndex); inputBuffer.CopyTo(outputBuffer); }
public void Process(CommandList context) { ReadOnlySpan <float> inputBuffer = context.GetBuffer(InputBufferIndex); Span <float> outputBuffer = context.GetBuffer(OutputBufferIndex); ProcessVolumeRamp(outputBuffer, inputBuffer, (int)context.SampleCount); }
public void Process(CommandList context) { const int targetChannelCount = 2; ulong currentOffset = CurrentOffset; if (CircularBufferSize > 0) { for (int i = 0; i < InputCount; i++) { ReadOnlySpan <float> inputBuffer = context.GetBuffer(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> inputBuffer = context.GetBuffer((int)InputBufferIndex); Span <float> outputBuffer = context.GetBuffer((int)OutputBufferIndex); if (IsEffectEnabled) { Span <int> inputBufferInt = MemoryMarshal.Cast <float, int>(inputBuffer); Span <int> outputBufferInt = MemoryMarshal.Cast <float, int>(outputBuffer); // Convert input data to the target format for user (int) DataSourceHelper.ToInt(inputBufferInt, inputBuffer, inputBuffer.Length); // Send the input to the user Write(context.MemoryManager, OutputBuffer, CountMax, inputBufferInt, context.SampleCount, WriteOffset, UpdateCount); // Convert back to float just in case it's reused DataSourceHelper.ToFloat(inputBuffer, inputBufferInt, inputBuffer.Length); // Retrieve the input from user uint readResult = Read(context.MemoryManager, InputBuffer, CountMax, outputBufferInt, context.SampleCount, WriteOffset, UpdateCount); // Convert the outputBuffer back to the target format of the renderer (float) DataSourceHelper.ToFloat(outputBuffer, outputBufferInt, outputBuffer.Length); if (readResult != context.SampleCount) { outputBuffer.Slice((int)readResult, (int)context.SampleCount - (int)readResult).Fill(0); } } else { AuxiliaryBufferInfo.Reset(context.MemoryManager, BufferInfo.SendBufferInfo); AuxiliaryBufferInfo.Reset(context.MemoryManager, BufferInfo.ReturnBufferInfo); if (InputBufferIndex != OutputBufferIndex) { inputBuffer.CopyTo(outputBuffer); } } }
public void Process(CommandList context) { for (int i = 0; i < MixBufferCount; i++) { ReadOnlySpan <float> inputBuffer = context.GetBuffer(InputBufferIndices[i]); Span <float> outputBuffer = context.GetBuffer(OutputBufferIndices[i]); float volume0 = Volume0[i]; float volume1 = Volume1[i]; ref VoiceUpdateState state = ref State.Span[0]; if (volume0 != 0 || volume1 != 0) { state.LastSamples[i] = ProcessMixRampGrouped(outputBuffer, inputBuffer, volume0, volume1, (int)context.SampleCount); } else { state.LastSamples[i] = 0; } }
public void Process(CommandList context) { uint bufferCount = Math.Min(MixBufferOffset + MixBufferCount, context.BufferCount); for (int i = (int)MixBufferOffset; i < bufferCount; i++) { float depopValue = DepopBuffer.Span[i]; if (depopValue != 0) { Span <float> buffer = context.GetBuffer(i); DepopBuffer.Span[i] = ProcessDepopMix(buffer, depopValue, context.SampleCount); } } }
public void Process(CommandList context) { float ratio = (float)InputSampleRate / Constants.TargetSampleRate; uint bufferCount = Math.Min(BufferCount, UpsamplerInfo.SourceSampleCount); for (int i = 0; i < bufferCount; i++) { Span <float> inputBuffer = context.GetBuffer(UpsamplerInfo.InputBufferIndices[i]); Span <float> outputBuffer = GetBuffer(UpsamplerInfo.InputBufferIndices[i], (int)UpsamplerInfo.SampleCount); float fraction = 0.0f; ResamplerHelper.ResampleForUpsampler(outputBuffer, inputBuffer, ratio, ref fraction, (int)(InputSampleCount / ratio)); } }
public void Process(CommandList context) { ReadOnlySpan <float> frontLeft = context.GetBuffer(InputBufferIndices[0]); ReadOnlySpan <float> frontRight = context.GetBuffer(InputBufferIndices[1]); ReadOnlySpan <float> frontCenter = context.GetBuffer(InputBufferIndices[2]); ReadOnlySpan <float> lowFrequency = context.GetBuffer(InputBufferIndices[3]); ReadOnlySpan <float> backLeft = context.GetBuffer(InputBufferIndices[4]); ReadOnlySpan <float> backRight = context.GetBuffer(InputBufferIndices[5]); Span <float> stereoLeft = context.GetBuffer(OutputBufferIndices[0]); Span <float> stereoRight = context.GetBuffer(OutputBufferIndices[1]); for (int i = 0; i < context.SampleCount; i++) { stereoLeft[i] = DownMixSurroundToStereo(Coefficients, backLeft[i], lowFrequency[i], frontCenter[i], frontLeft[i]); stereoRight[i] = DownMixSurroundToStereo(Coefficients, backRight[i], lowFrequency[i], frontCenter[i], frontRight[i]); } context.ClearBuffer(OutputBufferIndices[2]); context.ClearBuffer(OutputBufferIndices[3]); context.ClearBuffer(OutputBufferIndices[4]); context.ClearBuffer(OutputBufferIndices[5]); }
public void Process(CommandList context) { Span <float> inputBuffer = context.GetBuffer((int)InputBufferIndex); if (IsEffectEnabled) { Span <int> inputBufferInt = MemoryMarshal.Cast <float, int>(inputBuffer); // Convert input data to the target format for user (int) DataSourceHelper.ToInt(inputBufferInt, inputBuffer, inputBuffer.Length); // Send the input to the user Write(context.MemoryManager, OutputBuffer, CountMax, inputBufferInt, context.SampleCount, WriteOffset, UpdateCount); // Convert back to float DataSourceHelper.ToFloat(inputBuffer, inputBufferInt, inputBuffer.Length); } else { AuxiliaryBufferInfo.Reset(context.MemoryManager, DspBufferInfoAddress); } }