public SubSeekableAudioStream(ISeekableAudioStream parent, Timestamp start, Timestamp end, bool disposeAfterUse = true) { _parent = parent; _disposeAfterUse = disposeAfterUse; _start = AudioStreamHelper.ConvertTimeToStreamPos(start, Rate, IsStereo); _pos = new Timestamp(0, Rate * (IsStereo ? 2 : 1)); _length = AudioStreamHelper.ConvertTimeToStreamPos(end, Rate, IsStereo) - _start; Debug.Assert(_length.TotalNumberOfFrames % (IsStereo ? 2 : 1) == 0); _parent.Seek(_start); }
public bool Seek(Timestamp where) { _pos = AudioStreamHelper.ConvertTimeToStreamPos(where, Rate, IsStereo); if (_pos > _length) { _pos = _length; return(false); } if (_parent.Seek(_pos + _start)) { return(true); } else { _pos = _length; return(false); } }