Encoding and decoding floats #28
Unanswered
LatteSoyMilkCookie
asked this question in
Q&A
Replies: 1 comment 3 replies
-
|
I'm not sure what could be the issue. Also are both of your decoder and encoder the same samplerate and channels? Also found a similar issue to yours. As suggested, try working with real audio samples like a sine wave and output it. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a stream of raw PCM samples stored as an array of floats that I want to encode then decode back into an array of floats.
The decoded audio does return an array of floats, but the values are all incredibly small, the first sample is -0.001953125 which turns into 3.0517578E-35, and it flipped from negative to positive! I understand OPUS is lossy, so I shouldn't expect the input and output to be exactly the same, but the decoded data cannot be turned back into pleasant audio like this.
Below is the code I'm using to encode and decode the array of floats:
float[] _currentData = new float[960] {PCM samples here};
byte[] encoded = new byte[1000];
int encodedBytes = encoder.Encode(_currentData, 960, encoded, encoded.Length);
float[] _decodedSamples = new float[960];
var decodedSamples = decoder.Decode(encoded , encodedBytes, _decodedSamples, 960, false);
Any help/advice is greatly appreciated, thank you!
Beta Was this translation helpful? Give feedback.
All reactions