Пример #1
0
        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 uint GetChannelCount()
 {
     return(_baseDevice.GetChannelCount());
 }