/* Spectroscopic Toolkit version 1.94 by Pieter Suurmond, april 16, 2011. API headerfile to write (not read) AIFF files (from 54-bit integers). Copyright (c) 2000-2011 - Pieter Suurmond Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. Any person wishing to distribute modifications to the Software is requested to send the modifications to the original developer so that they can be incorporated into the canonical version. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*-----------------------------------------------------------------------------------*/ typedef struct AUDIOFILE* AUDIOFILEp; /* Forward declaration. Internal structure is */ /* private, defined and used only in ST_aiff.c. */ /*----------------------------------------------------------------------------*/ /* Tries to create a new AIFF file with name filename. If it succeeds, zero is returned and argument A receives an AUDIOFILE object. A negative error number is returned when handle A is NULL, filename is NULL or empty, or the number of channels or bits is invalid. Files created with openAIFFWRITE() must be closed with closeAIFFWRITE() because its' header needs to be rewritten. */ short openAIFFWRITE(AUDIOFILEp* A, /* Handle receiving AUDIOFILE object. */ const char* filename, /* Null-terminated string. */ long samplerate, /* In cycles per second. */ short channels, /* Number of interleaved channels. */ short bits); /* Number of bits per channel. */ /*----------------------------------------------------------------------------*/ /* Downscales, rounds and writes a number of sampleframes to file. To be fast, this function does NOT test its' arguments, so take care! Argument 'audio' should point to an interleaved buffer of signed 64-bit sampleframes (with not more than 54 bits effectively used!), containing at least 'frames' sampleframes. Argument A should point to an AUDIOFILE object, created earlier with function openAIFFWRITE(). Returns 0 on success. Returns 1 on over- or underflow (after completing buffer transfer to file). Returns 2 on write-errors (immediately, not attemting to complete file transfer). Returns 3 when file is becoming huge. */ short dumpAIFFWRITE(AUDIOFILEp A, const SIGNED64* audio, UNSIGNED32 frames); /*----------------------------------------------------------------------------*/ /* No problem when one or both arguments are NULL. */ void printAIFFWRITE(AUDIOFILEp A, FILE* to); /*----------------------------------------------------------------------------*/ /* Rewrites header info, closes the file, releases memory and clears the reference to the AUDIOFILE object. (dumpAIFFWRITE() counted number of frames, furthermore channels, bits and samplerate are remembered by the object itself. Returns 0 on success. Returns a negative error number on failures. */ short closeAIFFWRITE(AUDIOFILEp* A);