public void Process(CommandList context) { IHardwareDevice device = context.OutputDevice; if (device.GetSampleRate() == Constants.TargetSampleRate) { int channelCount = (int)device.GetChannelCount(); uint bufferCount = Math.Min(device.GetChannelCount(), InputCount); const int sampleCount = Constants.TargetSampleCount; short[] outputBuffer = new short[bufferCount * sampleCount]; for (int i = 0; i < bufferCount; i++) { ReadOnlySpan <float> inputBuffer = GetBuffer(InputBufferIndices[i], sampleCount); for (int j = 0; j < sampleCount; j++) { outputBuffer[i + j * channelCount] = PcmHelper.Saturate(inputBuffer[j]); } } device.AppendBuffer(outputBuffer, InputCount); } else { // TODO: support resampling for device only supporting something different throw new NotImplementedException(); } }
public void AppendBuffer(ReadOnlySpan <short> data, uint channelCount) { _baseDevice.AppendBuffer(data, channelCount); _secondaryDevice?.AppendBuffer(data, channelCount); }