| @@ -1,5 +1,5 @@ |
| 1 | /* | 1 | /* |
| 2 | ** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd@mega-nerd.com> | 2 | ** Copyright (C) 1999-2008 Erik de Castro Lopo <erikd@mega-nerd.com> |
| 3 | ** | 3 | ** |
| 4 | ** This program is free software; you can redistribute it and/or modify | 4 | ** This program is free software; you can redistribute it and/or modify |
| 5 | ** it under the terms of the GNU Lesser General Public License as published by | 5 | ** it under the terms of the GNU Lesser General Public License as published by |
| @@ -30,14 +30,7 @@ · 24 unmodified lines |
| 30 | #define SNDFILE_1 | 30 | #define SNDFILE_1 |
| 31 | | 31 | |
| 32 | #include <stdio.h> | 32 | #include <stdio.h> |
| 33 | | 33 | #include <sys/types.h> |
| 34 | /* For the Metrowerks CodeWarrior Pro Compiler (mainly MacOS) */ | | |
| 35 | | | |
| 36 | #if (defined (__MWERKS__)) | | |
| 37 | #include <unix.h> | | |
| 38 | #else | | |
| 39 | #include <sys/types.h> | | |
| 40 | #endif | | |
| 41 | | 34 | |
| 42 | #ifdef __cplusplus | 35 | #ifdef __cplusplus |
| 43 | extern "C" { | 36 | extern "C" { |
| @@ -52,7 +45,7 @@ extern "C" { · 8 unmodified lines |
| 52 | | 45 | |
| 53 | enum | 46 | enum |
| 54 | { /* Major formats. */ | 47 | { /* Major formats. */ |
| 55 | SF_FORMAT_WAV = 0x010000, /* Microsoft WAV format (little endian). */ | 48 | SF_FORMAT_WAV = 0x010000, /* Microsoft WAV format (little endian default). */ |
| 56 | SF_FORMAT_AIFF = 0x020000, /* Apple/SGI AIFF format (big endian). */ | 49 | SF_FORMAT_AIFF = 0x020000, /* Apple/SGI AIFF format (big endian). */ |
| 57 | SF_FORMAT_AU = 0x030000, /* Sun/NeXT AU format (big endian). */ | 50 | SF_FORMAT_AU = 0x030000, /* Sun/NeXT AU format (big endian). */ |
| 58 | SF_FORMAT_RAW = 0x040000, /* RAW PCM data. */ | 51 | SF_FORMAT_RAW = 0x040000, /* RAW PCM data. */ |
| @@ -68,7 +61,14 @@ enum · 9 unmodified lines |
| 68 | SF_FORMAT_XI = 0x0F0000, /* Fasttracker 2 Extended Instrument */ | 61 | SF_FORMAT_XI = 0x0F0000, /* Fasttracker 2 Extended Instrument */ |
| 69 | SF_FORMAT_HTK = 0x100000, /* HMM Tool Kit format */ | 62 | SF_FORMAT_HTK = 0x100000, /* HMM Tool Kit format */ |
| 70 | SF_FORMAT_SDS = 0x110000, /* Midi Sample Dump Standard */ | 63 | SF_FORMAT_SDS = 0x110000, /* Midi Sample Dump Standard */ |
| 71 | | 64 | SF_FORMAT_AVR = 0x120000, /* Audio Visual Research */ |
| | 65 | SF_FORMAT_WAVEX = 0x130000, /* MS WAVE with WAVEFORMATEX */ |
| | 66 | SF_FORMAT_SD2 = 0x160000, /* Sound Designer 2 */ |
| | 67 | SF_FORMAT_FLAC = 0x170000, /* FLAC lossless file format */ |
| | 68 | SF_FORMAT_CAF = 0x180000, /* Core Audio File format */ |
| | 69 | SF_FORMAT_WVE = 0x190000, /* Psion WVE format */ |
| | 70 | SF_FORMAT_OGG = 0x200000, /* Xiph OGG container */ |
| | 71 | |
| 72 | /* Subtypes from here on. */ | 72 | /* Subtypes from here on. */ |
| 73 | | 73 | |
| 74 | SF_FORMAT_PCM_S8 = 0x0001, /* Signed 8 bit data */ | 74 | SF_FORMAT_PCM_S8 = 0x0001, /* Signed 8 bit data */ |
| @@ -123,11 +123,15 @@ enum · 48 unmodified lines |
| 123 | enum | 123 | enum |
| 124 | { SFC_GET_LIB_VERSION = 0x1000, | 124 | { SFC_GET_LIB_VERSION = 0x1000, |
| 125 | SFC_GET_LOG_INFO = 0x1001, | 125 | SFC_GET_LOG_INFO = 0x1001, |
| | 126 | SFC_GET_CURRENT_SF_INFO = 0x1002, |
| | 127 | |
| 126 | | 128 | |
| 127 | SFC_GET_NORM_DOUBLE = 0x1010, | 129 | SFC_GET_NORM_DOUBLE = 0x1010, |
| 128 | SFC_GET_NORM_FLOAT = 0x1011, | 130 | SFC_GET_NORM_FLOAT = 0x1011, |
| 129 | SFC_SET_NORM_DOUBLE = 0x1012, | 131 | SFC_SET_NORM_DOUBLE = 0x1012, |
| 130 | SFC_SET_NORM_FLOAT = 0x1013, | 132 | SFC_SET_NORM_FLOAT = 0x1013, |
| | 133 | SFC_SET_SCALE_FLOAT_INT_READ = 0x1014, |
| | 134 | SFC_SET_SCALE_INT_FLOAT_WRITE = 0x1015, |
| 131 | | 135 | |
| 132 | SFC_GET_SIMPLE_FORMAT_COUNT = 0x1020, | 136 | SFC_GET_SIMPLE_FORMAT_COUNT = 0x1020, |
| 133 | SFC_GET_SIMPLE_FORMAT = 0x1021, | 137 | SFC_GET_SIMPLE_FORMAT = 0x1021, |
| @@ -143,6 +147,8 @@ enum · 9 unmodified lines |
| 143 | SFC_CALC_NORM_SIGNAL_MAX = 0x1041, | 147 | SFC_CALC_NORM_SIGNAL_MAX = 0x1041, |
| 144 | SFC_CALC_MAX_ALL_CHANNELS = 0x1042, | 148 | SFC_CALC_MAX_ALL_CHANNELS = 0x1042, |
| 145 | SFC_CALC_NORM_MAX_ALL_CHANNELS = 0x1043, | 149 | SFC_CALC_NORM_MAX_ALL_CHANNELS = 0x1043, |
| | 150 | SFC_GET_SIGNAL_MAX = 0x1044, |
| | 151 | SFC_GET_MAX_ALL_CHANNELS = 0x1045, |
| 146 | | 152 | |
| 147 | SFC_SET_ADD_PEAK_CHUNK = 0x1050, | 153 | SFC_SET_ADD_PEAK_CHUNK = 0x1050, |
| 148 | | 154 | |
| @@ -150,7 +156,7 @@ enum · 1 unmodified line |
| 150 | SFC_SET_UPDATE_HEADER_AUTO = 0x1061, | 156 | SFC_SET_UPDATE_HEADER_AUTO = 0x1061, |
| 151 | | 157 | |
| 152 | SFC_FILE_TRUNCATE = 0x1080, | 158 | SFC_FILE_TRUNCATE = 0x1080, |
| 153 | | 159 | |
| 154 | SFC_SET_RAW_START_OFFSET = 0x1090, | 160 | SFC_SET_RAW_START_OFFSET = 0x1090, |
| 155 | | 161 | |
| 156 | SFC_SET_DITHER_ON_WRITE = 0x10A0, | 162 | SFC_SET_DITHER_ON_WRITE = 0x10A0, |
| @@ -160,21 +166,37 @@ enum · 3 unmodified lines |
| 160 | SFC_GET_DITHER_INFO = 0x10A3, | 166 | SFC_GET_DITHER_INFO = 0x10A3, |
| 161 | | 167 | |
| 162 | SFC_GET_EMBED_FILE_INFO = 0x10B0, | 168 | SFC_GET_EMBED_FILE_INFO = 0x10B0, |
| 163 | | 169 | |
| 164 | SFC_SET_CLIPPING = 0x10C0, | 170 | SFC_SET_CLIPPING = 0x10C0, |
| 165 | SFC_GET_CLIPPING = 0x10C1, | 171 | SFC_GET_CLIPPING = 0x10C1, |
| 166 | | 172 | |
| 167 | SFC_GET_INSTRUMENT = 0x10D0, | 173 | SFC_GET_INSTRUMENT = 0x10D0, |
| 168 | SFC_SET_INSTRUMENT = 0x10D1, | 174 | SFC_SET_INSTRUMENT = 0x10D1, |
| 169 | | 175 | |
| | 176 | SFC_GET_LOOP_INFO = 0x10E0, |
| | 177 | |
| | 178 | SFC_GET_BROADCAST_INFO = 0x10F0, |
| | 179 | SFC_SET_BROADCAST_INFO = 0x10F1, |
| | 180 | |
| | 181 | SFC_GET_CHANNEL_MAP_INFO = 0x1100, |
| | 182 | SFC_SET_CHANNEL_MAP_INFO = 0x1101, |
| | 183 | |
| | 184 | SFC_RAW_DATA_NEEDS_ENDSWAP = 0x1110, |
| | 185 | |
| | 186 | /* Support for Wavex Ambisonics Format */ |
| | 187 | SFC_WAVEX_SET_AMBISONIC = 0x1200, |
| | 188 | SFC_WAVEX_GET_AMBISONIC = 0x1201, |
| | 189 | |
| | 190 | SFC_SET_VBR_ENCODING_QUALITY = 0x1300, |
| | 191 | |
| 170 | /* Following commands for testing only. */ | 192 | /* Following commands for testing only. */ |
| 171 | SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001, | 193 | SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001, |
| 172 | | 194 | |
| 173 | /* | 195 | /* |
| 174 | ** SFC_SET_ADD_* values are deprecated and will disappear at some | 196 | ** SFC_SET_ADD_* values are deprecated and will disappear at some |
| 175 | ** time in the future. They are guaranteed to be here up to and | 197 | ** time in the future. They are guaranteed to be here up to and |
| 176 | ** including version 1.0.8 to avoid breakage of existng software. | 198 | ** including version 1.0.8 to avoid breakage of existng software. |
| 177 | ** They currently do nothing and will continue to do nothing. | 199 | ** They currently do nothing and will continue to do nothing. |
| 178 | */ | 200 | */ |
| 179 | SFC_SET_ADD_DITHER_ON_WRITE = 0x1070, | 201 | SFC_SET_ADD_DITHER_ON_WRITE = 0x1070, |
| 180 | SFC_SET_ADD_DITHER_ON_READ = 0x1071 | 202 | SFC_SET_ADD_DITHER_ON_READ = 0x1071 |
| @@ -193,9 +215,19 @@ enum · 12 unmodified lines |
| 193 | SF_STR_SOFTWARE = 0x03, | 215 | SF_STR_SOFTWARE = 0x03, |
| 194 | SF_STR_ARTIST = 0x04, | 216 | SF_STR_ARTIST = 0x04, |
| 195 | SF_STR_COMMENT = 0x05, | 217 | SF_STR_COMMENT = 0x05, |
| 196 | SF_STR_DATE = 0x06 | 218 | SF_STR_DATE = 0x06, |
| | 219 | SF_STR_ALBUM = 0x07, |
| | 220 | SF_STR_LICENSE = 0x08 |
| 197 | } ; | 221 | } ; |
| 198 | | 222 | |
| | 223 | /* |
| | 224 | ** Use the following as the start and end index when doing metadata |
| | 225 | ** transcoding. |
| | 226 | */ |
| | 227 | |
| | 228 | #define SF_STR_FIRST SF_STR_TITLE |
| | 229 | #define SF_STR_LAST SF_STR_LICENSE |
| | 230 | |
| 199 | enum | 231 | enum |
| 200 | { /* True and false */ | 232 | { /* True and false */ |
| 201 | SF_FALSE = 0, | 233 | SF_FALSE = 0, |
| @@ -204,33 +236,75 @@ enum · 2 unmodified lines |
| 204 | /* Modes for opening files. */ | 236 | /* Modes for opening files. */ |
| 205 | SFM_READ = 0x10, | 237 | SFM_READ = 0x10, |
| 206 | SFM_WRITE = 0x20, | 238 | SFM_WRITE = 0x20, |
| 207 | SFM_RDWR = 0x30 | 239 | SFM_RDWR = 0x30, |
| | 240 | |
| | 241 | SF_AMBISONIC_NONE = 0x40, |
| | 242 | SF_AMBISONIC_B_FORMAT = 0x41 |
| 208 | } ; | 243 | } ; |
| 209 | | 244 | |
| 210 | /* Pubic error values. These are guaranteed to remain unchanged for the duration | 245 | /* Public error values. These are guaranteed to remain unchanged for the duration |
| 211 | ** of the library major version number. | 246 | ** of the library major version number. |
| 212 | ** There are also a large number of private error numbers which are internal to | 247 | ** There are also a large number of private error numbers which are internal to |
| 213 | ** the library which can change at any time. | 248 | ** the library which can change at any time. |
| 214 | */ | 249 | */ |
| 215 | | 250 | |
| 216 | enum | 251 | enum |
| 217 | { SF_ERR_NO_ERROR = 0, | 252 | { SF_ERR_NO_ERROR = 0, |
| 218 | SF_ERR_UNRECOGNISED_FORMAT = 1, | 253 | SF_ERR_UNRECOGNISED_FORMAT = 1, |
| 219 | SF_ERR_SYSTEM = 2 | 254 | SF_ERR_SYSTEM = 2, |
| | 255 | SF_ERR_MALFORMED_FILE = 3, |
| | 256 | SF_ERR_UNSUPPORTED_ENCODING = 4 |
| 220 | } ; | 257 | } ; |
| 221 | | 258 | |
| | 259 | |
| | 260 | /* Channel map values (used with SFC_SET/GET_CHANNEL_MAP). |
| | 261 | */ |
| | 262 | |
| | 263 | enum |
| | 264 | { SF_CHANNEL_MAP_INVALID = 0, |
| | 265 | SF_CHANNEL_MAP_MONO = 1, |
| | 266 | SF_CHANNEL_MAP_LEFT, |
| | 267 | SF_CHANNEL_MAP_RIGHT, |
| | 268 | SF_CHANNEL_MAP_CENTER, |
| | 269 | SF_CHANNEL_MAP_FRONT_LEFT, |
| | 270 | SF_CHANNEL_MAP_FRONT_RIGHT, |
| | 271 | SF_CHANNEL_MAP_FRONT_CENTER, |
| | 272 | SF_CHANNEL_MAP_REAR_CENTER, |
| | 273 | SF_CHANNEL_MAP_REAR_LEFT, |
| | 274 | SF_CHANNEL_MAP_REAR_RIGHT, |
| | 275 | SF_CHANNEL_MAP_LFE, |
| | 276 | SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER, |
| | 277 | SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER, |
| | 278 | SF_CHANNEL_MAP_SIDE_LEFT, |
| | 279 | SF_CHANNEL_MAP_SIDE_RIGHT, |
| | 280 | SF_CHANNEL_MAP_TOP_CENTER, |
| | 281 | SF_CHANNEL_MAP_TOP_FRONT_LEFT, |
| | 282 | SF_CHANNEL_MAP_TOP_FRONT_RIGHT, |
| | 283 | SF_CHANNEL_MAP_TOP_FRONT_CENTER, |
| | 284 | SF_CHANNEL_MAP_TOP_REAR_LEFT, |
| | 285 | SF_CHANNEL_MAP_TOP_REAR_RIGHT, |
| | 286 | SF_CHANNEL_MAP_TOP_REAR_CENTER |
| | 287 | } ; |
| | 288 | |
| | 289 | |
| 222 | /* A SNDFILE* pointer can be passed around much like stdio.h's FILE* pointer. */ | 290 | /* A SNDFILE* pointer can be passed around much like stdio.h's FILE* pointer. */ |
| 223 | | 291 | |
| 224 | typedef struct SNDFILE_tag SNDFILE ; | 292 | typedef struct SNDFILE_tag SNDFILE ; |
| 225 | | 293 | |
| 226 | /* The following typedef is system specific and is defined when libsndfile is. | 294 | /* The following typedef is system specific and is defined when libsndfile is |
| 227 | ** compiled. sf_count_t can be one of loff_t (Linux), off_t (*BSD), | 295 | ** compiled. sf_count_t can be one of loff_t (Linux), off_t (*BSD), off64_t |
| 228 | ** off64_t (Solaris), __int64_t (Win32) etc. | 296 | ** (Solaris), __int64_t (Win32) etc. On windows, we need to allow the same |
| | 297 | ** header file to be compiler by both GCC and the microsoft compiler. |
| 229 | */ | 298 | */ |
| 230 | | 299 | |
| 231 | typedef __int64 sf_count_t ; | 300 | #ifdef _MSCVER |
| | 301 | typedef __int64_t sf_count_t ; |
| | 302 | #define SF_COUNT_MAX 0x7fffffffffffffffi64 |
| | 303 | #else |
| | 304 | typedef loff_t sf_count_t ; |
| | 305 | #define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFLL |
| | 306 | #endif |
| 232 | | 307 | |
| 233 | #define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFi64 | | |
| 234 | | 308 | |
| 235 | /* A pointer to a SF_INFO structure is passed to sf_open_read () and filled in. | 309 | /* A pointer to a SF_INFO structure is passed to sf_open_read () and filled in. |
| 236 | ** On write, the SF_INFO structure is filled in by the user and passed into | 310 | ** On write, the SF_INFO structure is filled in by the user and passed into |
| @@ -261,13 +335,13 @@ typedef struct SF_INFO SF_INFO ; · 24 unmodified lines |
| 261 | | 335 | |
| 262 | typedef struct | 336 | typedef struct |
| 263 | { int format ; | 337 | { int format ; |
| 264 | const char *name ; | 338 | const char *name ; |
| 265 | const char *extension ; | 339 | const char *extension ; |
| 266 | } SF_FORMAT_INFO ; | 340 | } SF_FORMAT_INFO ; |
| 267 | | 341 | |
| 268 | /* | 342 | /* |
| 269 | ** Enums and typedefs for adding dither on read and write. | 343 | ** Enums and typedefs for adding dither on read and write. |
| 270 | ** See the html documentation for sf_command(), SFC_SET_DITHER_ON_WRITE | 344 | ** See the html documentation for sf_command(), SFC_SET_DITHER_ON_WRITE |
| 271 | ** and SFC_SET_DITHER_ON_READ. | 345 | ** and SFC_SET_DITHER_ON_READ. |
| 272 | */ | 346 | */ |
| 273 | | 347 | |
| @@ -295,26 +369,91 @@ typedef struct · 21 unmodified lines |
| 295 | sf_count_t length ; | 369 | sf_count_t length ; |
| 296 | } SF_EMBED_FILE_INFO ; | 370 | } SF_EMBED_FILE_INFO ; |
| 297 | | 371 | |
| 298 | /* Struct used to retrieve music sample information from a file. | 372 | /* |
| | 373 | ** Structs used to retrieve music sample information from a file. |
| 299 | */ | 374 | */ |
| 300 | | 375 | |
| | 376 | enum |
| | 377 | { /* |
| | 378 | ** The loop mode field in SF_INSTRUMENT will be one of the following. |
| | 379 | */ |
| | 380 | SF_LOOP_NONE = 800, |
| | 381 | SF_LOOP_FORWARD, |
| | 382 | SF_LOOP_BACKWARD, |
| | 383 | SF_LOOP_ALTERNATING |
| | 384 | } ; |
| | 385 | |
| 301 | typedef struct | 386 | typedef struct |
| 302 | { int basenote ; | 387 | { int gain ; |
| 303 | int gain ; | 388 | char basenote, detune ; |
| 304 | int sustain_mode ; | 389 | char velocity_lo, velocity_hi ; |
| 305 | int sustain_start, sustain_end ; | 390 | char key_lo, key_hi ; |
| 306 | int release_mode ; | 391 | int loop_count ; |
| 307 | int release_start, reslease_end ; | 392 | |
| | 393 | struct |
| | 394 | { int mode ; |
| | 395 | unsigned int start ; |
| | 396 | unsigned int end ; |
| | 397 | unsigned int count ; |
| | 398 | } loops [16] ; /* make variable in a sensible way */ |
| 308 | } SF_INSTRUMENT ; | 399 | } SF_INSTRUMENT ; |
| 309 | | 400 | |
| 310 | /* sustain_mode and release_mode will be one of the following. */ | | |
| 311 | | 401 | |
| 312 | enum | 402 | |
| 313 | { SF_LOOP_NONE = 800, | 403 | /* Struct used to retrieve loop information from a file.*/ |
| 314 | SF_LOOP_FORWARD, | 404 | typedef struct |
| 315 | SF_LOOP_BACKWARD, | 405 | { |
| | 406 | short time_sig_num ; /* any positive integer > 0 */ |
| | 407 | short time_sig_den ; /* any positive power of 2 > 0 */ |
| | 408 | int loop_mode ; /* see SF_LOOP enum */ |
| | 409 | |
| | 410 | int num_beats ; /* this is NOT the amount of quarter notes !!!*/ |
| | 411 | /* a full bar of 4/4 is 4 beats */ |
| | 412 | /* a full bar of 7/8 is 7 beats */ |
| | 413 | |
| | 414 | float bpm ; /* suggestion, as it can be calculated using other fields:*/ |
| | 415 | /* file's lenght, file's sampleRate and our time_sig_den*/ |
| | 416 | /* -> bpms are always the amount of _quarter notes_ per minute */ |
| | 417 | |
| | 418 | int root_key ; /* MIDI note, or -1 for None */ |
| | 419 | int future [6] ; |
| | 420 | } SF_LOOP_INFO ; |
| | 421 | |
| | 422 | |
| | 423 | /* Struct used to retrieve broadcast (EBU) information from a file. |
| | 424 | ** Strongly (!) based on EBU "bext" chunk format used in Broadcast WAVE. |
| | 425 | */ |
| | 426 | typedef struct |
| | 427 | { char description [256] ; |
| | 428 | char originator [32] ; |
| | 429 | char originator_reference [32] ; |
| | 430 | char origination_date [10] ; |
| | 431 | char origination_time [8] ; |
| | 432 | int time_reference_low ; |
| | 433 | int time_reference_high ; |
| | 434 | short version ; |
| | 435 | char umid [64] ; |
| | 436 | char reserved [190] ; |
| | 437 | unsigned int coding_history_size ; |
| | 438 | char coding_history [256] ; |
| | 439 | } SF_BROADCAST_INFO ; |
| | 440 | |
| | 441 | typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ; |
| | 442 | typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ; |
| | 443 | typedef sf_count_t (*sf_vio_read) (void *ptr, sf_count_t count, void *user_data) ; |
| | 444 | typedef sf_count_t (*sf_vio_write) (const void *ptr, sf_count_t count, void *user_data) ; |
| | 445 | typedef sf_count_t (*sf_vio_tell) (void *user_data) ; |
| | 446 | |
| | 447 | struct SF_VIRTUAL_IO |
| | 448 | { sf_vio_get_filelen get_filelen ; |
| | 449 | sf_vio_seek seek ; |
| | 450 | sf_vio_read read ; |
| | 451 | sf_vio_write write ; |
| | 452 | sf_vio_tell tell ; |
| 316 | } ; | 453 | } ; |
| 317 | | 454 | |
| | 455 | typedef struct SF_VIRTUAL_IO SF_VIRTUAL_IO ; |
| | 456 | |
| 318 | /* Open the specified file for read, write or both. On error, this will | 457 | /* Open the specified file for read, write or both. On error, this will |
| 319 | ** return a NULL pointer. To find the error number, pass a NULL SNDFILE | 458 | ** return a NULL pointer. To find the error number, pass a NULL SNDFILE |
| 320 | ** to sf_perror () or sf_error_str (). | 459 | ** to sf_perror () or sf_error_str (). |
| @@ -329,7 +468,7 @@ SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ; · 8 unmodified lines |
| 329 | ** When passed a descriptor like this, the library will assume that the start | 468 | ** When passed a descriptor like this, the library will assume that the start |
| 330 | ** of file header is at the current file offset. This allows sound files within | 469 | ** of file header is at the current file offset. This allows sound files within |
| 331 | ** larger container files to be read and/or written. | 470 | ** larger container files to be read and/or written. |
| 332 | ** On error, this will return a NULL pointer. To find the error number, pass a | 471 | ** On error, this will return a NULL pointer. To find the error number, pass a |
| 333 | ** NULL SNDFILE to sf_perror () or sf_error_str (). | 472 | ** NULL SNDFILE to sf_perror () or sf_error_str (). |
| 334 | ** All calls to sf_open_fd() should be matched with a call to sf_close(). | 473 | ** All calls to sf_open_fd() should be matched with a call to sf_close(). |
| 335 | | 474 | |
| @@ -337,20 +476,22 @@ SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ; · 1 unmodified line |
| 337 | | 476 | |
| 338 | SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ; | 477 | SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ; |
| 339 | | 478 | |
| 340 | /* sf_error () returns a error number which can be translated to a text | 479 | SNDFILE* sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ; |
| | 480 | |
| | 481 | /* sf_error () returns a error number which can be translated to a text |
| 341 | ** string using sf_error_number(). | 482 | ** string using sf_error_number(). |
| 342 | */ | 483 | */ |
| 343 | | 484 | |
| 344 | int sf_error (SNDFILE *sndfile) ; | 485 | int sf_error (SNDFILE *sndfile) ; |
| 345 | | 486 | |
| 346 | /* sf_strerror () returns to the caller a pointer to the current error message for | 487 | /* sf_strerror () returns to the caller a pointer to the current error message for |
| 347 | ** the given SNDFILE. | 488 | ** the given SNDFILE. |
| 348 | */ | 489 | */ |
| 349 | | 490 | |
| 350 | const char* sf_strerror (SNDFILE *sndfile) ; | 491 | const char* sf_strerror (SNDFILE *sndfile) ; |
| 351 | | 492 | |
| 352 | /* sf_error_number () allows the retrieval of the error string for each internal | 493 | /* sf_error_number () allows the retrieval of the error string for each internal |
| 353 | ** error number. | 494 | ** error number. |
| 354 | ** | 495 | ** |
| 355 | */ | 496 | */ |
| 356 | | 497 | |
| @@ -403,7 +544,7 @@ const char* sf_get_string (SNDFILE *sndfile, int str_type) ; · 46 unmodified lines |
| 403 | */ | 544 | */ |
| 404 | | 545 | |
| 405 | sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ; | 546 | sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ; |
| 406 | sf_count_t sf_write_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ; | 547 | sf_count_t sf_write_raw (SNDFILE *sndfile, const void *ptr, sf_count_t bytes) ; |
| 407 | | 548 | |
| 408 | /* Functions for reading and writing the data chunk in terms of frames. | 549 | /* Functions for reading and writing the data chunk in terms of frames. |
| 409 | ** The number of items actually read/written = frames * number of channels. | 550 | ** The number of items actually read/written = frames * number of channels. |
| @@ -416,16 +557,16 @@ sf_count_t sf_write_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ; · 6 unmodified lines |
| 416 | */ | 557 | */ |
| 417 | | 558 | |
| 418 | sf_count_t sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ; | 559 | sf_count_t sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ; |
| 419 | sf_count_t sf_writef_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ; | 560 | sf_count_t sf_writef_short (SNDFILE *sndfile, const short *ptr, sf_count_t frames) ; |
| 420 | | 561 | |
| 421 | sf_count_t sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ; | 562 | sf_count_t sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ; |
| 422 | sf_count_t sf_writef_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ; | 563 | sf_count_t sf_writef_int (SNDFILE *sndfile, const int *ptr, sf_count_t frames) ; |
| 423 | | 564 | |
| 424 | sf_count_t sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ; | 565 | sf_count_t sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ; |
| 425 | sf_count_t sf_writef_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ; | 566 | sf_count_t sf_writef_float (SNDFILE *sndfile, const float *ptr, sf_count_t frames) ; |
| 426 | | 567 | |
| 427 | sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ; | 568 | sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ; |
| 428 | sf_count_t sf_writef_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ; | 569 | sf_count_t sf_writef_double (SNDFILE *sndfile, const double *ptr, sf_count_t frames) ; |
| 429 | | 570 | |
| 430 | /* Functions for reading and writing the data chunk in terms of items. | 571 | /* Functions for reading and writing the data chunk in terms of items. |
| 431 | ** Otherwise similar to above. | 572 | ** Otherwise similar to above. |
| @@ -433,16 +574,16 @@ sf_count_t sf_writef_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ; · 1 unmodified line |
| 433 | */ | 574 | */ |
| 434 | | 575 | |
| 435 | sf_count_t sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ; | 576 | sf_count_t sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ; |
| 436 | sf_count_t sf_write_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ; | 577 | sf_count_t sf_write_short (SNDFILE *sndfile, const short *ptr, sf_count_t items) ; |
| 437 | | 578 | |
| 438 | sf_count_t sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ; | 579 | sf_count_t sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ; |
| 439 | sf_count_t sf_write_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ; | 580 | sf_count_t sf_write_int (SNDFILE *sndfile, const int *ptr, sf_count_t items) ; |
| 440 | | 581 | |
| 441 | sf_count_t sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ; | 582 | sf_count_t sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ; |
| 442 | sf_count_t sf_write_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ; | 583 | sf_count_t sf_write_float (SNDFILE *sndfile, const float *ptr, sf_count_t items) ; |
| 443 | | 584 | |
| 444 | sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ; | 585 | sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ; |
| 445 | sf_count_t sf_write_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ; | 586 | sf_count_t sf_write_double (SNDFILE *sndfile, const double *ptr, sf_count_t items) ; |
| 446 | | 587 | |
| 447 | /* Close the SNDFILE and clean up all memory allocations associated with this | 588 | /* Close the SNDFILE and clean up all memory allocations associated with this |
| 448 | ** file. | 589 | ** file. |
| @@ -451,17 +592,15 @@ sf_count_t sf_write_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ; · 2 unmodified lines |
| 451 | | 592 | |
| 452 | int sf_close (SNDFILE *sndfile) ; | 593 | int sf_close (SNDFILE *sndfile) ; |
| 453 | | 594 | |
| | 595 | /* If the file is opened SFM_WRITE or SFM_RDWR, call fsync() on the file |
| | 596 | ** to force the writing of data to disk. If the file is opened SFM_READ |
| | 597 | ** no action is taken. |
| | 598 | */ |
| | 599 | |
| | 600 | void sf_write_sync (SNDFILE *sndfile) ; |
| | 601 | |
| 454 | #ifdef __cplusplus | 602 | #ifdef __cplusplus |
| 455 | } /* extern "C" */ | 603 | } /* extern "C" */ |
| 456 | #endif /* __cplusplus */ | 604 | #endif /* __cplusplus */ |
| 457 | | 605 | |
| 458 | #endif /* SNDFILE_H */ | 606 | #endif /* SNDFILE_H */ |
| 459 | | | |
| 460 | /* | | |
| 461 | ** Do not edit or modify anything in this comment block. | | |
| 462 | ** The arch-tag line is a file identity tag for the GNU Arch | | |
| 463 | ** revision control system. | | |
| 464 | ** | | |
| 465 | ** arch-tag: 906bb197-18f2-4f66-a395-b4722bab5114 | | |
| 466 | */ | | |
| 467 | | | |