1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
#![allow(non_snake_case, non_camel_case_types)]

extern crate libc;

#[cfg(windows)]
use libc::wchar_t;
use libc::{c_char, c_double, c_float, c_int, c_short, c_uint, c_void, size_t};
use std::i64;

#[link(name = "sndfile")]
extern "C" {}

#[cfg(test)]
mod test;

pub const SF_FORMAT_WAV: c_int = 0x010000;
pub const SF_FORMAT_AIFF: c_int = 0x020000;
pub const SF_FORMAT_AU: c_int = 0x030000;
pub const SF_FORMAT_RAW: c_int = 0x040000;
pub const SF_FORMAT_PAF: c_int = 0x050000;
pub const SF_FORMAT_SVX: c_int = 0x060000;
pub const SF_FORMAT_NIST: c_int = 0x070000;
pub const SF_FORMAT_VOC: c_int = 0x080000;
pub const SF_FORMAT_IRCAM: c_int = 0x0A0000;
pub const SF_FORMAT_W64: c_int = 0x0B0000;
pub const SF_FORMAT_MAT4: c_int = 0x0C0000;
pub const SF_FORMAT_MAT5: c_int = 0x0D0000;
pub const SF_FORMAT_PVF: c_int = 0x0E0000;
pub const SF_FORMAT_XI: c_int = 0x0F0000;
pub const SF_FORMAT_HTK: c_int = 0x100000;
pub const SF_FORMAT_SDS: c_int = 0x110000;
pub const SF_FORMAT_AVR: c_int = 0x120000;
pub const SF_FORMAT_WAVEX: c_int = 0x130000;
pub const SF_FORMAT_SD2: c_int = 0x160000;
pub const SF_FORMAT_FLAC: c_int = 0x170000;
pub const SF_FORMAT_CAF: c_int = 0x180000;
pub const SF_FORMAT_WVE: c_int = 0x190000;
pub const SF_FORMAT_OGG: c_int = 0x200000;
pub const SF_FORMAT_MPC2K: c_int = 0x210000;
pub const SF_FORMAT_RF64: c_int = 0x220000;
pub const SF_FORMAT_MPEG: c_int = 0x230000;
pub const SF_FORMAT_PCM_S8: c_int = 0x0001;
pub const SF_FORMAT_PCM_16: c_int = 0x0002;
pub const SF_FORMAT_PCM_24: c_int = 0x0003;
pub const SF_FORMAT_PCM_32: c_int = 0x0004;
pub const SF_FORMAT_PCM_U8: c_int = 0x0005;
pub const SF_FORMAT_FLOAT: c_int = 0x0006;
pub const SF_FORMAT_DOUBLE: c_int = 0x0007;
pub const SF_FORMAT_ULAW: c_int = 0x0010;
pub const SF_FORMAT_ALAW: c_int = 0x0011;
pub const SF_FORMAT_IMA_ADPCM: c_int = 0x0012;
pub const SF_FORMAT_MS_ADPCM: c_int = 0x0013;
pub const SF_FORMAT_GSM610: c_int = 0x0020;
pub const SF_FORMAT_VOX_ADPCM: c_int = 0x0021;
pub const SF_FORMAT_NMS_ADPCM_16: c_int = 0x0022;
pub const SF_FORMAT_NMS_ADPCM_24: c_int = 0x0023;
pub const SF_FORMAT_NMS_ADPCM_32: c_int = 0x0024;
pub const SF_FORMAT_G721_32: c_int = 0x0030;
pub const SF_FORMAT_G723_24: c_int = 0x0031;
pub const SF_FORMAT_G723_40: c_int = 0x0032;
pub const SF_FORMAT_DWVW_12: c_int = 0x0040;
pub const SF_FORMAT_DWVW_16: c_int = 0x0041;
pub const SF_FORMAT_DWVW_24: c_int = 0x0042;
pub const SF_FORMAT_DWVW_N: c_int = 0x0043;
pub const SF_FORMAT_DPCM_8: c_int = 0x0050;
pub const SF_FORMAT_DPCM_16: c_int = 0x0051;
pub const SF_FORMAT_VORBIS: c_int = 0x0060;
pub const SF_FORMAT_OPUS: c_int = 0x0064;
pub const SF_FORMAT_ALAC_16: c_int = 0x0070;
pub const SF_FORMAT_ALAC_20: c_int = 0x0071;
pub const SF_FORMAT_ALAC_24: c_int = 0x0072;
pub const SF_FORMAT_ALAC_32: c_int = 0x0073;
pub const SF_FORMAT_MPEG_LAYER_I: c_int = 0x0080;
pub const SF_FORMAT_MPEG_LAYER_II: c_int = 0x0081;
pub const SF_FORMAT_MPEG_LAYER_III: c_int = 0x0082;
pub const SF_ENDIAN_FILE: c_int = 0x00000000;
pub const SF_ENDIAN_LITTLE: c_int = 0x10000000;
pub const SF_ENDIAN_BIG: c_int = 0x20000000;
pub const SF_ENDIAN_CPU: c_int = 0x30000000;
pub const SF_FORMAT_SUBMASK: c_int = 0x0000FFFF;
pub const SF_FORMAT_TYPEMASK: c_int = 0x0FFF0000;
pub const SF_FORMAT_ENDMASK: c_int = 0x30000000;

pub const SFC_GET_LIB_VERSION: c_int = 0x1000;
pub const SFC_GET_LOG_INFO: c_int = 0x1001;
pub const SFC_GET_CURRENT_SF_INFO: c_int = 0x1002;
pub const SFC_GET_NORM_DOUBLE: c_int = 0x1010;
pub const SFC_GET_NORM_FLOAT: c_int = 0x1011;
pub const SFC_SET_NORM_DOUBLE: c_int = 0x1012;
pub const SFC_SET_NORM_FLOAT: c_int = 0x1013;
pub const SFC_SET_SCALE_FLOAT_INT_READ: c_int = 0x1014;
pub const SFC_SET_SCALE_INT_FLOAT_WRITE: c_int = 0x1015;
pub const SFC_GET_SIMPLE_FORMAT_COUNT: c_int = 0x1020;
pub const SFC_GET_SIMPLE_FORMAT: c_int = 0x1021;
pub const SFC_GET_FORMAT_INFO: c_int = 0x1028;
pub const SFC_GET_FORMAT_MAJOR_COUNT: c_int = 0x1030;
pub const SFC_GET_FORMAT_MAJOR: c_int = 0x1031;
pub const SFC_GET_FORMAT_SUBTYPE_COUNT: c_int = 0x1032;
pub const SFC_GET_FORMAT_SUBTYPE: c_int = 0x1033;
pub const SFC_CALC_SIGNAL_MAX: c_int = 0x1040;
pub const SFC_CALC_NORM_SIGNAL_MAX: c_int = 0x1041;
pub const SFC_CALC_MAX_ALL_CHANNELS: c_int = 0x1042;
pub const SFC_CALC_NORM_MAX_ALL_CHANNELS: c_int = 0x1043;
pub const SFC_GET_SIGNAL_MAX: c_int = 0x1044;
pub const SFC_GET_MAX_ALL_CHANNELS: c_int = 0x1045;
pub const SFC_SET_ADD_PEAK_CHUNK: c_int = 0x1050;
pub const SFC_UPDATE_HEADER_NOW: c_int = 0x1060;
pub const SFC_SET_UPDATE_HEADER_AUTO: c_int = 0x1061;
pub const SFC_FILE_TRUNCATE: c_int = 0x1080;
pub const SFC_SET_RAW_START_OFFSET: c_int = 0x1090;
pub const SFC_SET_DITHER_ON_WRITE: c_int = 0x10A0;
pub const SFC_SET_DITHER_ON_READ: c_int = 0x10A1;
pub const SFC_GET_DITHER_INFO_COUNT: c_int = 0x10A2;
pub const SFC_GET_DITHER_INFO: c_int = 0x10A3;
pub const SFC_GET_EMBED_FILE_INFO: c_int = 0x10B0;
pub const SFC_SET_CLIPPING: c_int = 0x10C0;
pub const SFC_GET_CLIPPING: c_int = 0x10C1;
pub const SFC_GET_CUE_COUNT: c_int = 0x10CD;
pub const SFC_GET_CUE: c_int = 0x10CE;
pub const SFC_SET_CUE: c_int = 0x10CF;
pub const SFC_GET_INSTRUMENT: c_int = 0x10D0;
pub const SFC_SET_INSTRUMENT: c_int = 0x10D1;
pub const SFC_GET_LOOP_INFO: c_int = 0x10E0;
pub const SFC_GET_BROADCAST_INFO: c_int = 0x10F0;
pub const SFC_SET_BROADCAST_INFO: c_int = 0x10F1;
pub const SFC_GET_CHANNEL_MAP_INFO: c_int = 0x1100;
pub const SFC_SET_CHANNEL_MAP_INFO: c_int = 0x1101;
pub const SFC_RAW_DATA_NEEDS_ENDSWAP: c_int = 0x1110;
pub const SFC_WAVEX_SET_AMBISONIC: c_int = 0x1200;
pub const SFC_WAVEX_GET_AMBISONIC: c_int = 0x1201;
pub const SFC_RF64_AUTO_DOWNGRADE: c_int = 0x1210;
pub const SFC_SET_VBR_ENCODING_QUALITY: c_int = 0x1300;
pub const SFC_SET_COMPRESSION_LEVEL: c_int = 0x1301;
pub const SFC_SET_OGG_PAGE_LATENCY_MS: c_int = 0x1302;
pub const SFC_SET_OGG_PAGE_LATENCY: c_int = 0x1303;
pub const SFC_GET_BITRATE_MODE: c_int = 0x1304;
pub const SFC_SET_BITRATE_MODE: c_int = 0x1305;
pub const SFC_SET_CART_INFO: c_int = 0x1400;
pub const SFC_GET_CART_INFO: c_int = 0x1401;
pub const SFC_SET_ORIGINAL_SAMPLERATE: c_int = 0x1500;
pub const SFC_GET_ORIGINAL_SAMPLERATE: c_int = 0x1501;
pub const SFC_TEST_IEEE_FLOAT_REPLACE: c_int = 0x6001;
pub const SFC_SET_ADD_HEADER_PAD_CHUNK: c_int = 0x1051;
pub const SFC_SET_ADD_DITHER_ON_WRITE: c_int = 0x1070;
pub const SFC_SET_ADD_DITHER_ON_READ: c_int = 0x1071;

pub const SF_STR_TITLE: c_int = 0x01;
pub const SF_STR_COPYRIGHT: c_int = 0x02;
pub const SF_STR_SOFTWARE: c_int = 0x03;
pub const SF_STR_ARTIST: c_int = 0x04;
pub const SF_STR_COMMENT: c_int = 0x05;
pub const SF_STR_DATE: c_int = 0x06;
pub const SF_STR_ALBUM: c_int = 0x07;
pub const SF_STR_LICENSE: c_int = 0x08;
pub const SF_STR_TRACKNUMBER: c_int = 0x09;
pub const SF_STR_GENRE: c_int = 0x10;
pub const SF_STR_FIRST: c_int = SF_STR_TITLE;
pub const SF_STR_LAST: c_int = SF_STR_GENRE;

pub const SF_FALSE: c_int = 0;
pub const SF_TRUE: c_int = 1;

pub const SFM_READ: c_int = 0x10;
pub const SFM_WRITE: c_int = 0x20;
pub const SFM_RDWR: c_int = 0x30;

pub const SF_AMBISONIC_NONE: c_int = 0x40;
pub const SF_AMBISONIC_B_FORMAT: c_int = 0x41;

pub const SF_ERR_NO_ERROR: c_int = 0;
pub const SF_ERR_UNRECOGNISED_FORMAT: c_int = 1;
pub const SF_ERR_SYSTEM: c_int = 2;
pub const SF_ERR_MALFORMED_FILE: c_int = 3;
pub const SF_ERR_UNSUPPORTED_ENCODING: c_int = 4;

pub const SF_CHANNEL_MAP_INVALID: c_int = 0;
pub const SF_CHANNEL_MAP_MONO: c_int = 1;
pub const SF_CHANNEL_MAP_LEFT: c_int = 2;
pub const SF_CHANNEL_MAP_RIGHT: c_int = 3;
pub const SF_CHANNEL_MAP_CENTER: c_int = 4;
pub const SF_CHANNEL_MAP_FRONT_LEFT: c_int = 5;
pub const SF_CHANNEL_MAP_FRONT_RIGHT: c_int = 6;
pub const SF_CHANNEL_MAP_FRONT_CENTER: c_int = 7;
pub const SF_CHANNEL_MAP_REAR_CENTER: c_int = 8;
pub const SF_CHANNEL_MAP_REAR_LEFT: c_int = 9;
pub const SF_CHANNEL_MAP_REAR_RIGHT: c_int = 10;
pub const SF_CHANNEL_MAP_LFE: c_int = 11;
pub const SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER: c_int = 12;
pub const SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER: c_int = 13;
pub const SF_CHANNEL_MAP_SIDE_LEFT: c_int = 14;
pub const SF_CHANNEL_MAP_SIDE_RIGHT: c_int = 15;
pub const SF_CHANNEL_MAP_TOP_CENTER: c_int = 16;
pub const SF_CHANNEL_MAP_TOP_FRONT_LEFT: c_int = 17;
pub const SF_CHANNEL_MAP_TOP_FRONT_RIGHT: c_int = 18;
pub const SF_CHANNEL_MAP_TOP_FRONT_CENTER: c_int = 19;
pub const SF_CHANNEL_MAP_TOP_REAR_LEFT: c_int = 20;
pub const SF_CHANNEL_MAP_TOP_REAR_RIGHT: c_int = 21;
pub const SF_CHANNEL_MAP_TOP_REAR_CENTER: c_int = 22;
pub const SF_CHANNEL_MAP_AMBISONIC_B_W: c_int = 23;
pub const SF_CHANNEL_MAP_AMBISONIC_B_X: c_int = 24;
pub const SF_CHANNEL_MAP_AMBISONIC_B_Y: c_int = 25;
pub const SF_CHANNEL_MAP_AMBISONIC_B_Z: c_int = 26;
pub const SF_CHANNEL_MAP_MAX: c_int = 27;

pub type SNDFILE = c_void;

pub type sf_count_t = i64;

pub const SF_COUNT_MAX: i64 = i64::MAX;

#[repr(C)]
#[derive(Debug)]
pub struct SF_INFO {
    pub frames: sf_count_t,
    pub samplerate: c_int,
    pub channels: c_int,
    pub format: c_int,
    pub sections: c_int,
    pub seekable: c_int,
}

#[repr(C)]
#[derive(Debug)]
pub struct SF_FORMAT_INFO {
    pub format: c_int,
    pub name: *const c_char,
    pub extension: *const c_char,
}

pub const SFD_DEFAULT_LEVEL: c_int = 0;
pub const SFD_CUSTOM_LEVEL: c_int = 0x40000000;
pub const SFD_NO_DITHER: c_int = 500;
pub const SFD_WHITE: c_int = 501;
pub const SFD_TRIANGULAR_PDF: c_int = 502;

#[repr(C)]
#[derive(Debug)]
pub struct SF_DITHER_INFO {
    pub type_: c_int,
    pub level: c_double,
    pub name: *const c_char,
}

#[repr(C)]
#[derive(Debug)]
pub struct SF_EMBED_FILE_INFO {
    pub offset: sf_count_t,
    pub length: sf_count_t,
}

#[repr(C)]
pub struct SF_CUE_POINT {
    pub indx: i32,
    pub position: u32,
    pub fcc_chunk: i32,
    pub chunk_start: i32,
    pub block_start: i32,
    pub sample_offset: u32,
    pub name: [c_char; 256],
}

#[repr(C)]
pub struct SF_CUES {
    pub cue_count: u32,
    pub cue_points: [SF_CUE_POINT; 100],
}

pub const SF_LOOP_NONE: c_int = 800;
pub const SF_LOOP_FORWARD: c_int = 801;
pub const SF_LOOP_BACKWARD: c_int = 802;
pub const SF_LOOP_ALTERNATING: c_int = 803;

#[repr(C)]
#[derive(Debug)]
pub struct SF_INSTRUMENT_LOOP {
    pub mode: c_int,
    pub start: u32,
    pub end: u32,
    pub count: u32,
}

#[repr(C)]
pub struct SF_INSTRUMENT {
    pub gain: c_int,
    pub basenote: c_char,
    pub detune: c_char,
    pub velocity_lo: c_char,
    pub velocity_hi: c_char,
    pub key_lo: c_char,
    pub key_hi: c_char,
    pub loop_count: c_int,
    pub loops: [SF_INSTRUMENT_LOOP; 16],
}

#[repr(C)]
pub struct SF_LOOP_INFO {
    pub time_sig_num: c_short,
    pub time_sig_den: c_short,
    pub loop_mode: c_int,
    pub num_beats: c_int,
    pub bpm: c_float,
    pub root_key: c_int,
    pub future: [c_int; 6],
}

#[repr(C)]
pub struct SF_BROADCAST_INFO {
    pub description: [c_char; 256],
    pub originator: [c_char; 32],
    pub originator_reference: [c_char; 32],
    pub origination_date: [c_char; 10],
    pub origination_time: [c_char; 8],
    pub time_reference_low: u32,
    pub time_reference_high: u32,
    pub version: c_short,
    pub umid: [c_char; 64],
    pub reserved: [c_char; 190],
    pub coding_history_size: u32,
    pub coding_history: [c_char; 256],
}

#[repr(C)]
pub struct SF_CART_TIMER {
    pub usage: [c_char; 4],
    pub value: i32,
}

#[repr(C)]
pub struct SF_CART_INFO {
    pub version: [c_char; 4],
    pub title: [c_char; 64],
    pub artist: [c_char; 64],
    pub cut_id: [c_char; 64],
    pub client_id: [c_char; 64],
    pub category: [c_char; 64],
    pub classification: [c_char; 64],
    pub out_cue: [c_char; 64],
    pub start_date: [c_char; 10],
    pub start_time: [c_char; 8],
    pub end_date: [c_char; 10],
    pub end_time: [c_char; 8],
    pub producer_app_id: [c_char; 64],
    pub producer_app_version: [c_char; 64],
    pub user_def: [c_char; 64],
    pub level_reference: i32,
    pub post_timers: [SF_CART_TIMER; 8],
    pub reserved: [c_char; 276],
    pub url: [c_char; 1024],
    pub tag_text_size: i32,
    pub tag_text: [c_char; 256],
}

pub type sf_vio_get_filelen = extern "C" fn(user_data: *mut c_void) -> sf_count_t;
pub type sf_vio_seek =
    extern "C" fn(offset: sf_count_t, whence: c_int, user_data: *mut c_void) -> sf_count_t;
pub type sf_vio_read =
    extern "C" fn(ptr: *mut c_void, count: sf_count_t, user_data: *mut c_void) -> sf_count_t;
pub type sf_vio_write =
    extern "C" fn(ptr: *const c_void, count: sf_count_t, user_data: *mut c_void) -> sf_count_t;
pub type sf_vio_tell = extern "C" fn(user_data: *mut c_void) -> sf_count_t;

#[repr(C)]
#[derive(Debug)]
pub struct SF_VIRTUAL_IO {
    pub get_filelen: sf_vio_get_filelen,
    pub seek: sf_vio_seek,
    pub read: sf_vio_read,
    pub write: sf_vio_write,
    pub tell: sf_vio_tell,
}

pub const SF_SEEK_SET: c_int = 0;
pub const SF_SEEK_CUR: c_int = 1;
pub const SF_SEEK_END: c_int = 2;

#[repr(C)]
pub struct SF_CHUNK_INFO {
    id: [c_char; 64],
    id_size: c_uint,
    datalen: c_uint,
    data: *mut c_void,
}

pub type SF_CHUNK_ITERATOR = c_void;

extern "C" {
    pub fn sf_open(path: *const c_char, mode: c_int, sfinfo: *mut SF_INFO) -> *mut SNDFILE;
    pub fn sf_open_fd(
        fd: c_int,
        mode: c_int,
        sfinfo: *mut SF_INFO,
        close_desc: c_int,
    ) -> *mut SNDFILE;
    pub fn sf_open_virtual(
        sfvirtual: *mut SF_VIRTUAL_IO,
        mode: c_int,
        sfinfo: *mut SF_INFO,
        user_data: *mut c_void,
    ) -> *mut SNDFILE;
    #[cfg(windows)]
    pub fn sf_wchar_open(wpath: *const wchar_t, mode: c_int, sfinfo: *mut SF_INFO) -> *mut SNDFILE;
    pub fn sf_error(sndfile: *mut SNDFILE) -> c_int;
    pub fn sf_strerror(sndfile: *mut SNDFILE) -> *const c_char;
    pub fn sf_error_number(errnum: c_int) -> *const c_char;
    pub fn sf_perror(sndfile: *mut SNDFILE) -> c_int;
    pub fn sf_error_str(sndfile: *mut SNDFILE, str_: *mut c_char, len: size_t) -> c_int;
    pub fn sf_command(
        sndfile: *mut SNDFILE,
        command: c_int,
        data: *mut c_void,
        datasize: c_int,
    ) -> c_int;
    pub fn sf_format_check(info: *const SF_INFO) -> c_int;
    pub fn sf_seek(sndfile: *mut SNDFILE, frames: sf_count_t, whence: c_int) -> sf_count_t;
    pub fn sf_set_string(sndfile: *mut SNDFILE, str_type: c_int, str_: *const c_char) -> c_int;
    pub fn sf_get_string(sndfile: *mut SNDFILE, str_type: c_int) -> *const c_char;
    pub fn sf_version_string() -> *const c_char;
    pub fn sf_current_byterate(sndfile: *mut SNDFILE) -> c_int;
    pub fn sf_read_raw(sndfile: *mut SNDFILE, ptr: *mut c_void, bytes: sf_count_t) -> sf_count_t;
    pub fn sf_write_raw(sndfile: *mut SNDFILE, ptr: *const c_void, bytes: sf_count_t)
        -> sf_count_t;
    pub fn sf_readf_short(
        sndfile: *mut SNDFILE,
        ptr: *mut c_short,
        frames: sf_count_t,
    ) -> sf_count_t;
    pub fn sf_writef_short(
        sndfile: *mut SNDFILE,
        ptr: *const c_short,
        frames: sf_count_t,
    ) -> sf_count_t;
    pub fn sf_readf_int(sndfile: *mut SNDFILE, ptr: *mut c_int, frames: sf_count_t) -> sf_count_t;
    pub fn sf_writef_int(
        sndfile: *mut SNDFILE,
        ptr: *const c_int,
        frames: sf_count_t,
    ) -> sf_count_t;
    pub fn sf_readf_float(
        sndfile: *mut SNDFILE,
        ptr: *mut c_float,
        frames: sf_count_t,
    ) -> sf_count_t;
    pub fn sf_writef_float(
        sndfile: *mut SNDFILE,
        ptr: *const c_float,
        frames: sf_count_t,
    ) -> sf_count_t;
    pub fn sf_readf_double(
        sndfile: *mut SNDFILE,
        ptr: *mut c_double,
        frames: sf_count_t,
    ) -> sf_count_t;
    pub fn sf_writef_double(
        sndfile: *mut SNDFILE,
        ptr: *const c_double,
        frames: sf_count_t,
    ) -> sf_count_t;
    pub fn sf_read_short(sndfile: *mut SNDFILE, ptr: *mut c_short, items: sf_count_t)
        -> sf_count_t;
    pub fn sf_write_short(
        sndfile: *mut SNDFILE,
        ptr: *const c_short,
        items: sf_count_t,
    ) -> sf_count_t;
    pub fn sf_read_int(sndfile: *mut SNDFILE, ptr: *mut c_int, items: sf_count_t) -> sf_count_t;
    pub fn sf_write_int(sndfile: *mut SNDFILE, ptr: *const c_int, items: sf_count_t) -> sf_count_t;
    pub fn sf_read_float(sndfile: *mut SNDFILE, ptr: *mut c_float, items: sf_count_t)
        -> sf_count_t;
    pub fn sf_write_float(
        sndfile: *mut SNDFILE,
        ptr: *const c_float,
        items: sf_count_t,
    ) -> sf_count_t;
    pub fn sf_read_double(
        sndfile: *mut SNDFILE,
        ptr: *mut c_double,
        items: sf_count_t,
    ) -> sf_count_t;
    pub fn sf_write_double(
        sndfile: *mut SNDFILE,
        ptr: *const c_double,
        items: sf_count_t,
    ) -> sf_count_t;
    pub fn sf_close(sndfile: *mut SNDFILE) -> c_int;
    pub fn sf_write_sync(sndfile: *mut SNDFILE);
    pub fn sf_set_chunk(sndfile: *mut SNDFILE, chunk_info: *const SF_CHUNK_INFO) -> c_int;
    pub fn sf_get_chunk_iterator(
        sndfile: *mut SNDFILE,
        chunk_info: *const SF_CHUNK_INFO,
    ) -> *mut SF_CHUNK_ITERATOR;
    pub fn sf_next_chunk_iterator(iterator: *mut SF_CHUNK_ITERATOR) -> *mut SF_CHUNK_ITERATOR;
    pub fn sf_get_chunk_size(it: *const SF_CHUNK_ITERATOR, chunk_info: *mut SF_CHUNK_INFO)
        -> c_int;
    pub fn sf_get_chunk_data(it: *const SF_CHUNK_ITERATOR, chunk_info: *mut SF_CHUNK_INFO)
        -> c_int;
}