dbry/adpcm-xq

lost samples

Closed this issue · 6 comments

Hello! I have a question about your library:
If i use adpcm_decode_block(...) function for data encoded by adpcm_encode_block(...) function, i have decoded data buffer a 7 samples shotrer then input buffer for encoding (the block size doesnt matter).
I'm not good at acoustic science, but i think it is not right, isn't it?

dbry commented

I think the most likely reason is that you must call adpcm_encode_block() with a inbufcount equal to one greater than a multiple of 8. If you use a multiple of 8, you will lose exactly 7 samples. You can read about this at the very top of the adpcm-lib.c file.

I hope this fixes your problem.

-David

dbry commented

Oops...I didn't mean to close the issue. Please comment if you still have trouble.

Thank you for response!
Yes, i tried inbuf equal to one greater than a multiple of 8 and i heard scratches in output sound. If i lose 7 samples there are much less scratches. Probably, this is my fault.
Anyway, this library provides the best quality of sound of all ADPCM codecs i have tried, so thank you very much for your help!

dbry commented

There should not be any transient sounds. You should be able to make sure the encoder/decoder is working correctly by using the command-line tester. Please feel free to let me know if you continue to have trouble, and I can perhaps look over your code.

I beleive encoder/decoder work fine in your application. I think my problem is the way of receiving incoming PCM data - it comes from PDM data and some filtering and decimation. In this case input data are always is buffer equal a multiple of 8 and it corrupts if i try to get one more sample.
I think this issue could be closed, thanks for your help!

dbry commented

Ah, okay. You'll have to create your own buffer then and keep track of the extra samples. Obviously just throwing away samples will not sound good. Good luck!