StreamDataProvider.ReadBytes(buffer) returns zero array #14
-
Dear all, First of all, thank you for this amazing library.
When I debugged this piece of code, I realized that the float[] floats is actually filled with zero values. May I ask you what I'm missing here? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Although I haven't attempted to use
I've just tested the code you provided and it's working as expected. The example below allows me to play the raw audio file without any issues with results
I'm unable to reproduce the issue, but I'll keep the discussion open in case you can provide an example. It's possible that the issue lies with your audio file, try using a different one to see if the problem persists. and if your issue is resolved, feel free to close it otherwise. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your reply and the advice. Thank you again! |
Beta Was this translation helpful? Give feedback.
After some experiments, it appears that using BinaryWriter to return a stream, regardless of whether it's a MemoryStream or FileStream, results in values being written as zeros. However, when writing to a FileStream and then opening it with
File.OpenRead
, the data is written correctly,After further experiments, I found that BinaryWriter does not reset its position upon completion, resulting in the stream playing nothing. To resolve this, I added
wavStream.Position = 0;
beforewriter.Close();
, and the sound played correctly usingSoundFlowToMemoryStream
. Regarding the zeros at the beginning of the file, I think this may be related to the decoder and does not affect playback. Instead of ma…