/// <summary>
 /// Reads a part of the samples as floats from the sample provider.
 /// </summary>
 /// <param name="destination">The destination buffer that decoded samples are written to.</param>
 /// <returns>The number of samples that could be read. Will be less than the destination size when the end of the sound is reached.</returns>
 public int Read(NativeSlice <float> destination)
 {
     CheckValidAndThrow();
     return(DSPSampleProviderInternal.Internal_ReadFloatFromSampleProviderById(
                ProviderHandle, destination.GetUnsafePtr(),
                destination.Length));
 }
 /// <summary>
 /// Reads a part of the samples as bytes in the specified output format from the sample provider.
 /// </summary>
 /// <param name="destination">The destination buffer that decoded samples are written to.</param>
 /// <param name="format">The destination format that the samples are decoded to.</param>
 /// <returns>The number of samples that could be read. Will be less than the destination size when the end of the sound is reached.</returns>
 public int Read(NativeSlice <byte> destination, NativeFormatType format)
 {
     CheckValidAndThrow();
     // Not doing any format/size checks here. byte is the only valid choice for 8-bits,
     // 24-bits as well as big-endian float. Users may have reasons to want 16-bit samples
     // carried via a buffer-of-bytes, so we're being totally flexible here.
     return(DSPSampleProviderInternal.Internal_ReadUInt8FromSampleProviderById(
                ProviderHandle, (int)format, destination.GetUnsafePtr(),
                destination.Length));
 }
        /// <summary>
        /// Reads a part of the samples as short integers in the specified output format from the sample provider.
        /// </summary>
        /// <param name="destination">The destination buffer that decoded samples are written to.</param>
        /// <param name="format">The destination format that the samples are decoded to.</param>
        /// <returns>The number of samples that could be read. Will be less than the destination size when the end of the sound is reached.</returns>
        public int Read(NativeSlice <short> destination, NativeFormatType format)
        {
            CheckValidAndThrow();
            if (format != NativeFormatType.PCM16_LE && format != NativeFormatType.PCM16_BE)
            {
                throw new ArgumentException("Using buffer of short to capture samples of a different size.");
            }

            return(DSPSampleProviderInternal.Internal_ReadSInt16FromSampleProviderById(
                       ProviderHandle, (int)format,
                       destination.GetUnsafePtr(), destination.Length));
        }