I am trying to write audio files (.aif) from an msp external i am working on.
A file is written successfully, however, it does not open
in QT for example (stating end-of-file not found).
I am wondering where I am going wrong. Do I not have to write .aiff header information before writing my data or is this
handled by the sys API since I specify my file type as being ‘AIFF’.
Here is a snippet of my code:
// create file name to save .aif file as
char fileName = "doormouse";
short path = defvolume();
long type = ‘AIFF';
long fileSizeBytes = sizeof(float) * wsf->tableSize;
I’m pretty sure that creating the file as AIFF just tells the OS that the file should be treated as an AIFF file (regardless of whether the data is valid). Looking at your code you’ll have a RAW 32-bit floating point audio file.
You need to write the data into the file according to the AIFF spec. So yes you’d need to write header data and audio data as AIFF "chunks". You’d probably need to convert the floating point format to 8, 16, 24 or 32 bit signed ints too, I’m fairly sure AIFF doesn’t support float.