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