DSPUtil.SampleBuffer.PaddedSubset C# (CSharp) Method

PaddedSubset() public method

Variant of Subset, supporting negative "start" values
public PaddedSubset ( int start, int count ) : ISoundObj
start int
count int
return ISoundObj
        public ISoundObj PaddedSubset(int start, int count)
        {
            bool started = false;
            ISampleBuffer sb = GetInputEnum();
            ushort nc = NumChannels;
            return new CallbackSource(nc, SampleRate, delegate(long n)
            {
                int nn;
                bool more;
                if (start < 0)
                {
                    start++;
                    return new Sample(nc);
                }
                if (!started)
                {
                    sb.Skip(start, out nn, out more);
                    started = true;
                }
                if (n > count)
                {
                    return null;
                }
                ISample[] sa = sb.Read(1, out nn, out more);
                if (sa.Length > 0)
                {
                    return sa[0];
                }
                else
                {
                    return null;
                }
            });
        }