Fix voice example for DCA0 audio #477
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When I first learned of DCA back in April and checked out the example in this repository, I grew quite frustrated (and many others probably have, too) since none of the DCA files I created myself using the original Go program following its manual worked at all but the
nico.dca
test file that is included in here happened to work just fine.I decided to have a closer look at it and realized that, for some obscure reason, its headers use 4 bytes as opposed to the actual
int16
type header the original DCA tool produces.I've done a bit of research, assuming
nico.dca
might have been created with an older iteration of DCA or something, but I couldn't really find anything specifying a header size other than 2 bytes.Anyways, this here fixes the
writeOpus
function in the voice example, now correctly readingDCA0
files.In the second commit I also included a bit of logic detecting and properly mitigating 4-byte-header
DCA0
files in case they're actually more common than how it seems. If that's not desired, I can easily just trim back the branch and updatenico.dca
to use 2-byte headers instead.