Advertisement
Kurausukun

Untitled

Mar 11th, 2023
850
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.23 KB | None | 0 0
  1. int main(int argc, char * argv[]) {
  2.     struct Swav swav;
  3.     FILE * infile, * outfile1, * outfile2;
  4.     char * infilename = argv[1], * outfilename = argv[2];
  5.     int lookahead = 3, flags = ADPCM_FLAG_RAW_OUTPUT, blocksize_pow2 = 0, overwrite = 0;
  6.     struct AdpcmData adpcmData = adpcm_converter(infilename, outfilename, flags, blocksize_pow2, lookahead);
  7.     outfile1 = adpcmData.file;
  8.     outfile2 = fopen(strncat(outfilename, ".swav", 6), "wb");
  9.     fseek(outfile1, 0, SEEK_SET);
  10.     swav.file.type[0] = 'S';
  11.     swav.file.type[1] = 'W';
  12.     swav.file.type[2] = 'A';
  13.     swav.file.type[3] = 'V';
  14.     swav.file.magic = 0x0100feff;
  15.     swav.file.fileSize = adpcmData.size + 20 + 16;
  16.     swav.file.structSize = 16;
  17.     swav.file.numBlocks = 1;
  18.     swav.data.info.waveType = 2;
  19.     swav.data.info.loop = 1;
  20.     swav.data.info.sampleRate = adpcmData.sampleRate;
  21.     swav.data.info.loopOffset = 0;
  22.     swav.data.info.loopLength = adpcmData.numSamples;
  23.     swav.data.type[0] = 'D';
  24.     swav.data.type[1] = 'A';
  25.     swav.data.type[2] = 'T';
  26.     swav.data.type[3] = 'A';
  27.     swav.data.size = swav.file.fileSize - 16;
  28.     fread(swav.data.data, adpcmData.size, 1, outfile1);
  29.     return fwrite(&swav, swav.file.fileSize, 1, outfile2);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement