PS2 VAG ADPCM File Format

  adpcm, audio, audio-converter, c++

I’m working on a project to convert form a headerless PS2 VAG file to WAV and from a WAV file to a headerless PS2 VAG file.

Until now the decoder works fine, but we are having issues with the encoder, I’ve created a GitHub repository with the project, is written in C#.
I would really appreciate if someone could tell me what’s wrong in the encoder code, for some reason the file that creates is corrupt…

enter image description here

Here’s the code:

I’ve been inspiring on this code written in C++, but I’m not an experienced programmer, and I’ve never programmed in that language, so probably I’d skipped some important things:

Thank you very much!!

Source: Windows Questions C++