At these lines:
outfile = sf_open(path, SFM_WRITE, &sfinfo);
outfile2 = sf_open(uniqueFilename, SFM_WRITE, &sfinfo);
outfileAnalog = sf_open(pathAn, SFM_WRITE, &sfinfo);
outfileAnalog2 = sf_open(uniqueFilenameAn, SFM_WRITE, &sfinfo);
you are opening both your default path name (path
and pathAn
, respectively), and the unique ones (uniqueFilename
, uniqueFilenameAn
).
Then, you are writing to all of those files:
sf_write_float(outfile, &buf[0], ret);
sf_write_float(outfile2, &buf[0], ret);
sf_write_float(outfileAnalog, &bufAnalog[0], retAn);
sf_write_float(outfileAnalog2, &bufAnalog[0], retAn);
and closing them both:
sf_write_sync(outfile2);
sf_close(outfile2);
sf_write_sync(outfile);
sf_close(outfile);
sf_write_sync(outfileAnalog2);
sf_close(outfileAnalog2);
sf_write_sync(outfileAnalog);
sf_close(outfileAnalog);
Just remove all the lines, of the above, that deal with path
, pathAn
, outfile
, outfileAnalog
and you should be fine.