annotate win64-mingw/include/sndfile.h @ 131:cd8a866e0905

Debug build of Rubber Band Library
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 19 Oct 2016 17:32:56 +0100
parents c9cf28b398fb
children
rev   line source
cannam@120 1 /*
cannam@120 2 ** Copyright (C) 1999-2011Erik de Castro Lopo <erikd@mega-nerd.com>
cannam@120 3 **
cannam@120 4 ** This program is free software; you can redistribute it and/or modify
cannam@120 5 ** it under the terms of the GNU Lesser General Public License as published by
cannam@120 6 ** the Free Software Foundation; either version 2.1 of the License, or
cannam@120 7 ** (at your option) any later version.
cannam@120 8 **
cannam@120 9 ** This program is distributed in the hope that it will be useful,
cannam@120 10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@120 11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@120 12 ** GNU Lesser General Public License for more details.
cannam@120 13 **
cannam@120 14 ** You should have received a copy of the GNU Lesser General Public License
cannam@120 15 ** along with this program; if not, write to the Free Software
cannam@120 16 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
cannam@120 17 */
cannam@120 18
cannam@120 19 /*
cannam@120 20 ** sndfile.h -- system-wide definitions
cannam@120 21 **
cannam@120 22 ** API documentation is in the doc/ directory of the source code tarball
cannam@120 23 ** and at http://www.mega-nerd.com/libsndfile/api.html.
cannam@120 24 */
cannam@120 25
cannam@120 26 #ifndef SNDFILE_H
cannam@120 27 #define SNDFILE_H
cannam@120 28
cannam@120 29 /* This is the version 1.0.X header file. */
cannam@120 30 #define SNDFILE_1
cannam@120 31
cannam@120 32 #include <stdio.h>
cannam@120 33 #include <sys/types.h>
cannam@120 34
cannam@120 35 #ifdef __cplusplus
cannam@120 36 extern "C" {
cannam@120 37 #endif /* __cplusplus */
cannam@120 38
cannam@120 39 /* The following file types can be read and written.
cannam@120 40 ** A file type would consist of a major type (ie SF_FORMAT_WAV) bitwise
cannam@120 41 ** ORed with a minor type (ie SF_FORMAT_PCM). SF_FORMAT_TYPEMASK and
cannam@120 42 ** SF_FORMAT_SUBMASK can be used to separate the major and minor file
cannam@120 43 ** types.
cannam@120 44 */
cannam@120 45
cannam@120 46 enum
cannam@120 47 { /* Major formats. */
cannam@120 48 SF_FORMAT_WAV = 0x010000, /* Microsoft WAV format (little endian default). */
cannam@120 49 SF_FORMAT_AIFF = 0x020000, /* Apple/SGI AIFF format (big endian). */
cannam@120 50 SF_FORMAT_AU = 0x030000, /* Sun/NeXT AU format (big endian). */
cannam@120 51 SF_FORMAT_RAW = 0x040000, /* RAW PCM data. */
cannam@120 52 SF_FORMAT_PAF = 0x050000, /* Ensoniq PARIS file format. */
cannam@120 53 SF_FORMAT_SVX = 0x060000, /* Amiga IFF / SVX8 / SV16 format. */
cannam@120 54 SF_FORMAT_NIST = 0x070000, /* Sphere NIST format. */
cannam@120 55 SF_FORMAT_VOC = 0x080000, /* VOC files. */
cannam@120 56 SF_FORMAT_IRCAM = 0x0A0000, /* Berkeley/IRCAM/CARL */
cannam@120 57 SF_FORMAT_W64 = 0x0B0000, /* Sonic Foundry's 64 bit RIFF/WAV */
cannam@120 58 SF_FORMAT_MAT4 = 0x0C0000, /* Matlab (tm) V4.2 / GNU Octave 2.0 */
cannam@120 59 SF_FORMAT_MAT5 = 0x0D0000, /* Matlab (tm) V5.0 / GNU Octave 2.1 */
cannam@120 60 SF_FORMAT_PVF = 0x0E0000, /* Portable Voice Format */
cannam@120 61 SF_FORMAT_XI = 0x0F0000, /* Fasttracker 2 Extended Instrument */
cannam@120 62 SF_FORMAT_HTK = 0x100000, /* HMM Tool Kit format */
cannam@120 63 SF_FORMAT_SDS = 0x110000, /* Midi Sample Dump Standard */
cannam@120 64 SF_FORMAT_AVR = 0x120000, /* Audio Visual Research */
cannam@120 65 SF_FORMAT_WAVEX = 0x130000, /* MS WAVE with WAVEFORMATEX */
cannam@120 66 SF_FORMAT_SD2 = 0x160000, /* Sound Designer 2 */
cannam@120 67 SF_FORMAT_FLAC = 0x170000, /* FLAC lossless file format */
cannam@120 68 SF_FORMAT_CAF = 0x180000, /* Core Audio File format */
cannam@120 69 SF_FORMAT_WVE = 0x190000, /* Psion WVE format */
cannam@120 70 SF_FORMAT_OGG = 0x200000, /* Xiph OGG container */
cannam@120 71 SF_FORMAT_MPC2K = 0x210000, /* Akai MPC 2000 sampler */
cannam@120 72 SF_FORMAT_RF64 = 0x220000, /* RF64 WAV file */
cannam@120 73
cannam@120 74 /* Subtypes from here on. */
cannam@120 75
cannam@120 76 SF_FORMAT_PCM_S8 = 0x0001, /* Signed 8 bit data */
cannam@120 77 SF_FORMAT_PCM_16 = 0x0002, /* Signed 16 bit data */
cannam@120 78 SF_FORMAT_PCM_24 = 0x0003, /* Signed 24 bit data */
cannam@120 79 SF_FORMAT_PCM_32 = 0x0004, /* Signed 32 bit data */
cannam@120 80
cannam@120 81 SF_FORMAT_PCM_U8 = 0x0005, /* Unsigned 8 bit data (WAV and RAW only) */
cannam@120 82
cannam@120 83 SF_FORMAT_FLOAT = 0x0006, /* 32 bit float data */
cannam@120 84 SF_FORMAT_DOUBLE = 0x0007, /* 64 bit float data */
cannam@120 85
cannam@120 86 SF_FORMAT_ULAW = 0x0010, /* U-Law encoded. */
cannam@120 87 SF_FORMAT_ALAW = 0x0011, /* A-Law encoded. */
cannam@120 88 SF_FORMAT_IMA_ADPCM = 0x0012, /* IMA ADPCM. */
cannam@120 89 SF_FORMAT_MS_ADPCM = 0x0013, /* Microsoft ADPCM. */
cannam@120 90
cannam@120 91 SF_FORMAT_GSM610 = 0x0020, /* GSM 6.10 encoding. */
cannam@120 92 SF_FORMAT_VOX_ADPCM = 0x0021, /* OKI / Dialogix ADPCM */
cannam@120 93
cannam@120 94 SF_FORMAT_G721_32 = 0x0030, /* 32kbs G721 ADPCM encoding. */
cannam@120 95 SF_FORMAT_G723_24 = 0x0031, /* 24kbs G723 ADPCM encoding. */
cannam@120 96 SF_FORMAT_G723_40 = 0x0032, /* 40kbs G723 ADPCM encoding. */
cannam@120 97
cannam@120 98 SF_FORMAT_DWVW_12 = 0x0040, /* 12 bit Delta Width Variable Word encoding. */
cannam@120 99 SF_FORMAT_DWVW_16 = 0x0041, /* 16 bit Delta Width Variable Word encoding. */
cannam@120 100 SF_FORMAT_DWVW_24 = 0x0042, /* 24 bit Delta Width Variable Word encoding. */
cannam@120 101 SF_FORMAT_DWVW_N = 0x0043, /* N bit Delta Width Variable Word encoding. */
cannam@120 102
cannam@120 103 SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */
cannam@120 104 SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */
cannam@120 105
cannam@120 106 SF_FORMAT_VORBIS = 0x0060, /* Xiph Vorbis encoding. */
cannam@120 107
cannam@120 108 /* Endian-ness options. */
cannam@120 109
cannam@120 110 SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */
cannam@120 111 SF_ENDIAN_LITTLE = 0x10000000, /* Force little endian-ness. */
cannam@120 112 SF_ENDIAN_BIG = 0x20000000, /* Force big endian-ness. */
cannam@120 113 SF_ENDIAN_CPU = 0x30000000, /* Force CPU endian-ness. */
cannam@120 114
cannam@120 115 SF_FORMAT_SUBMASK = 0x0000FFFF,
cannam@120 116 SF_FORMAT_TYPEMASK = 0x0FFF0000,
cannam@120 117 SF_FORMAT_ENDMASK = 0x30000000
cannam@120 118 } ;
cannam@120 119
cannam@120 120 /*
cannam@120 121 ** The following are the valid command numbers for the sf_command()
cannam@120 122 ** interface. The use of these commands is documented in the file
cannam@120 123 ** command.html in the doc directory of the source code distribution.
cannam@120 124 */
cannam@120 125
cannam@120 126 enum
cannam@120 127 { SFC_GET_LIB_VERSION = 0x1000,
cannam@120 128 SFC_GET_LOG_INFO = 0x1001,
cannam@120 129 SFC_GET_CURRENT_SF_INFO = 0x1002,
cannam@120 130
cannam@120 131
cannam@120 132 SFC_GET_NORM_DOUBLE = 0x1010,
cannam@120 133 SFC_GET_NORM_FLOAT = 0x1011,
cannam@120 134 SFC_SET_NORM_DOUBLE = 0x1012,
cannam@120 135 SFC_SET_NORM_FLOAT = 0x1013,
cannam@120 136 SFC_SET_SCALE_FLOAT_INT_READ = 0x1014,
cannam@120 137 SFC_SET_SCALE_INT_FLOAT_WRITE = 0x1015,
cannam@120 138
cannam@120 139 SFC_GET_SIMPLE_FORMAT_COUNT = 0x1020,
cannam@120 140 SFC_GET_SIMPLE_FORMAT = 0x1021,
cannam@120 141
cannam@120 142 SFC_GET_FORMAT_INFO = 0x1028,
cannam@120 143
cannam@120 144 SFC_GET_FORMAT_MAJOR_COUNT = 0x1030,
cannam@120 145 SFC_GET_FORMAT_MAJOR = 0x1031,
cannam@120 146 SFC_GET_FORMAT_SUBTYPE_COUNT = 0x1032,
cannam@120 147 SFC_GET_FORMAT_SUBTYPE = 0x1033,
cannam@120 148
cannam@120 149 SFC_CALC_SIGNAL_MAX = 0x1040,
cannam@120 150 SFC_CALC_NORM_SIGNAL_MAX = 0x1041,
cannam@120 151 SFC_CALC_MAX_ALL_CHANNELS = 0x1042,
cannam@120 152 SFC_CALC_NORM_MAX_ALL_CHANNELS = 0x1043,
cannam@120 153 SFC_GET_SIGNAL_MAX = 0x1044,
cannam@120 154 SFC_GET_MAX_ALL_CHANNELS = 0x1045,
cannam@120 155
cannam@120 156 SFC_SET_ADD_PEAK_CHUNK = 0x1050,
cannam@120 157 SFC_SET_ADD_HEADER_PAD_CHUNK = 0x1051,
cannam@120 158
cannam@120 159 SFC_UPDATE_HEADER_NOW = 0x1060,
cannam@120 160 SFC_SET_UPDATE_HEADER_AUTO = 0x1061,
cannam@120 161
cannam@120 162 SFC_FILE_TRUNCATE = 0x1080,
cannam@120 163
cannam@120 164 SFC_SET_RAW_START_OFFSET = 0x1090,
cannam@120 165
cannam@120 166 SFC_SET_DITHER_ON_WRITE = 0x10A0,
cannam@120 167 SFC_SET_DITHER_ON_READ = 0x10A1,
cannam@120 168
cannam@120 169 SFC_GET_DITHER_INFO_COUNT = 0x10A2,
cannam@120 170 SFC_GET_DITHER_INFO = 0x10A3,
cannam@120 171
cannam@120 172 SFC_GET_EMBED_FILE_INFO = 0x10B0,
cannam@120 173
cannam@120 174 SFC_SET_CLIPPING = 0x10C0,
cannam@120 175 SFC_GET_CLIPPING = 0x10C1,
cannam@120 176
cannam@120 177 SFC_GET_INSTRUMENT = 0x10D0,
cannam@120 178 SFC_SET_INSTRUMENT = 0x10D1,
cannam@120 179
cannam@120 180 SFC_GET_LOOP_INFO = 0x10E0,
cannam@120 181
cannam@120 182 SFC_GET_BROADCAST_INFO = 0x10F0,
cannam@120 183 SFC_SET_BROADCAST_INFO = 0x10F1,
cannam@120 184
cannam@120 185 SFC_GET_CHANNEL_MAP_INFO = 0x1100,
cannam@120 186 SFC_SET_CHANNEL_MAP_INFO = 0x1101,
cannam@120 187
cannam@120 188 SFC_RAW_DATA_NEEDS_ENDSWAP = 0x1110,
cannam@120 189
cannam@120 190 /* Support for Wavex Ambisonics Format */
cannam@120 191 SFC_WAVEX_SET_AMBISONIC = 0x1200,
cannam@120 192 SFC_WAVEX_GET_AMBISONIC = 0x1201,
cannam@120 193
cannam@120 194 SFC_SET_VBR_ENCODING_QUALITY = 0x1300,
cannam@120 195
cannam@120 196 /* Following commands for testing only. */
cannam@120 197 SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001,
cannam@120 198
cannam@120 199 /*
cannam@120 200 ** SFC_SET_ADD_* values are deprecated and will disappear at some
cannam@120 201 ** time in the future. They are guaranteed to be here up to and
cannam@120 202 ** including version 1.0.8 to avoid breakage of existng software.
cannam@120 203 ** They currently do nothing and will continue to do nothing.
cannam@120 204 */
cannam@120 205 SFC_SET_ADD_DITHER_ON_WRITE = 0x1070,
cannam@120 206 SFC_SET_ADD_DITHER_ON_READ = 0x1071
cannam@120 207 } ;
cannam@120 208
cannam@120 209
cannam@120 210 /*
cannam@120 211 ** String types that can be set and read from files. Not all file types
cannam@120 212 ** support this and even the file types which support one, may not support
cannam@120 213 ** all string types.
cannam@120 214 */
cannam@120 215
cannam@120 216 enum
cannam@120 217 { SF_STR_TITLE = 0x01,
cannam@120 218 SF_STR_COPYRIGHT = 0x02,
cannam@120 219 SF_STR_SOFTWARE = 0x03,
cannam@120 220 SF_STR_ARTIST = 0x04,
cannam@120 221 SF_STR_COMMENT = 0x05,
cannam@120 222 SF_STR_DATE = 0x06,
cannam@120 223 SF_STR_ALBUM = 0x07,
cannam@120 224 SF_STR_LICENSE = 0x08,
cannam@120 225 SF_STR_TRACKNUMBER = 0x09,
cannam@120 226 SF_STR_GENRE = 0x10
cannam@120 227 } ;
cannam@120 228
cannam@120 229 /*
cannam@120 230 ** Use the following as the start and end index when doing metadata
cannam@120 231 ** transcoding.
cannam@120 232 */
cannam@120 233
cannam@120 234 #define SF_STR_FIRST SF_STR_TITLE
cannam@120 235 #define SF_STR_LAST SF_STR_GENRE
cannam@120 236
cannam@120 237 enum
cannam@120 238 { /* True and false */
cannam@120 239 SF_FALSE = 0,
cannam@120 240 SF_TRUE = 1,
cannam@120 241
cannam@120 242 /* Modes for opening files. */
cannam@120 243 SFM_READ = 0x10,
cannam@120 244 SFM_WRITE = 0x20,
cannam@120 245 SFM_RDWR = 0x30,
cannam@120 246
cannam@120 247 SF_AMBISONIC_NONE = 0x40,
cannam@120 248 SF_AMBISONIC_B_FORMAT = 0x41
cannam@120 249 } ;
cannam@120 250
cannam@120 251 /* Public error values. These are guaranteed to remain unchanged for the duration
cannam@120 252 ** of the library major version number.
cannam@120 253 ** There are also a large number of private error numbers which are internal to
cannam@120 254 ** the library which can change at any time.
cannam@120 255 */
cannam@120 256
cannam@120 257 enum
cannam@120 258 { SF_ERR_NO_ERROR = 0,
cannam@120 259 SF_ERR_UNRECOGNISED_FORMAT = 1,
cannam@120 260 SF_ERR_SYSTEM = 2,
cannam@120 261 SF_ERR_MALFORMED_FILE = 3,
cannam@120 262 SF_ERR_UNSUPPORTED_ENCODING = 4
cannam@120 263 } ;
cannam@120 264
cannam@120 265
cannam@120 266 /* Channel map values (used with SFC_SET/GET_CHANNEL_MAP).
cannam@120 267 */
cannam@120 268
cannam@120 269 enum
cannam@120 270 { SF_CHANNEL_MAP_INVALID = 0,
cannam@120 271 SF_CHANNEL_MAP_MONO = 1,
cannam@120 272 SF_CHANNEL_MAP_LEFT, /* Apple calls this 'Left' */
cannam@120 273 SF_CHANNEL_MAP_RIGHT, /* Apple calls this 'Right' */
cannam@120 274 SF_CHANNEL_MAP_CENTER, /* Apple calls this 'Center' */
cannam@120 275 SF_CHANNEL_MAP_FRONT_LEFT,
cannam@120 276 SF_CHANNEL_MAP_FRONT_RIGHT,
cannam@120 277 SF_CHANNEL_MAP_FRONT_CENTER,
cannam@120 278 SF_CHANNEL_MAP_REAR_CENTER, /* Apple calls this 'Center Surround', Msft calls this 'Back Center' */
cannam@120 279 SF_CHANNEL_MAP_REAR_LEFT, /* Apple calls this 'Left Surround', Msft calls this 'Back Left' */
cannam@120 280 SF_CHANNEL_MAP_REAR_RIGHT, /* Apple calls this 'Right Surround', Msft calls this 'Back Right' */
cannam@120 281 SF_CHANNEL_MAP_LFE, /* Apple calls this 'LFEScreen', Msft calls this 'Low Frequency' */
cannam@120 282 SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER, /* Apple calls this 'Left Center' */
cannam@120 283 SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER, /* Apple calls this 'Right Center */
cannam@120 284 SF_CHANNEL_MAP_SIDE_LEFT, /* Apple calls this 'Left Surround Direct' */
cannam@120 285 SF_CHANNEL_MAP_SIDE_RIGHT, /* Apple calls this 'Right Surround Direct' */
cannam@120 286 SF_CHANNEL_MAP_TOP_CENTER, /* Apple calls this 'Top Center Surround' */
cannam@120 287 SF_CHANNEL_MAP_TOP_FRONT_LEFT, /* Apple calls this 'Vertical Height Left' */
cannam@120 288 SF_CHANNEL_MAP_TOP_FRONT_RIGHT, /* Apple calls this 'Vertical Height Right' */
cannam@120 289 SF_CHANNEL_MAP_TOP_FRONT_CENTER, /* Apple calls this 'Vertical Height Center' */
cannam@120 290 SF_CHANNEL_MAP_TOP_REAR_LEFT, /* Apple and MS call this 'Top Back Left' */
cannam@120 291 SF_CHANNEL_MAP_TOP_REAR_RIGHT, /* Apple and MS call this 'Top Back Right' */
cannam@120 292 SF_CHANNEL_MAP_TOP_REAR_CENTER, /* Apple and MS call this 'Top Back Center' */
cannam@120 293
cannam@120 294 SF_CHANNEL_MAP_AMBISONIC_B_W,
cannam@120 295 SF_CHANNEL_MAP_AMBISONIC_B_X,
cannam@120 296 SF_CHANNEL_MAP_AMBISONIC_B_Y,
cannam@120 297 SF_CHANNEL_MAP_AMBISONIC_B_Z,
cannam@120 298
cannam@120 299 SF_CHANNEL_MAP_MAX
cannam@120 300 } ;
cannam@120 301
cannam@120 302
cannam@120 303 /* A SNDFILE* pointer can be passed around much like stdio.h's FILE* pointer. */
cannam@120 304
cannam@120 305 typedef struct SNDFILE_tag SNDFILE ;
cannam@120 306
cannam@120 307 /* The following typedef is system specific and is defined when libsndfile is
cannam@120 308 ** compiled. sf_count_t will be a 64 bit value when the underlying OS allows
cannam@120 309 ** 64 bit file offsets.
cannam@120 310 ** On windows, we need to allow the same header file to be compiler by both GCC
cannam@120 311 ** and the Microsoft compiler.
cannam@120 312 */
cannam@120 313
cannam@120 314 #if (defined (_MSCVER) || defined (_MSC_VER))
cannam@120 315 typedef __int64 sf_count_t ;
cannam@120 316 #define SF_COUNT_MAX 0x7fffffffffffffffi64
cannam@120 317 #else
cannam@120 318 typedef off_t sf_count_t ;
cannam@120 319 #define SF_COUNT_MAX 0x7FFFFFFF
cannam@120 320 #endif
cannam@120 321
cannam@120 322
cannam@120 323 /* A pointer to a SF_INFO structure is passed to sf_open () and filled in.
cannam@120 324 ** On write, the SF_INFO structure is filled in by the user and passed into
cannam@120 325 ** sf_open ().
cannam@120 326 */
cannam@120 327
cannam@120 328 struct SF_INFO
cannam@120 329 { sf_count_t frames ; /* Used to be called samples. Changed to avoid confusion. */
cannam@120 330 int samplerate ;
cannam@120 331 int channels ;
cannam@120 332 int format ;
cannam@120 333 int sections ;
cannam@120 334 int seekable ;
cannam@120 335 } ;
cannam@120 336
cannam@120 337 typedef struct SF_INFO SF_INFO ;
cannam@120 338
cannam@120 339 /* The SF_FORMAT_INFO struct is used to retrieve information about the sound
cannam@120 340 ** file formats libsndfile supports using the sf_command () interface.
cannam@120 341 **
cannam@120 342 ** Using this interface will allow applications to support new file formats
cannam@120 343 ** and encoding types when libsndfile is upgraded, without requiring
cannam@120 344 ** re-compilation of the application.
cannam@120 345 **
cannam@120 346 ** Please consult the libsndfile documentation (particularly the information
cannam@120 347 ** on the sf_command () interface) for examples of its use.
cannam@120 348 */
cannam@120 349
cannam@120 350 typedef struct
cannam@120 351 { int format ;
cannam@120 352 const char *name ;
cannam@120 353 const char *extension ;
cannam@120 354 } SF_FORMAT_INFO ;
cannam@120 355
cannam@120 356 /*
cannam@120 357 ** Enums and typedefs for adding dither on read and write.
cannam@120 358 ** See the html documentation for sf_command(), SFC_SET_DITHER_ON_WRITE
cannam@120 359 ** and SFC_SET_DITHER_ON_READ.
cannam@120 360 */
cannam@120 361
cannam@120 362 enum
cannam@120 363 { SFD_DEFAULT_LEVEL = 0,
cannam@120 364 SFD_CUSTOM_LEVEL = 0x40000000,
cannam@120 365
cannam@120 366 SFD_NO_DITHER = 500,
cannam@120 367 SFD_WHITE = 501,
cannam@120 368 SFD_TRIANGULAR_PDF = 502
cannam@120 369 } ;
cannam@120 370
cannam@120 371 typedef struct
cannam@120 372 { int type ;
cannam@120 373 double level ;
cannam@120 374 const char *name ;
cannam@120 375 } SF_DITHER_INFO ;
cannam@120 376
cannam@120 377 /* Struct used to retrieve information about a file embedded within a
cannam@120 378 ** larger file. See SFC_GET_EMBED_FILE_INFO.
cannam@120 379 */
cannam@120 380
cannam@120 381 typedef struct
cannam@120 382 { sf_count_t offset ;
cannam@120 383 sf_count_t length ;
cannam@120 384 } SF_EMBED_FILE_INFO ;
cannam@120 385
cannam@120 386 /*
cannam@120 387 ** Structs used to retrieve music sample information from a file.
cannam@120 388 */
cannam@120 389
cannam@120 390 enum
cannam@120 391 { /*
cannam@120 392 ** The loop mode field in SF_INSTRUMENT will be one of the following.
cannam@120 393 */
cannam@120 394 SF_LOOP_NONE = 800,
cannam@120 395 SF_LOOP_FORWARD,
cannam@120 396 SF_LOOP_BACKWARD,
cannam@120 397 SF_LOOP_ALTERNATING
cannam@120 398 } ;
cannam@120 399
cannam@120 400 typedef struct
cannam@120 401 { int gain ;
cannam@120 402 char basenote, detune ;
cannam@120 403 char velocity_lo, velocity_hi ;
cannam@120 404 char key_lo, key_hi ;
cannam@120 405 int loop_count ;
cannam@120 406
cannam@120 407 struct
cannam@120 408 { int mode ;
cannam@120 409 unsigned int start ;
cannam@120 410 unsigned int end ;
cannam@120 411 unsigned int count ;
cannam@120 412 } loops [16] ; /* make variable in a sensible way */
cannam@120 413 } SF_INSTRUMENT ;
cannam@120 414
cannam@120 415
cannam@120 416
cannam@120 417 /* Struct used to retrieve loop information from a file.*/
cannam@120 418 typedef struct
cannam@120 419 {
cannam@120 420 short time_sig_num ; /* any positive integer > 0 */
cannam@120 421 short time_sig_den ; /* any positive power of 2 > 0 */
cannam@120 422 int loop_mode ; /* see SF_LOOP enum */
cannam@120 423
cannam@120 424 int num_beats ; /* this is NOT the amount of quarter notes !!!*/
cannam@120 425 /* a full bar of 4/4 is 4 beats */
cannam@120 426 /* a full bar of 7/8 is 7 beats */
cannam@120 427
cannam@120 428 float bpm ; /* suggestion, as it can be calculated using other fields:*/
cannam@120 429 /* file's lenght, file's sampleRate and our time_sig_den*/
cannam@120 430 /* -> bpms are always the amount of _quarter notes_ per minute */
cannam@120 431
cannam@120 432 int root_key ; /* MIDI note, or -1 for None */
cannam@120 433 int future [6] ;
cannam@120 434 } SF_LOOP_INFO ;
cannam@120 435
cannam@120 436
cannam@120 437 /* Struct used to retrieve broadcast (EBU) information from a file.
cannam@120 438 ** Strongly (!) based on EBU "bext" chunk format used in Broadcast WAVE.
cannam@120 439 */
cannam@120 440 #define SF_BROADCAST_INFO_VAR(coding_hist_size) \
cannam@120 441 struct \
cannam@120 442 { char description [256] ; \
cannam@120 443 char originator [32] ; \
cannam@120 444 char originator_reference [32] ; \
cannam@120 445 char origination_date [10] ; \
cannam@120 446 char origination_time [8] ; \
cannam@120 447 unsigned int time_reference_low ; \
cannam@120 448 unsigned int time_reference_high ; \
cannam@120 449 short version ; \
cannam@120 450 char umid [64] ; \
cannam@120 451 char reserved [190] ; \
cannam@120 452 unsigned int coding_history_size ; \
cannam@120 453 char coding_history [coding_hist_size] ; \
cannam@120 454 }
cannam@120 455
cannam@120 456 /* SF_BROADCAST_INFO is the above struct with coding_history field of 256 bytes. */
cannam@120 457 typedef SF_BROADCAST_INFO_VAR (256) SF_BROADCAST_INFO ;
cannam@120 458
cannam@120 459
cannam@120 460 /* Virtual I/O functionality. */
cannam@120 461
cannam@120 462 typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ;
cannam@120 463 typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ;
cannam@120 464 typedef sf_count_t (*sf_vio_read) (void *ptr, sf_count_t count, void *user_data) ;
cannam@120 465 typedef sf_count_t (*sf_vio_write) (const void *ptr, sf_count_t count, void *user_data) ;
cannam@120 466 typedef sf_count_t (*sf_vio_tell) (void *user_data) ;
cannam@120 467
cannam@120 468 struct SF_VIRTUAL_IO
cannam@120 469 { sf_vio_get_filelen get_filelen ;
cannam@120 470 sf_vio_seek seek ;
cannam@120 471 sf_vio_read read ;
cannam@120 472 sf_vio_write write ;
cannam@120 473 sf_vio_tell tell ;
cannam@120 474 } ;
cannam@120 475
cannam@120 476 typedef struct SF_VIRTUAL_IO SF_VIRTUAL_IO ;
cannam@120 477
cannam@120 478
cannam@120 479 /* Open the specified file for read, write or both. On error, this will
cannam@120 480 ** return a NULL pointer. To find the error number, pass a NULL SNDFILE
cannam@120 481 ** to sf_strerror ().
cannam@120 482 ** All calls to sf_open() should be matched with a call to sf_close().
cannam@120 483 */
cannam@120 484
cannam@120 485 SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ;
cannam@120 486
cannam@120 487
cannam@120 488 /* Use the existing file descriptor to create a SNDFILE object. If close_desc
cannam@120 489 ** is TRUE, the file descriptor will be closed when sf_close() is called. If
cannam@120 490 ** it is FALSE, the descritor will not be closed.
cannam@120 491 ** When passed a descriptor like this, the library will assume that the start
cannam@120 492 ** of file header is at the current file offset. This allows sound files within
cannam@120 493 ** larger container files to be read and/or written.
cannam@120 494 ** On error, this will return a NULL pointer. To find the error number, pass a
cannam@120 495 ** NULL SNDFILE to sf_strerror ().
cannam@120 496 ** All calls to sf_open_fd() should be matched with a call to sf_close().
cannam@120 497
cannam@120 498 */
cannam@120 499
cannam@120 500 SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ;
cannam@120 501
cannam@120 502 SNDFILE* sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ;
cannam@120 503
cannam@120 504
cannam@120 505 /* sf_error () returns a error number which can be translated to a text
cannam@120 506 ** string using sf_error_number().
cannam@120 507 */
cannam@120 508
cannam@120 509 int sf_error (SNDFILE *sndfile) ;
cannam@120 510
cannam@120 511
cannam@120 512 /* sf_strerror () returns to the caller a pointer to the current error message for
cannam@120 513 ** the given SNDFILE.
cannam@120 514 */
cannam@120 515
cannam@120 516 const char* sf_strerror (SNDFILE *sndfile) ;
cannam@120 517
cannam@120 518
cannam@120 519 /* sf_error_number () allows the retrieval of the error string for each internal
cannam@120 520 ** error number.
cannam@120 521 **
cannam@120 522 */
cannam@120 523
cannam@120 524 const char* sf_error_number (int errnum) ;
cannam@120 525
cannam@120 526
cannam@120 527 /* The following two error functions are deprecated but they will remain in the
cannam@120 528 ** library for the forseeable future. The function sf_strerror() should be used
cannam@120 529 ** in their place.
cannam@120 530 */
cannam@120 531
cannam@120 532 int sf_perror (SNDFILE *sndfile) ;
cannam@120 533 int sf_error_str (SNDFILE *sndfile, char* str, size_t len) ;
cannam@120 534
cannam@120 535
cannam@120 536 /* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */
cannam@120 537
cannam@120 538 int sf_command (SNDFILE *sndfile, int command, void *data, int datasize) ;
cannam@120 539
cannam@120 540
cannam@120 541 /* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */
cannam@120 542
cannam@120 543 int sf_format_check (const SF_INFO *info) ;
cannam@120 544
cannam@120 545
cannam@120 546 /* Seek within the waveform data chunk of the SNDFILE. sf_seek () uses
cannam@120 547 ** the same values for whence (SEEK_SET, SEEK_CUR and SEEK_END) as
cannam@120 548 ** stdio.h function fseek ().
cannam@120 549 ** An offset of zero with whence set to SEEK_SET will position the
cannam@120 550 ** read / write pointer to the first data sample.
cannam@120 551 ** On success sf_seek returns the current position in (multi-channel)
cannam@120 552 ** samples from the start of the file.
cannam@120 553 ** Please see the libsndfile documentation for moving the read pointer
cannam@120 554 ** separately from the write pointer on files open in mode SFM_RDWR.
cannam@120 555 ** On error all of these functions return -1.
cannam@120 556 */
cannam@120 557
cannam@120 558 sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ;
cannam@120 559
cannam@120 560
cannam@120 561 /* Functions for retrieving and setting string data within sound files.
cannam@120 562 ** Not all file types support this features; AIFF and WAV do. For both
cannam@120 563 ** functions, the str_type parameter must be one of the SF_STR_* values
cannam@120 564 ** defined above.
cannam@120 565 ** On error, sf_set_string() returns non-zero while sf_get_string()
cannam@120 566 ** returns NULL.
cannam@120 567 */
cannam@120 568
cannam@120 569 int sf_set_string (SNDFILE *sndfile, int str_type, const char* str) ;
cannam@120 570
cannam@120 571 const char* sf_get_string (SNDFILE *sndfile, int str_type) ;
cannam@120 572
cannam@120 573
cannam@120 574 /* Return the library version string. */
cannam@120 575
cannam@120 576 const char * sf_version_string (void) ;
cannam@120 577
cannam@120 578
cannam@120 579 /* Functions for reading/writing the waveform data of a sound file.
cannam@120 580 */
cannam@120 581
cannam@120 582 sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
cannam@120 583 sf_count_t sf_write_raw (SNDFILE *sndfile, const void *ptr, sf_count_t bytes) ;
cannam@120 584
cannam@120 585
cannam@120 586 /* Functions for reading and writing the data chunk in terms of frames.
cannam@120 587 ** The number of items actually read/written = frames * number of channels.
cannam@120 588 ** sf_xxxx_raw read/writes the raw data bytes from/to the file
cannam@120 589 ** sf_xxxx_short passes data in the native short format
cannam@120 590 ** sf_xxxx_int passes data in the native int format
cannam@120 591 ** sf_xxxx_float passes data in the native float format
cannam@120 592 ** sf_xxxx_double passes data in the native double format
cannam@120 593 ** All of these read/write function return number of frames read/written.
cannam@120 594 */
cannam@120 595
cannam@120 596 sf_count_t sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ;
cannam@120 597 sf_count_t sf_writef_short (SNDFILE *sndfile, const short *ptr, sf_count_t frames) ;
cannam@120 598
cannam@120 599 sf_count_t sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ;
cannam@120 600 sf_count_t sf_writef_int (SNDFILE *sndfile, const int *ptr, sf_count_t frames) ;
cannam@120 601
cannam@120 602 sf_count_t sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ;
cannam@120 603 sf_count_t sf_writef_float (SNDFILE *sndfile, const float *ptr, sf_count_t frames) ;
cannam@120 604
cannam@120 605 sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ;
cannam@120 606 sf_count_t sf_writef_double (SNDFILE *sndfile, const double *ptr, sf_count_t frames) ;
cannam@120 607
cannam@120 608
cannam@120 609 /* Functions for reading and writing the data chunk in terms of items.
cannam@120 610 ** Otherwise similar to above.
cannam@120 611 ** All of these read/write function return number of items read/written.
cannam@120 612 */
cannam@120 613
cannam@120 614 sf_count_t sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ;
cannam@120 615 sf_count_t sf_write_short (SNDFILE *sndfile, const short *ptr, sf_count_t items) ;
cannam@120 616
cannam@120 617 sf_count_t sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ;
cannam@120 618 sf_count_t sf_write_int (SNDFILE *sndfile, const int *ptr, sf_count_t items) ;
cannam@120 619
cannam@120 620 sf_count_t sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ;
cannam@120 621 sf_count_t sf_write_float (SNDFILE *sndfile, const float *ptr, sf_count_t items) ;
cannam@120 622
cannam@120 623 sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ;
cannam@120 624 sf_count_t sf_write_double (SNDFILE *sndfile, const double *ptr, sf_count_t items) ;
cannam@120 625
cannam@120 626
cannam@120 627 /* Close the SNDFILE and clean up all memory allocations associated with this
cannam@120 628 ** file.
cannam@120 629 ** Returns 0 on success, or an error number.
cannam@120 630 */
cannam@120 631
cannam@120 632 int sf_close (SNDFILE *sndfile) ;
cannam@120 633
cannam@120 634
cannam@120 635 /* If the file is opened SFM_WRITE or SFM_RDWR, call fsync() on the file
cannam@120 636 ** to force the writing of data to disk. If the file is opened SFM_READ
cannam@120 637 ** no action is taken.
cannam@120 638 */
cannam@120 639
cannam@120 640 void sf_write_sync (SNDFILE *sndfile) ;
cannam@120 641
cannam@120 642
cannam@120 643
cannam@120 644 /* The function sf_wchar_open() is Windows Only!
cannam@120 645 ** Open a file passing in a Windows Unicode filename. Otherwise, this is
cannam@120 646 ** the same as sf_open().
cannam@120 647 **
cannam@120 648 ** In order for this to work, you need to do the following:
cannam@120 649 **
cannam@120 650 ** #include <windows.h>
cannam@120 651 ** #define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1
cannam@120 652 ** #including <sndfile.h>
cannam@120 653 */
cannam@120 654
cannam@120 655 #if (defined (ENABLE_SNDFILE_WINDOWS_PROTOTYPES) && ENABLE_SNDFILE_WINDOWS_PROTOTYPES)
cannam@120 656 SNDFILE* sf_wchar_open (LPCWSTR wpath, int mode, SF_INFO *sfinfo) ;
cannam@120 657 #endif
cannam@120 658
cannam@120 659
cannam@120 660
cannam@120 661 #ifdef __cplusplus
cannam@120 662 } /* extern "C" */
cannam@120 663 #endif /* __cplusplus */
cannam@120 664
cannam@120 665 #endif /* SNDFILE_H */
cannam@120 666