public ISoundObj Subset(int start, int count) { bool started = false; ISampleBuffer sb = GetInputEnum(); return(new CallbackSource(NumChannels, SampleRate, delegate(long n) { int nn; bool more; 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; } })); }
public bool ReadTo(int n) { if (n < _samples.Count) { return(true); } if (_input == null) { _moreSamples = false; return(_moreSamples); } if (_inputEnum == null) { _inputEnum = _input.GetBufferedEnumerator() as ISampleBuffer; } int nn = n - _samples.Count; if (nn > 0 && _moreSamples) { if (n < int.MaxValue && _samples.Capacity < n) { _samples.Capacity = n; } int tot = 0; int nnn; while (_moreSamples && tot < nn) { ISample[] tmp = _inputEnum.Read(DSPUtil.BUFSIZE, out nnn, out _moreSamples); for (int j = 0; j < nnn; j++) { _samples.Add(tmp[j]); } tot += nnn; } } return(nn < 0 || _moreSamples); }