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