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