Home | History | Annotate | Download | only in include
      1 /*
      2 	Audio File Library
      3 	Copyright (C) 1998-2000, 2010-2011, Michael Pruett <michael (at) 68k.org>
      4 
      5 	This library is free software; you can redistribute it and/or
      6 	modify it under the terms of the GNU Library General Public
      7 	License as published by the Free Software Foundation; either
      8 	version 2 of the License, or (at your option) any later version.
      9 
     10 	This library is distributed in the hope that it will be useful,
     11 	but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13 	Library General Public License for more details.
     14 
     15 	You should have received a copy of the GNU Library General Public
     16 	License along with this library; if not, write to the
     17 	Free Software Foundation, Inc., 59 Temple Place - Suite 330,
     18 	Boston, MA  02111-1307  USA.
     19 */
     20 
     21 /*
     22 	audiofile.h
     23 
     24 	This file contains the public interfaces to the Audio File Library.
     25 */
     26 
     27 #ifndef AUDIOFILE_H
     28 #define AUDIOFILE_H
     29 
     30 #include <aupvlist.h>
     31 #include <stdint.h>
     32 #include <sys/types.h>
     33 
     34 #define LIBAUDIOFILE_MAJOR_VERSION 0
     35 #define LIBAUDIOFILE_MINOR_VERSION 3
     36 #define LIBAUDIOFILE_MICRO_VERSION 3
     37 
     38 #ifdef __cplusplus
     39 extern "C" {
     40 #endif
     41 
     42 typedef struct _AFvirtualfile AFvirtualfile;
     43 
     44 typedef struct _AFfilesetup *AFfilesetup;
     45 typedef struct _AFfilehandle *AFfilehandle;
     46 typedef void (*AFerrfunc)(long, const char *);
     47 
     48 // Define AFframecount and AFfileoffset as 64-bit signed integers.
     49 #if defined(__FreeBSD__) || \
     50 	defined(__DragonFly__) || \
     51 	defined(__NetBSD__) || \
     52 	defined(__OpenBSD__) || \
     53 	defined(__APPLE__) || \
     54 	defined(__sgi) || \
     55 	(defined(__linux__) && defined(__LP64__))
     56 // BSD and IRIX systems define off_t as a 64-bit signed integer.
     57 // Linux defines off_t as a 64-bit signed integer in LP64 mode.
     58 typedef off_t AFframecount;
     59 typedef off_t AFfileoffset;
     60 #else
     61 // For all other systems, use int64_t.
     62 typedef int64_t AFframecount;
     63 typedef int64_t AFfileoffset;
     64 #endif
     65 
     66 #define AF_NULL_FILESETUP	((struct _AFfilesetup *) 0)
     67 #define AF_NULL_FILEHANDLE	((struct _AFfilehandle *) 0)
     68 
     69 #define AF_ERR_BASE 3000
     70 
     71 enum
     72 {
     73 	AF_DEFAULT_TRACK = 1001
     74 };
     75 
     76 enum
     77 {
     78 	AF_DEFAULT_INST = 2001
     79 };
     80 
     81 enum
     82 {
     83 	AF_NUM_UNLIMITED = 99999
     84 };
     85 
     86 enum
     87 {
     88 	AF_BYTEORDER_BIGENDIAN = 501,
     89 	AF_BYTEORDER_LITTLEENDIAN = 502
     90 };
     91 
     92 enum
     93 {
     94 	AF_FILE_UNKNOWN = -1,
     95 	AF_FILE_RAWDATA = 0,
     96 	AF_FILE_AIFFC = 1,
     97 	AF_FILE_AIFF = 2,
     98 	AF_FILE_NEXTSND = 3,
     99 	AF_FILE_WAVE = 4,
    100 	AF_FILE_BICSF = 5,
    101 	AF_FILE_IRCAM = AF_FILE_BICSF,
    102 	AF_FILE_MPEG1BITSTREAM = 6,	/* not implemented */
    103 	AF_FILE_SOUNDDESIGNER1 = 7,	/* not implemented */
    104 	AF_FILE_SOUNDDESIGNER2 = 8,	/* not implemented */
    105 	AF_FILE_AVR = 9,
    106 	AF_FILE_IFF_8SVX = 10,
    107 	AF_FILE_SAMPLEVISION = 11,	/* not implemented */
    108 	AF_FILE_VOC = 12,
    109 	AF_FILE_NIST_SPHERE = 13,
    110 	AF_FILE_SOUNDFONT2 = 14,	/* not implemented */
    111 	AF_FILE_CAF = 15
    112 };
    113 
    114 enum
    115 {
    116 	AF_LOOP_MODE_NOLOOP = 0,
    117 	AF_LOOP_MODE_FORW = 1,
    118 	AF_LOOP_MODE_FORWBAKW = 2
    119 };
    120 
    121 enum
    122 {
    123 	AF_SAMPFMT_TWOSCOMP = 401, /* linear two's complement */
    124 	AF_SAMPFMT_UNSIGNED = 402, /* unsigned integer */
    125 	AF_SAMPFMT_FLOAT = 403, /* 32-bit IEEE floating-point */
    126 	AF_SAMPFMT_DOUBLE = 404 /* 64-bit IEEE double-precision floating-point */
    127 };
    128 
    129 enum
    130 {
    131 	AF_INST_LOOP_OFF = 0,			/* no looping */
    132 	AF_INST_LOOP_CONTINUOUS = 1,	/* loop continuously through decay */
    133 	AF_INST_LOOP_SUSTAIN = 3		/* loop during sustain, then continue */
    134 };
    135 
    136 enum
    137 {
    138 	AF_INST_MIDI_BASENOTE = 301,
    139 	AF_INST_NUMCENTS_DETUNE = 302,
    140 	AF_INST_MIDI_LONOTE = 303,
    141 	AF_INST_MIDI_HINOTE = 304,
    142 	AF_INST_MIDI_LOVELOCITY = 305,
    143 	AF_INST_MIDI_HIVELOCITY = 306,
    144 	AF_INST_NUMDBS_GAIN = 307,
    145 	AF_INST_SUSLOOPID = 308,		/* loop id for AIFF sustain loop */
    146 	AF_INST_RELLOOPID = 309,		/* loop id for AIFF release loop */
    147 	AF_INST_SAMP_STARTFRAME = 310,	/* start sample for this inst */
    148 	AF_INST_SAMP_ENDFRAME = 311,	/* end sample for this inst */
    149 	AF_INST_SAMP_MODE = 312,		/* looping mode for this inst */
    150 	AF_INST_TRACKID = 313,
    151 	AF_INST_NAME = 314,				/* name of this inst */
    152 	AF_INST_SAMP_RATE = 315,		/* sample rate of this inst's sample */
    153 	AF_INST_PRESETID = 316,			/* ID of preset containing this inst */
    154 	AF_INST_PRESET_NAME = 317		/* name of preset containing this inst */
    155 };
    156 
    157 enum
    158 {
    159 	AF_MISC_UNRECOGNIZED = 0,	/* unrecognized data chunk */
    160 	AF_MISC_COPY = 201,	/* copyright string */
    161 	AF_MISC_AUTH = 202,	/* author string */
    162 	AF_MISC_NAME = 203,	/* name string */
    163 	AF_MISC_ANNO = 204,	/* annotation string */
    164 	AF_MISC_APPL = 205,	/* application-specific data */
    165 	AF_MISC_MIDI = 206,	/* MIDI exclusive data */
    166 	AF_MISC_PCMMAP = 207,	/* PCM mapping information (future use) */
    167 	AF_MISC_NeXT = 208,	/* misc binary data appended to NeXT header */
    168 	AF_MISC_IRCAM_PEAKAMP = 209,	/* peak amplitude information */
    169 	AF_MISC_IRCAM_COMMENT = 210,	/* BICSF text comment */
    170 	AF_MISC_COMMENT = 210,	/* general text comment */
    171 
    172 	AF_MISC_ICMT = AF_MISC_COMMENT,	/* comments chunk (WAVE format) */
    173 	AF_MISC_ICRD = 211,  /* creation date (WAVE format) */
    174 	AF_MISC_ISFT = 212  /* software name (WAVE format) */
    175 };
    176 
    177 enum
    178 {
    179 	/* supported compression schemes */
    180 	AF_COMPRESSION_UNKNOWN = -1,
    181 	AF_COMPRESSION_NONE = 0,
    182 	AF_COMPRESSION_G722 = 501,
    183 	AF_COMPRESSION_G711_ULAW = 502,
    184 	AF_COMPRESSION_G711_ALAW = 503,
    185 
    186 	/* Apple proprietary AIFF-C compression schemes (not supported) */
    187 	AF_COMPRESSION_APPLE_ACE2 = 504,
    188 	AF_COMPRESSION_APPLE_ACE8 = 505,
    189 	AF_COMPRESSION_APPLE_MAC3 = 506,
    190 	AF_COMPRESSION_APPLE_MAC6 = 507,
    191 
    192 	AF_COMPRESSION_G726 = 517,
    193 	AF_COMPRESSION_G728 = 518,
    194 	AF_COMPRESSION_DVI_AUDIO = 519,
    195 	AF_COMPRESSION_IMA = AF_COMPRESSION_DVI_AUDIO,
    196 	AF_COMPRESSION_GSM = 520,
    197 	AF_COMPRESSION_FS1016 = 521,
    198 	AF_COMPRESSION_DV = 522,
    199 	AF_COMPRESSION_MS_ADPCM = 523
    200 };
    201 
    202 /* tokens for afQuery() -- see the man page for instructions */
    203 /* level 1 selectors */
    204 enum
    205 {
    206 	AF_QUERYTYPE_INSTPARAM = 500,
    207 	AF_QUERYTYPE_FILEFMT = 501,
    208 	AF_QUERYTYPE_COMPRESSION = 502,
    209 	AF_QUERYTYPE_COMPRESSIONPARAM = 503,
    210 	AF_QUERYTYPE_MISC = 504,
    211 	AF_QUERYTYPE_INST = 505,
    212 	AF_QUERYTYPE_MARK = 506,
    213 	AF_QUERYTYPE_LOOP = 507
    214 };
    215 
    216 /* level 2 selectors */
    217 enum
    218 {
    219 	AF_QUERY_NAME = 600,	/* get name (1-3 words) */
    220 	AF_QUERY_DESC = 601,	/* get description */
    221 	AF_QUERY_LABEL = 602,	/* get 4- or 5-char label */
    222 	AF_QUERY_TYPE = 603,	/* get type token */
    223 	AF_QUERY_DEFAULT = 604,	/* dflt. value for param */
    224 	AF_QUERY_ID_COUNT = 605,	/* get number of ids avail. */
    225 	AF_QUERY_IDS = 606,	/* get array of id tokens */
    226 	AF_QUERY_IMPLEMENTED = 613,	/* boolean */
    227 	AF_QUERY_TYPE_COUNT = 607,	/* get number of types av. */
    228 	AF_QUERY_TYPES = 608,	/* get array of types */
    229 	AF_QUERY_NATIVE_SAMPFMT = 609,	/* for compression */
    230 	AF_QUERY_NATIVE_SAMPWIDTH = 610,
    231 	AF_QUERY_SQUISHFAC = 611,	/* 1.0 means variable */
    232 	AF_QUERY_MAX_NUMBER = 612,	/* max allowed in file */
    233 	AF_QUERY_SUPPORTED = 613	/* insts, loops, etc., supported? */
    234 };
    235 
    236 /* level 2 selectors which have sub-selectors */
    237 enum
    238 {
    239 	AF_QUERY_TRACKS = 620,
    240 	AF_QUERY_CHANNELS = 621,
    241 	AF_QUERY_SAMPLE_SIZES = 622,
    242 	AF_QUERY_SAMPLE_FORMATS = 623,
    243 	AF_QUERY_COMPRESSION_TYPES = 624
    244 };
    245 
    246 /* level 3 sub-selectors */
    247 enum
    248 {
    249 	AF_QUERY_VALUE_COUNT = 650,	/* number of values of the above */
    250 	AF_QUERY_VALUES = 651	/* array of those values */
    251 };
    252 
    253 
    254 /*
    255 	Old Audio File Library error codes. These are still returned by the
    256 	AFerrorhandler calls, but are not used by the new digital media library
    257 	error reporting routines. See the bottom of this file for the new error
    258 	tokens.
    259 */
    260 
    261 enum
    262 {
    263 	AF_BAD_NOT_IMPLEMENTED = 0,	/* not implemented yet */
    264 	AF_BAD_FILEHANDLE = 1,	/* tried to use invalid filehandle */
    265 	AF_BAD_OPEN = 3,	/* unix open failed */
    266 	AF_BAD_CLOSE = 4,	/* unix close failed */
    267 	AF_BAD_READ = 5,	/* unix read failed */
    268 	AF_BAD_WRITE = 6,	/* unix write failed */
    269 	AF_BAD_LSEEK = 7,	/* unix lseek failed */
    270 	AF_BAD_NO_FILEHANDLE = 8,	/* failed to allocate a filehandle struct */
    271 	AF_BAD_ACCMODE = 10,	/* unrecognized audio file access mode */
    272 	AF_BAD_NOWRITEACC = 11,	/* file not open for writing */
    273 	AF_BAD_NOREADACC = 12,	/* file not open for reading */
    274 	AF_BAD_FILEFMT = 13,	/* unrecognized audio file format */
    275 	AF_BAD_RATE = 14,	/* invalid sample rate */
    276 	AF_BAD_CHANNELS = 15,	/* invalid number of channels*/
    277 	AF_BAD_SAMPCNT = 16,	/* invalid sample count */
    278 	AF_BAD_WIDTH = 17,	/* invalid sample width */
    279 	AF_BAD_SEEKMODE = 18,	/* invalid seek mode */
    280 	AF_BAD_NO_LOOPDATA = 19,	/* failed to allocate loop struct */
    281 	AF_BAD_MALLOC = 20,	/* malloc failed somewhere */
    282 	AF_BAD_LOOPID = 21,
    283 	AF_BAD_SAMPFMT = 22,	/* bad sample format */
    284 	AF_BAD_FILESETUP = 23,	/* bad file setup structure*/
    285 	AF_BAD_TRACKID = 24,	/* no track corresponding to id */
    286 	AF_BAD_NUMTRACKS = 25,	/* wrong number of tracks for file format */
    287 	AF_BAD_NO_FILESETUP = 26,	/* failed to allocate a filesetup struct*/
    288 	AF_BAD_LOOPMODE = 27,	/* unrecognized loop mode value */
    289 	AF_BAD_INSTID = 28,	/* invalid instrument id */
    290 	AF_BAD_NUMLOOPS = 29,	/* bad number of loops */
    291 	AF_BAD_NUMMARKS = 30,	/* bad number of markers */
    292 	AF_BAD_MARKID = 31,	/* bad marker id */
    293 	AF_BAD_MARKPOS = 32,	/* invalid marker position value */
    294 	AF_BAD_NUMINSTS = 33,	/* invalid number of instruments */
    295 	AF_BAD_NOAESDATA = 34,
    296 	AF_BAD_MISCID = 35,
    297 	AF_BAD_NUMMISC = 36,
    298 	AF_BAD_MISCSIZE = 37,
    299 	AF_BAD_MISCTYPE = 38,
    300 	AF_BAD_MISCSEEK = 39,
    301 	AF_BAD_STRLEN = 40,	/* invalid string length */
    302 	AF_BAD_RATECONV = 45,
    303 	AF_BAD_SYNCFILE = 46,
    304 	AF_BAD_CODEC_CONFIG = 47,	/* improperly configured codec */
    305 	AF_BAD_CODEC_STATE = 48,	/* invalid codec state: can't recover */
    306 	AF_BAD_CODEC_LICENSE = 49,	/* no license available for codec */
    307 	AF_BAD_CODEC_TYPE = 50,	/* unsupported codec type */
    308 	AF_BAD_COMPRESSION = AF_BAD_CODEC_CONFIG,	/* for back compat */
    309 	AF_BAD_COMPTYPE = AF_BAD_CODEC_TYPE,	/* for back compat */
    310 
    311 	AF_BAD_INSTPTYPE = 51,	/* invalid instrument parameter type */
    312 	AF_BAD_INSTPID = 52,	/* invalid instrument parameter id */
    313 	AF_BAD_BYTEORDER = 53,
    314 	AF_BAD_FILEFMT_PARAM = 54,	/* unrecognized file format parameter */
    315 	AF_BAD_COMP_PARAM = 55,	/* unrecognized compression parameter */
    316 	AF_BAD_DATAOFFSET = 56,	/* bad data offset */
    317 	AF_BAD_FRAMECNT = 57,	/* bad frame count */
    318 	AF_BAD_QUERYTYPE = 58,	/* bad query type */
    319 	AF_BAD_QUERY = 59,	/* bad argument to afQuery() */
    320 	AF_WARNING_CODEC_RATE = 60,	/* using 8k instead of codec rate 8012 */
    321 	AF_WARNING_RATECVT = 61,	/* warning about rate conversion used */
    322 
    323 	AF_BAD_HEADER = 62,	/* failed to parse header */
    324 	AF_BAD_FRAME = 63,	/* bad frame number */
    325 	AF_BAD_LOOPCOUNT = 64,	/* bad loop count */
    326 	AF_BAD_DMEDIA_CALL = 65,	/* error in dmedia subsystem call */
    327 
    328 	/* AIFF/AIFF-C specific errors when parsing file header */
    329 	AF_BAD_AIFF_HEADER = 108,	/* failed to parse chunk header */
    330 	AF_BAD_AIFF_FORM = 109,	/* failed to parse FORM chunk */
    331 	AF_BAD_AIFF_SSND = 110,	/* failed to parse SSND chunk */
    332 	AF_BAD_AIFF_CHUNKID = 111,	/* unrecognized AIFF/AIFF-C chunk id */
    333 	AF_BAD_AIFF_COMM = 112,	/* failed to parse COMM chunk */
    334 	AF_BAD_AIFF_INST = 113,	/* failed to parse INST chunk */
    335 	AF_BAD_AIFF_MARK = 114,	/* failed to parse MARK chunk */
    336 	AF_BAD_AIFF_SKIP = 115,	/* failed to skip unsupported chunk */
    337 	AF_BAD_AIFF_LOOPMODE = 116	/* unrecognized loop mode (forw, etc)*/
    338 };
    339 
    340 /* new error codes which may be retrieved via dmGetError() */
    341 /* The old error tokens continue to be retrievable via the AFerrorhandler */
    342 /* AF_ERR_BASE is #defined in dmedia/dmedia.h */
    343 
    344 enum
    345 {
    346 	AF_ERR_NOT_IMPLEMENTED = 0+AF_ERR_BASE,	/* not implemented yet */
    347 	AF_ERR_BAD_FILEHANDLE = 1+AF_ERR_BASE,	/* invalid filehandle */
    348 	AF_ERR_BAD_READ = 5+AF_ERR_BASE,	/* unix read failed */
    349 	AF_ERR_BAD_WRITE = 6+AF_ERR_BASE,	/* unix write failed */
    350 	AF_ERR_BAD_LSEEK = 7+AF_ERR_BASE,	/* unix lseek failed */
    351 	AF_ERR_BAD_ACCMODE = 10+AF_ERR_BASE,	/* unrecognized audio file access mode */
    352 	AF_ERR_NO_WRITEACC = 11+AF_ERR_BASE,	/* file not open for writing */
    353 	AF_ERR_NO_READACC = 12+AF_ERR_BASE,	/* file not open for reading */
    354 	AF_ERR_BAD_FILEFMT = 13+AF_ERR_BASE,	/* unrecognized audio file format */
    355 	AF_ERR_BAD_RATE = 14+AF_ERR_BASE,	/* invalid sample rate */
    356 	AF_ERR_BAD_CHANNELS = 15+AF_ERR_BASE,	/* invalid # channels*/
    357 	AF_ERR_BAD_SAMPCNT = 16+AF_ERR_BASE,	/* invalid sample count */
    358 	AF_ERR_BAD_WIDTH = 17+AF_ERR_BASE,	/* invalid sample width */
    359 	AF_ERR_BAD_SEEKMODE = 18+AF_ERR_BASE,	/* invalid seek mode */
    360 	AF_ERR_BAD_LOOPID = 21+AF_ERR_BASE,	/* invalid loop id */
    361 	AF_ERR_BAD_SAMPFMT = 22+AF_ERR_BASE,	/* bad sample format */
    362 	AF_ERR_BAD_FILESETUP = 23+AF_ERR_BASE,	/* bad file setup structure*/
    363 	AF_ERR_BAD_TRACKID = 24+AF_ERR_BASE,	/* no track corresponding to id */
    364 	AF_ERR_BAD_NUMTRACKS = 25+AF_ERR_BASE,	/* wrong number of tracks for file format */
    365 	AF_ERR_BAD_LOOPMODE = 27+AF_ERR_BASE,	/* unrecognized loop mode symbol */
    366 	AF_ERR_BAD_INSTID = 28+AF_ERR_BASE,	/* invalid instrument id */
    367 	AF_ERR_BAD_NUMLOOPS = 29+AF_ERR_BASE,	/* bad number of loops */
    368 	AF_ERR_BAD_NUMMARKS = 30+AF_ERR_BASE,	/* bad number of markers */
    369 	AF_ERR_BAD_MARKID = 31+AF_ERR_BASE,	/* bad marker id */
    370 	AF_ERR_BAD_MARKPOS = 32+AF_ERR_BASE,	/* invalid marker position value */
    371 	AF_ERR_BAD_NUMINSTS = 33+AF_ERR_BASE,	/* invalid number of instruments */
    372 	AF_ERR_BAD_NOAESDATA = 34+AF_ERR_BASE,
    373 	AF_ERR_BAD_MISCID = 35+AF_ERR_BASE,
    374 	AF_ERR_BAD_NUMMISC = 36+AF_ERR_BASE,
    375 	AF_ERR_BAD_MISCSIZE = 37+AF_ERR_BASE,
    376 	AF_ERR_BAD_MISCTYPE = 38+AF_ERR_BASE,
    377 	AF_ERR_BAD_MISCSEEK = 39+AF_ERR_BASE,
    378 	AF_ERR_BAD_STRLEN = 40+AF_ERR_BASE,	/* invalid string length */
    379 	AF_ERR_BAD_RATECONV = 45+AF_ERR_BASE,
    380 	AF_ERR_BAD_SYNCFILE = 46+AF_ERR_BASE,
    381 	AF_ERR_BAD_CODEC_CONFIG = 47+AF_ERR_BASE,	/* improperly configured codec */
    382 	AF_ERR_BAD_CODEC_TYPE = 50+AF_ERR_BASE,	/* unsupported codec type */
    383 	AF_ERR_BAD_INSTPTYPE = 51+AF_ERR_BASE,	/* invalid instrument parameter type */
    384 	AF_ERR_BAD_INSTPID = 52+AF_ERR_BASE,	/* invalid instrument parameter id */
    385 
    386 	AF_ERR_BAD_BYTEORDER = 53+AF_ERR_BASE,
    387 	AF_ERR_BAD_FILEFMT_PARAM = 54+AF_ERR_BASE,	/* unrecognized file format parameter */
    388 	AF_ERR_BAD_COMP_PARAM = 55+AF_ERR_BASE,	/* unrecognized compression parameter */
    389 	AF_ERR_BAD_DATAOFFSET = 56+AF_ERR_BASE,	/* bad data offset */
    390 	AF_ERR_BAD_FRAMECNT = 57+AF_ERR_BASE,	/* bad frame count */
    391 
    392 	AF_ERR_BAD_QUERYTYPE = 58+AF_ERR_BASE,	/* bad query type */
    393 	AF_ERR_BAD_QUERY = 59+AF_ERR_BASE,	/* bad argument to afQuery() */
    394 	AF_ERR_BAD_HEADER = 62+AF_ERR_BASE,	/* failed to parse header */
    395 	AF_ERR_BAD_FRAME = 63+AF_ERR_BASE,	/* bad frame number */
    396 	AF_ERR_BAD_LOOPCOUNT = 64+AF_ERR_BASE,	/* bad loop count */
    397 
    398 	/* AIFF/AIFF-C specific errors when parsing file header */
    399 
    400 	AF_ERR_BAD_AIFF_HEADER = 66+AF_ERR_BASE,	/* failed to parse chunk header */
    401 	AF_ERR_BAD_AIFF_FORM = 67+AF_ERR_BASE,	/* failed to parse FORM chunk */
    402 	AF_ERR_BAD_AIFF_SSND = 68+AF_ERR_BASE,	/* failed to parse SSND chunk */
    403 	AF_ERR_BAD_AIFF_CHUNKID = 69+AF_ERR_BASE,	/* unrecognized AIFF/AIFF-C chunk id */
    404 	AF_ERR_BAD_AIFF_COMM = 70+AF_ERR_BASE,	/* failed to parse COMM chunk */
    405 	AF_ERR_BAD_AIFF_INST = 71+AF_ERR_BASE,	/* failed to parse INST chunk */
    406 	AF_ERR_BAD_AIFF_MARK = 72+AF_ERR_BASE,	/* failed to parse MARK chunk */
    407 	AF_ERR_BAD_AIFF_SKIP = 73+AF_ERR_BASE,	/* failed to skip unsupported chunk */
    408 	AF_ERR_BAD_AIFF_LOOPMODE = 74+AF_ERR_BASE	/* unrecognized loop mode (forw, etc) */
    409 };
    410 
    411 
    412 /* global routines */
    413 AFerrfunc afSetErrorHandler (AFerrfunc efunc);
    414 
    415 /* query routines */
    416 AUpvlist afQuery (int querytype, int arg1, int arg2, int arg3, int arg4);
    417 long afQueryLong (int querytype, int arg1, int arg2, int arg3, int arg4);
    418 double afQueryDouble (int querytype, int arg1, int arg2, int arg3, int arg4);
    419 void *afQueryPointer (int querytype, int arg1, int arg2, int arg3, int arg4);
    420 
    421 /* basic operations on file handles and file setups */
    422 AFfilesetup afNewFileSetup (void);
    423 void afFreeFileSetup (AFfilesetup);
    424 int afIdentifyFD (int);
    425 int afIdentifyNamedFD (int, const char *filename, int *implemented);
    426 
    427 AFfilehandle afOpenFile (const char *filename, const char *mode,
    428 	AFfilesetup setup);
    429 AFfilehandle afOpenVirtualFile (AFvirtualfile *vfile, const char *mode,
    430 	AFfilesetup setup);
    431 AFfilehandle afOpenFD (int fd, const char *mode, AFfilesetup setup);
    432 AFfilehandle afOpenNamedFD (int fd, const char *mode, AFfilesetup setup,
    433 	const char *filename);
    434 
    435 void afSaveFilePosition (AFfilehandle file);
    436 void afRestoreFilePosition (AFfilehandle file);
    437 int afSyncFile (AFfilehandle file);
    438 int afCloseFile (AFfilehandle file);
    439 
    440 void afInitFileFormat (AFfilesetup, int format);
    441 int afGetFileFormat (AFfilehandle, int *version);
    442 
    443 /* track */
    444 void afInitTrackIDs (AFfilesetup, const int *trackids, int trackCount);
    445 int afGetTrackIDs (AFfilehandle, int *trackids);
    446 
    447 /* track data: reading, writng, seeking, sizing frames */
    448 int afReadFrames (AFfilehandle, int track, void *buffer, int frameCount);
    449 int afWriteFrames (AFfilehandle, int track, const void *buffer, int frameCount);
    450 AFframecount afSeekFrame (AFfilehandle, int track, AFframecount frameoffset);
    451 AFframecount afTellFrame (AFfilehandle, int track);
    452 AFfileoffset afGetTrackBytes (AFfilehandle, int track);
    453 float afGetFrameSize (AFfilehandle, int track, int expand3to4);
    454 float afGetVirtualFrameSize (AFfilehandle, int track, int expand3to4);
    455 
    456 /* track data: AES data */
    457 /* afInitAESChannelData is obsolete -- use afInitAESChannelDataTo() */
    458 void afInitAESChannelData (AFfilesetup, int track); /* obsolete */
    459 void afInitAESChannelDataTo (AFfilesetup, int track, int willBeData);
    460 int afGetAESChannelData (AFfilehandle, int track, unsigned char buf[24]);
    461 void afSetAESChannelData (AFfilehandle, int track, unsigned char buf[24]);
    462 
    463 /* track data: byte order */
    464 void afInitByteOrder (AFfilesetup, int track, int byteOrder);
    465 int afGetByteOrder (AFfilehandle, int track);
    466 int afSetVirtualByteOrder (AFfilehandle, int track, int byteOrder);
    467 int afGetVirtualByteOrder (AFfilehandle, int track);
    468 
    469 /* track data: number of channels */
    470 void afInitChannels (AFfilesetup, int track, int nchannels);
    471 int afGetChannels (AFfilehandle, int track);
    472 int afSetVirtualChannels (AFfilehandle, int track, int channelCount);
    473 int afGetVirtualChannels (AFfilehandle, int track);
    474 void afSetChannelMatrix (AFfilehandle, int track, double *matrix);
    475 
    476 /* track data: sample format and sample width */
    477 void afInitSampleFormat (AFfilesetup, int track, int sampleFormat,
    478 	int sampleWidth);
    479 void afGetSampleFormat (AFfilehandle file, int track, int *sampleFormat,
    480 	int *sampleWidth);
    481 int afSetVirtualSampleFormat (AFfilehandle, int track,
    482 	int sampleFormat, int sampleWidth);
    483 void afGetVirtualSampleFormat (AFfilehandle, int track,
    484 	int *sampleFormat, int *sampleWidth);
    485 
    486 /* track data: sampling rate */
    487 void afInitRate (AFfilesetup, int track, double rate);
    488 double afGetRate (AFfilehandle, int track);
    489 
    490 #if 0
    491 int afSetVirtualRate (AFfilehandle, int track, double rate);
    492 double afGetVirtualRate (AFfilehandle, int track);
    493 #endif
    494 
    495 /* track data: compression */
    496 void afInitCompression (AFfilesetup, int track, int compression);
    497 #if 0
    498 void afInitCompressionParams (AFfilesetup, int track, int compression
    499 	AUpvlist params, int parameterCount);
    500 #endif
    501 
    502 int afGetCompression (AFfilehandle, int track);
    503 #if 0
    504 void afGetCompressionParams (AFfilehandle, int track, int *compression,
    505 	AUpvlist params, int parameterCount);
    506 
    507 int afSetVirtualCompression (AFfilesetup, int track, int compression);
    508 void afSetVirtualCompressionParams (AFfilehandle, int track, int compression,
    509 	AUpvlist params, int parameterCount);
    510 
    511 int afGetVirtualCompression (AFfilesetup, int track, int compression);
    512 void afGetVirtualCompressionParams (AFfilehandle, int track, int *compression,
    513 	AUpvlist params, int parameterCount);
    514 #endif
    515 
    516 /* track data: pcm mapping */
    517 void afInitPCMMapping (AFfilesetup filesetup, int track,
    518 	double slope, double intercept, double minClip, double maxClip);
    519 void afGetPCMMapping (AFfilehandle file, int track,
    520 	double *slope, double *intercept, double *minClip, double *maxClip);
    521 /* NOTE: afSetTrackPCMMapping() is special--it does not set the virtual  */
    522 /* format; it changes what the AF thinks the track format is! Be careful. */
    523 int afSetTrackPCMMapping (AFfilehandle file, int track,
    524 	double slope, double intercept, double minClip, double maxClip);
    525 /* NOTE: afSetVirtualPCMMapping() is different from afSetTrackPCMMapping(): */
    526 /* see comment for afSetTrackPCMMapping(). */
    527 int afSetVirtualPCMMapping (AFfilehandle file, int track,
    528 	double slope, double intercept, double minClip, double maxClip);
    529 void afGetVirtualPCMMapping (AFfilehandle file, int track,
    530 	double *slope, double *intercept, double *minClip, double *maxClip);
    531 
    532 /* track data: data offset within the file */
    533 /* initialize for raw reading only */
    534 void afInitDataOffset(AFfilesetup, int track, AFfileoffset offset);
    535 AFfileoffset afGetDataOffset (AFfilehandle, int track);
    536 
    537 /* track data: count of frames in file */
    538 void afInitFrameCount (AFfilesetup, int track, AFframecount frameCount);
    539 AFframecount afGetFrameCount (AFfilehandle file, int track);
    540 
    541 /* loop operations */
    542 void afInitLoopIDs (AFfilesetup, int instid, const int *ids, int nids);
    543 int afGetLoopIDs (AFfilehandle, int instid, int loopids[]);
    544 void afSetLoopMode (AFfilehandle, int instid, int loop, int mode);
    545 int afGetLoopMode (AFfilehandle, int instid, int loopid);
    546 int afSetLoopCount (AFfilehandle, int instid, int loop, int count);
    547 int afGetLoopCount (AFfilehandle, int instid, int loopid);
    548 void afSetLoopStart (AFfilehandle, int instid, int loopid, int markerid);
    549 int afGetLoopStart (AFfilehandle, int instid, int loopid);
    550 void afSetLoopEnd (AFfilehandle, int instid, int loopid, int markerid);
    551 int afGetLoopEnd (AFfilehandle, int instid, int loopid);
    552 
    553 int afSetLoopStartFrame (AFfilehandle, int instid, int loop,
    554 	AFframecount startFrame);
    555 AFframecount afGetLoopStartFrame (AFfilehandle, int instid, int loop);
    556 int afSetLoopEndFrame (AFfilehandle, int instid, int loop,
    557 	AFframecount startFrame);
    558 AFframecount afGetLoopEndFrame (AFfilehandle, int instid, int loop);
    559 
    560 void afSetLoopTrack (AFfilehandle, int instid, int loopid, int trackid);
    561 int afGetLoopTrack (AFfilehandle, int instid, int loopid);
    562 
    563 /* marker operations */
    564 void afInitMarkIDs (AFfilesetup, int trackid, const int *ids, int nids);
    565 int afGetMarkIDs (AFfilehandle file, int trackid, int markids[]);
    566 void afSetMarkPosition (AFfilehandle file, int trackid, int markid,
    567 	AFframecount markpos);
    568 AFframecount afGetMarkPosition (AFfilehandle file, int trackid, int markid);
    569 void afInitMarkName (AFfilesetup, int trackid, int marker, const char *name);
    570 void afInitMarkComment (AFfilesetup, int trackid, int marker,
    571 	const char *comment);
    572 char *afGetMarkName (AFfilehandle file, int trackid, int markid);
    573 char *afGetMarkComment (AFfilehandle file, int trackid, int markid);
    574 
    575 /* instrument operations */
    576 void afInitInstIDs (AFfilesetup, const int *ids, int nids);
    577 int afGetInstIDs (AFfilehandle file, int *instids);
    578 void afGetInstParams (AFfilehandle file, int instid, AUpvlist pvlist,
    579 	int nparams);
    580 void afSetInstParams (AFfilehandle file, int instid, AUpvlist pvlist,
    581 	int nparams);
    582 long afGetInstParamLong (AFfilehandle file, int instid, int param);
    583 void afSetInstParamLong (AFfilehandle file, int instid, int param, long value);
    584 
    585 /* miscellaneous data operations */
    586 void afInitMiscIDs (AFfilesetup, const int *ids, int nids);
    587 int afGetMiscIDs (AFfilehandle, int *ids);
    588 void afInitMiscType (AFfilesetup, int miscellaneousid, int type);
    589 int afGetMiscType (AFfilehandle, int miscellaneousid);
    590 void afInitMiscSize (AFfilesetup, int miscellaneousid, int size);
    591 int afGetMiscSize (AFfilehandle, int miscellaneousid);
    592 int afWriteMisc (AFfilehandle, int miscellaneousid, const void *buf, int bytes);
    593 int afReadMisc (AFfilehandle, int miscellaneousid, void *buf, int bytes);
    594 int afSeekMisc (AFfilehandle, int miscellaneousid, int offset);
    595 
    596 #ifdef __cplusplus
    597 }
    598 #endif
    599 
    600 #endif /* AUDIOFILE_H */
    601