Comments (6)
Fixed it!
I was creating a new instance of the decoder every time I needed to use it.
Creating just one of them and re-using it for subsequent packets works flawlessly
from opus.
Hi Brandon, I think you forgot to attach the spectograms.
My first step for debugging this would be to compare the raw opus data extracted by your node and go programs: if they're equal, then the problem lies with decoding the packets. If they're not, then it's in the extraction of opus data from that proprietary stream.
I'd output them using something very easy to compare, e.g. a text file with one line of hex encoded binary data per line. If there is any diff, this makes it easy to identify where the issue is, hopefully.
If you've done that and the opus data is the same, I'd check one more thing: are you actually receiving raw opus packets, or are you receiving a OGG/Opus stream? (see the README for more details on this).
If you've done all that and you're sure it's raw opus data coming in and they're exactly the same between nodejs and go, I'd have another close look at the initialisation of the decoder: are all the parameters passed exactly right? Are you extracting the resulting PCM data correctly? Are you handling the mono vs stereo case correctly? (NB that libopus returns a single channel as a single array, which might not fit your PCM device API).
For context: this wrapper is extremely thin. It doesn't do any allocation or data handling of the actual audio: it's a direct, zerocopy passthrough to libopus. If the Node.JS lib you're using does some smarter handling of the data, there's another avenue for bugs to creep in when switching to this lib.
Good luck
from opus.
I'm closing this until further update indicates that it is specifically an issue with this library.
from opus.
Thanks for the very helpful reply!
After a great deal more debugging, I didn't get any further.
The data was the exact same going into the decoder in my Go project as in my Node project.
I also tried another Go Opus library but got the same result - so it's clearly not a problem specifically with this library.
Still, the mystery remains
from opus.
@brandonsturgeon what was the node library you were using?
from opus.
We're using Discord's Opus library: https://github.com/discordjs/opus
Comparing your call to libopus:
n := int(C.opus_decode(
dec.p,
(*C.uchar)(&data[0]),
C.opus_int32(len(data)),
(*C.opus_int16)(&pcm[0]),
C.int(cap(pcm)/dec.channels),
0))
To discordjs':
int decodedSamples = opus_decode(
this->decoder,
compressedData,
compressedDataLength,
&(this->outPcm[0]),
MAX_FRAME_SIZE,
/* decode_fec */ 0
);
They're practically identical, so... I have no idea.
To my eyes, the only difference is the second-to-last parameter.
You use the size of the input buffer. They use MAX_FRAME_SIZE
, which I believe is:
#define MAX_FRAME_SIZE 6 * 960
I actually tried modifying your opus
to use 6 * 960
in that parameter and found zero difference in the output. Still garbled.
from opus.
Related Issues (20)
- transfer pcm to opus HOT 2
- run error HOT 2
- Forward error correction flag in decode (decode_fec flag) HOT 9
- How to find sample rate of a stream? HOT 2
- How can I play opus codec audio by using portaudio? HOT 1
- Opus 1.3 release,would we update to new version? HOT 1
- There is a difference between an opus stream (which is an ogg/opus stream) and raw opus data. .opus files are really .ogg files with opus data, which this package doesn't provide a way to write. It does have a reader for it (Stream type), but no writer yet (never bothered to because I haven't needed it so far, but feel free to submit a PR). HOT 2
- transfer pcm to raw opus HOT 7
- "checkptr: unsafe pointer arithmetic" when using go race detector HOT 1
- How to complie in cross platform? HOT 5
- Inconsistent types in README HOT 1
- encoder: invalid argument HOT 1
- Amplify ogg stream? HOT 2
- Byte slice to int16 slice. HOT 2
- How to destroy en(de)coder state? HOT 2
- Get audio from microphone and encode to ogg HOT 1
- Decode: corrupted stream HOT 3
- Set encoder bitrate HOT 5
- Declare constants as actual const
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opus.