/// <summary> /// Reads decoded samples from the current logical stream /// </summary> /// <param name="buffer">The buffer to write the samples to.</param> /// <returns>The number of samples written</returns> public int ReadSamples(Span <float> buffer) { int samples = ActiveDecoder.ReadSamples(buffer); if (ClipSamples) { VorbisStreamDecoder decoder = _decoders[StreamIndex]; for (int i = 0; i < samples; i++) { buffer[i] = Utils.ClipValue(buffer[i], ref decoder._clipped); } } return(samples); }
/// <summary> /// Reads decoded samples from the current logical stream /// </summary> /// <param name="buffer">The buffer to write the samples to</param> /// <param name="offset">The offset into the buffer to write the samples to</param> /// <param name="count">The number of samples to write</param> /// <returns>The number of samples written</returns> public int ReadSamples(float[] buffer, int offset, int count) { if (offset < 0) { throw new ArgumentOutOfRangeException("offset"); } if (count < 0 || offset + count > buffer.Length) { throw new ArgumentOutOfRangeException("count"); } count = ActiveDecoder.ReadSamples(buffer, offset, count); if (ClipSamples) { var decoder = _decoders[_streamIdx]; for (int i = 0; i < count; i++, offset++) { buffer[offset] = Utils.ClipValue(buffer[offset], ref decoder._clipped); } } return(count); }
public int ReadSamples(float[] buffer, int offset, int count) { if (offset < 0) { throw new ArgumentOutOfRangeException("offset"); } if (count < 0 || offset + count > buffer.Length) { throw new ArgumentOutOfRangeException("count"); } count = ActiveDecoder.ReadSamples(buffer, offset, count); if (ClipSamples) { VorbisStreamDecoder vorbisStreamDecoder = _decoders[_streamIdx]; int num = 0; while (num < count) { buffer[offset] = Utils.ClipValue(buffer[offset], ref vorbisStreamDecoder._clipped); num++; offset++; } } return(count); }