TerrySoba / VocTool

MIT License
1 stars 1 forks source link

Support for multi-block ADPCM #1

Open viciious opened 1 week ago

viciious commented 1 week ago

Hello!

Thanks for writing and publishing your project on github! Getting VEDIT2 to work is such an ordeal, so VocTool is a godsend.

If I may, I'd like to suggest adding support for multi-block ADPCM files. Looking at the source code, it appears that source PCM data is always encoded as a single block, meaning the predictor is never reset when mean error gets too high. Or maybe just do that at fixed intervals to keep the error in line.

Cheers!

TerrySoba commented 1 week ago

Hi viciious,

I'm glad you find VocTool useful.

I've not done a thorough investigation of the usage of multi-block ADPCM files, so I cannot say how much this would improve audio quality. In my tests so far I have not seen a significant drift of the generated output in comparison with the original, so I have not bothered with it until now.

I have appended the image of a step response of the encoder with compression level 6. The above is the original. image I think this could be a good point for a new ADPCM block, as the step currently takes about 3 samples and makes it look more like slope.

Currently I don't have much time to work on VocTool, but if you are interested I'd be happy to merge a pull request by you that implements the feature. I'll also happily answer any question you have about the current code.

viciious commented 1 week ago

Ideally VocTool needs to be married with adpcm-xq's noise shaping algorithm that improves perceived audio fidelity and also its prediction initialization algorithm that minimizes the error.

UP: I actually did add support for Creative Lab's 4-bit ADPCM to adpcm-xq at some point, albeit getting away with the RIFF container format instead of VOC: https://github.com/viciious/adpcm-xq/blob/c9652e80f87557ac85e1c072026b330f00441bad/adpcm-lib.c

TerrySoba commented 1 week ago

That sounds very interesting. Currently VocTool pretty much brute forces the encoding of ADPCM and simply minimizes the squared error. No noise shaping at all.

The code you linked is quite intriguing, as I've not found any other open source Creative Lab's 4-bit ADPCM code before. If I find the time I might try to add adpcm-xq as an option in VocTool, but no promises ;)