49 public override int Read(
byte[] buffer,
int offset,
int count) {
50 ArgumentNullException.ThrowIfNull(buffer);
53 || offset + count > buffer.Length) {
54 throw new InvalidOperationException(
"Invalid range.");
57 byte[] sample =
new byte[count * 2];
58 int num =
m_reader.Read(sample, 0, count * 2);
59 for (
int i = 0; i < num; i += 4) {
60 float sample32Bit = BitConverter.ToSingle(sample, i);
61 short sample16Bit = (short)(sample32Bit *
short.MaxValue);
62 byte[] sampleBytes = BitConverter.GetBytes(sample16Bit);
63 buffer[offset++] = sampleBytes[0];
64 buffer[offset++] = sampleBytes[1];