andrew@0: /* andrew@0: ** Copyright (C) 1999-2006 Erik de Castro Lopo andrew@0: ** andrew@0: ** This program is free software; you can redistribute it and/or modify andrew@0: ** it under the terms of the GNU Lesser General Public License as published by andrew@0: ** the Free Software Foundation; either version 2.1 of the License, or andrew@0: ** (at your option) any later version. andrew@0: ** andrew@0: ** This program is distributed in the hope that it will be useful, andrew@0: ** but WITHOUT ANY WARRANTY; without even the implied warranty of andrew@0: ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the andrew@0: ** GNU Lesser General Public License for more details. andrew@0: ** andrew@0: ** You should have received a copy of the GNU Lesser General Public License andrew@0: ** along with this program; if not, write to the Free Software andrew@0: ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. andrew@0: */ andrew@0: andrew@0: /* andrew@0: ** sndfile.h -- system-wide definitions andrew@0: ** andrew@0: ** API documentation is in the doc/ directory of the source code tarball andrew@0: ** and at http://www.mega-nerd.com/libsndfile/api.html. andrew@0: */ andrew@0: andrew@0: #ifndef SNDFILE_H andrew@0: #define SNDFILE_H andrew@0: andrew@0: /* This is the version 1.0.X header file. */ andrew@0: #define SNDFILE_1 andrew@0: andrew@0: #include andrew@0: andrew@0: /* For the Metrowerks CodeWarrior Pro Compiler (mainly MacOS) */ andrew@0: andrew@0: #if (defined (__MWERKS__)) andrew@0: #include andrew@0: #else andrew@0: #include andrew@0: #endif andrew@0: andrew@0: #ifdef __cplusplus andrew@0: extern "C" { andrew@0: #endif /* __cplusplus */ andrew@0: andrew@0: /* The following file types can be read and written. andrew@0: ** A file type would consist of a major type (ie SF_FORMAT_WAV) bitwise andrew@0: ** ORed with a minor type (ie SF_FORMAT_PCM). SF_FORMAT_TYPEMASK and andrew@0: ** SF_FORMAT_SUBMASK can be used to separate the major and minor file andrew@0: ** types. andrew@0: */ andrew@0: andrew@0: enum andrew@0: { /* Major formats. */ andrew@0: SF_FORMAT_WAV = 0x010000, /* Microsoft WAV format (little endian default). */ andrew@0: SF_FORMAT_AIFF = 0x020000, /* Apple/SGI AIFF format (big endian). */ andrew@0: SF_FORMAT_AU = 0x030000, /* Sun/NeXT AU format (big endian). */ andrew@0: SF_FORMAT_RAW = 0x040000, /* RAW PCM data. */ andrew@0: SF_FORMAT_PAF = 0x050000, /* Ensoniq PARIS file format. */ andrew@0: SF_FORMAT_SVX = 0x060000, /* Amiga IFF / SVX8 / SV16 format. */ andrew@0: SF_FORMAT_NIST = 0x070000, /* Sphere NIST format. */ andrew@0: SF_FORMAT_VOC = 0x080000, /* VOC files. */ andrew@0: SF_FORMAT_IRCAM = 0x0A0000, /* Berkeley/IRCAM/CARL */ andrew@0: SF_FORMAT_W64 = 0x0B0000, /* Sonic Foundry's 64 bit RIFF/WAV */ andrew@0: SF_FORMAT_MAT4 = 0x0C0000, /* Matlab (tm) V4.2 / GNU Octave 2.0 */ andrew@0: SF_FORMAT_MAT5 = 0x0D0000, /* Matlab (tm) V5.0 / GNU Octave 2.1 */ andrew@0: SF_FORMAT_PVF = 0x0E0000, /* Portable Voice Format */ andrew@0: SF_FORMAT_XI = 0x0F0000, /* Fasttracker 2 Extended Instrument */ andrew@0: SF_FORMAT_HTK = 0x100000, /* HMM Tool Kit format */ andrew@0: SF_FORMAT_SDS = 0x110000, /* Midi Sample Dump Standard */ andrew@0: SF_FORMAT_AVR = 0x120000, /* Audio Visual Research */ andrew@0: SF_FORMAT_WAVEX = 0x130000, /* MS WAVE with WAVEFORMATEX */ andrew@0: SF_FORMAT_SD2 = 0x160000, /* Sound Designer 2 */ andrew@0: SF_FORMAT_FLAC = 0x170000, /* FLAC lossless file format */ andrew@0: SF_FORMAT_CAF = 0x180000, /* Core Audio File format */ andrew@0: andrew@0: /* Subtypes from here on. */ andrew@0: andrew@0: SF_FORMAT_PCM_S8 = 0x0001, /* Signed 8 bit data */ andrew@0: SF_FORMAT_PCM_16 = 0x0002, /* Signed 16 bit data */ andrew@0: SF_FORMAT_PCM_24 = 0x0003, /* Signed 24 bit data */ andrew@0: SF_FORMAT_PCM_32 = 0x0004, /* Signed 32 bit data */ andrew@0: andrew@0: SF_FORMAT_PCM_U8 = 0x0005, /* Unsigned 8 bit data (WAV and RAW only) */ andrew@0: andrew@0: SF_FORMAT_FLOAT = 0x0006, /* 32 bit float data */ andrew@0: SF_FORMAT_DOUBLE = 0x0007, /* 64 bit float data */ andrew@0: andrew@0: SF_FORMAT_ULAW = 0x0010, /* U-Law encoded. */ andrew@0: SF_FORMAT_ALAW = 0x0011, /* A-Law encoded. */ andrew@0: SF_FORMAT_IMA_ADPCM = 0x0012, /* IMA ADPCM. */ andrew@0: SF_FORMAT_MS_ADPCM = 0x0013, /* Microsoft ADPCM. */ andrew@0: andrew@0: SF_FORMAT_GSM610 = 0x0020, /* GSM 6.10 encoding. */ andrew@0: SF_FORMAT_VOX_ADPCM = 0x0021, /* OKI / Dialogix ADPCM */ andrew@0: andrew@0: SF_FORMAT_G721_32 = 0x0030, /* 32kbs G721 ADPCM encoding. */ andrew@0: SF_FORMAT_G723_24 = 0x0031, /* 24kbs G723 ADPCM encoding. */ andrew@0: SF_FORMAT_G723_40 = 0x0032, /* 40kbs G723 ADPCM encoding. */ andrew@0: andrew@0: SF_FORMAT_DWVW_12 = 0x0040, /* 12 bit Delta Width Variable Word encoding. */ andrew@0: SF_FORMAT_DWVW_16 = 0x0041, /* 16 bit Delta Width Variable Word encoding. */ andrew@0: SF_FORMAT_DWVW_24 = 0x0042, /* 24 bit Delta Width Variable Word encoding. */ andrew@0: SF_FORMAT_DWVW_N = 0x0043, /* N bit Delta Width Variable Word encoding. */ andrew@0: andrew@0: SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */ andrew@0: SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */ andrew@0: andrew@0: /* Endian-ness options. */ andrew@0: andrew@0: SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */ andrew@0: SF_ENDIAN_LITTLE = 0x10000000, /* Force little endian-ness. */ andrew@0: SF_ENDIAN_BIG = 0x20000000, /* Force big endian-ness. */ andrew@0: SF_ENDIAN_CPU = 0x30000000, /* Force CPU endian-ness. */ andrew@0: andrew@0: SF_FORMAT_SUBMASK = 0x0000FFFF, andrew@0: SF_FORMAT_TYPEMASK = 0x0FFF0000, andrew@0: SF_FORMAT_ENDMASK = 0x30000000 andrew@0: } ; andrew@0: andrew@0: /* andrew@0: ** The following are the valid command numbers for the sf_command() andrew@0: ** interface. The use of these commands is documented in the file andrew@0: ** command.html in the doc directory of the source code distribution. andrew@0: */ andrew@0: andrew@0: enum andrew@0: { SFC_GET_LIB_VERSION = 0x1000, andrew@0: SFC_GET_LOG_INFO = 0x1001, andrew@0: andrew@0: SFC_GET_NORM_DOUBLE = 0x1010, andrew@0: SFC_GET_NORM_FLOAT = 0x1011, andrew@0: SFC_SET_NORM_DOUBLE = 0x1012, andrew@0: SFC_SET_NORM_FLOAT = 0x1013, andrew@0: SFC_SET_SCALE_FLOAT_INT_READ = 0x1014, andrew@0: andrew@0: SFC_GET_SIMPLE_FORMAT_COUNT = 0x1020, andrew@0: SFC_GET_SIMPLE_FORMAT = 0x1021, andrew@0: andrew@0: SFC_GET_FORMAT_INFO = 0x1028, andrew@0: andrew@0: SFC_GET_FORMAT_MAJOR_COUNT = 0x1030, andrew@0: SFC_GET_FORMAT_MAJOR = 0x1031, andrew@0: SFC_GET_FORMAT_SUBTYPE_COUNT = 0x1032, andrew@0: SFC_GET_FORMAT_SUBTYPE = 0x1033, andrew@0: andrew@0: SFC_CALC_SIGNAL_MAX = 0x1040, andrew@0: SFC_CALC_NORM_SIGNAL_MAX = 0x1041, andrew@0: SFC_CALC_MAX_ALL_CHANNELS = 0x1042, andrew@0: SFC_CALC_NORM_MAX_ALL_CHANNELS = 0x1043, andrew@0: SFC_GET_SIGNAL_MAX = 0x1044, andrew@0: SFC_GET_MAX_ALL_CHANNELS = 0x1045, andrew@0: andrew@0: SFC_SET_ADD_PEAK_CHUNK = 0x1050, andrew@0: andrew@0: SFC_UPDATE_HEADER_NOW = 0x1060, andrew@0: SFC_SET_UPDATE_HEADER_AUTO = 0x1061, andrew@0: andrew@0: SFC_FILE_TRUNCATE = 0x1080, andrew@0: andrew@0: SFC_SET_RAW_START_OFFSET = 0x1090, andrew@0: andrew@0: SFC_SET_DITHER_ON_WRITE = 0x10A0, andrew@0: SFC_SET_DITHER_ON_READ = 0x10A1, andrew@0: andrew@0: SFC_GET_DITHER_INFO_COUNT = 0x10A2, andrew@0: SFC_GET_DITHER_INFO = 0x10A3, andrew@0: andrew@0: SFC_GET_EMBED_FILE_INFO = 0x10B0, andrew@0: andrew@0: SFC_SET_CLIPPING = 0x10C0, andrew@0: SFC_GET_CLIPPING = 0x10C1, andrew@0: andrew@0: SFC_GET_INSTRUMENT = 0x10D0, andrew@0: SFC_SET_INSTRUMENT = 0x10D1, andrew@0: andrew@0: SFC_GET_LOOP_INFO = 0x10E0, andrew@0: andrew@0: SFC_GET_BROADCAST_INFO = 0x10F0, andrew@0: SFC_SET_BROADCAST_INFO = 0x10F1, andrew@0: andrew@0: /* Following commands for testing only. */ andrew@0: SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001, andrew@0: andrew@0: /* andrew@0: ** SFC_SET_ADD_* values are deprecated and will disappear at some andrew@0: ** time in the future. They are guaranteed to be here up to and andrew@0: ** including version 1.0.8 to avoid breakage of existng software. andrew@0: ** They currently do nothing and will continue to do nothing. andrew@0: */ andrew@0: SFC_SET_ADD_DITHER_ON_WRITE = 0x1070, andrew@0: SFC_SET_ADD_DITHER_ON_READ = 0x1071 andrew@0: } ; andrew@0: andrew@0: andrew@0: /* andrew@0: ** String types that can be set and read from files. Not all file types andrew@0: ** support this and even the file types which support one, may not support andrew@0: ** all string types. andrew@0: */ andrew@0: andrew@0: enum andrew@0: { SF_STR_TITLE = 0x01, andrew@0: SF_STR_COPYRIGHT = 0x02, andrew@0: SF_STR_SOFTWARE = 0x03, andrew@0: SF_STR_ARTIST = 0x04, andrew@0: SF_STR_COMMENT = 0x05, andrew@0: SF_STR_DATE = 0x06 andrew@0: } ; andrew@0: andrew@0: /* andrew@0: ** Use the following as the start and end index when doing metadata andrew@0: ** transcoding. andrew@0: */ andrew@0: andrew@0: #define SF_STR_FIRST SF_STR_TITLE andrew@0: #define SF_STR_LAST SF_STR_DATE andrew@0: andrew@0: enum andrew@0: { /* True and false */ andrew@0: SF_FALSE = 0, andrew@0: SF_TRUE = 1, andrew@0: andrew@0: /* Modes for opening files. */ andrew@0: SFM_READ = 0x10, andrew@0: SFM_WRITE = 0x20, andrew@0: SFM_RDWR = 0x30 andrew@0: } ; andrew@0: andrew@0: /* Public error values. These are guaranteed to remain unchanged for the duration andrew@0: ** of the library major version number. andrew@0: ** There are also a large number of private error numbers which are internal to andrew@0: ** the library which can change at any time. andrew@0: */ andrew@0: andrew@0: enum andrew@0: { SF_ERR_NO_ERROR = 0, andrew@0: SF_ERR_UNRECOGNISED_FORMAT = 1, andrew@0: SF_ERR_SYSTEM = 2, andrew@0: SF_ERR_MALFORMED_FILE = 3, andrew@0: SF_ERR_UNSUPPORTED_ENCODING = 4 andrew@0: } ; andrew@0: andrew@0: /* A SNDFILE* pointer can be passed around much like stdio.h's FILE* pointer. */ andrew@0: andrew@0: typedef struct SNDFILE_tag SNDFILE ; andrew@0: andrew@0: /* The following typedef is system specific and is defined when libsndfile is. andrew@0: ** compiled. sf_count_t can be one of loff_t (Linux), off_t (*BSD), andrew@0: ** off64_t (Solaris), __int64_t (Win32) etc. andrew@0: */ andrew@0: andrew@0: typedef off_t sf_count_t ; andrew@0: andrew@0: #define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFLL andrew@0: andrew@0: /* A pointer to a SF_INFO structure is passed to sf_open_read () and filled in. andrew@0: ** On write, the SF_INFO structure is filled in by the user and passed into andrew@0: ** sf_open_write (). andrew@0: */ andrew@0: andrew@0: struct SF_INFO andrew@0: { sf_count_t frames ; /* Used to be called samples. Changed to avoid confusion. */ andrew@0: int samplerate ; andrew@0: int channels ; andrew@0: int format ; andrew@0: int sections ; andrew@0: int seekable ; andrew@0: } ; andrew@0: andrew@0: typedef struct SF_INFO SF_INFO ; andrew@0: andrew@0: /* The SF_FORMAT_INFO struct is used to retrieve information about the sound andrew@0: ** file formats libsndfile supports using the sf_command () interface. andrew@0: ** andrew@0: ** Using this interface will allow applications to support new file formats andrew@0: ** and encoding types when libsndfile is upgraded, without requiring andrew@0: ** re-compilation of the application. andrew@0: ** andrew@0: ** Please consult the libsndfile documentation (particularly the information andrew@0: ** on the sf_command () interface) for examples of its use. andrew@0: */ andrew@0: andrew@0: typedef struct andrew@0: { int format ; andrew@0: const char *name ; andrew@0: const char *extension ; andrew@0: } SF_FORMAT_INFO ; andrew@0: andrew@0: /* andrew@0: ** Enums and typedefs for adding dither on read and write. andrew@0: ** See the html documentation for sf_command(), SFC_SET_DITHER_ON_WRITE andrew@0: ** and SFC_SET_DITHER_ON_READ. andrew@0: */ andrew@0: andrew@0: enum andrew@0: { SFD_DEFAULT_LEVEL = 0, andrew@0: SFD_CUSTOM_LEVEL = 0x40000000, andrew@0: andrew@0: SFD_NO_DITHER = 500, andrew@0: SFD_WHITE = 501, andrew@0: SFD_TRIANGULAR_PDF = 502 andrew@0: } ; andrew@0: andrew@0: typedef struct andrew@0: { int type ; andrew@0: double level ; andrew@0: const char *name ; andrew@0: } SF_DITHER_INFO ; andrew@0: andrew@0: /* Struct used to retrieve information about a file embedded within a andrew@0: ** larger file. See SFC_GET_EMBED_FILE_INFO. andrew@0: */ andrew@0: andrew@0: typedef struct andrew@0: { sf_count_t offset ; andrew@0: sf_count_t length ; andrew@0: } SF_EMBED_FILE_INFO ; andrew@0: andrew@0: /* andrew@0: ** Structs used to retrieve music sample information from a file. andrew@0: */ andrew@0: andrew@0: enum andrew@0: { /* andrew@0: ** The loop mode field in SF_INSTRUMENT will be one of the following. andrew@0: */ andrew@0: SF_LOOP_NONE = 800, andrew@0: SF_LOOP_FORWARD, andrew@0: SF_LOOP_BACKWARD, andrew@0: SF_LOOP_ALTERNATING andrew@0: } ; andrew@0: andrew@0: typedef struct andrew@0: { int gain ; andrew@0: char basenote, detune ; andrew@0: char velocity_lo, velocity_hi ; andrew@0: char key_lo, key_hi ; andrew@0: int loop_count ; andrew@0: andrew@0: struct andrew@0: { int mode ; andrew@0: unsigned int start ; andrew@0: unsigned int end ; andrew@0: unsigned int count ; andrew@0: } loops [16] ; /* make variable in a sensible way */ andrew@0: } SF_INSTRUMENT ; andrew@0: andrew@0: andrew@0: andrew@0: /* Struct used to retrieve loop information from a file.*/ andrew@0: typedef struct andrew@0: { andrew@0: short time_sig_num ; /* any positive integer > 0 */ andrew@0: short time_sig_den ; /* any positive power of 2 > 0 */ andrew@0: int loop_mode ; /* see SF_LOOP enum */ andrew@0: andrew@0: int num_beats ; /* this is NOT the amount of quarter notes !!!*/ andrew@0: /* a full bar of 4/4 is 4 beats */ andrew@0: /* a full bar of 7/8 is 7 beats */ andrew@0: andrew@0: float bpm ; /* suggestion, as it can be calculated using other fields:*/ andrew@0: /* file's lenght, file's sampleRate and our time_sig_den*/ andrew@0: /* -> bpms are always the amount of _quarter notes_ per minute */ andrew@0: andrew@0: int root_key ; /* MIDI note, or -1 for None */ andrew@0: int future [6] ; andrew@0: } SF_LOOP_INFO ; andrew@0: andrew@0: andrew@0: /* Struct used to retrieve broadcast (EBU) information from a file. andrew@0: ** Strongly (!) based on EBU "bext" chunk format used in Broadcast WAVE. andrew@0: */ andrew@0: typedef struct andrew@0: { char description [256] ; andrew@0: char originator [32] ; andrew@0: char originator_reference [32] ; andrew@0: char origination_date [10] ; andrew@0: char origination_time [8] ; andrew@0: int time_reference_low ; andrew@0: int time_reference_high ; andrew@0: short version ; andrew@0: char umid [64] ; andrew@0: char reserved [190] ; andrew@0: unsigned int coding_history_size ; andrew@0: char coding_history [256] ; andrew@0: } SF_BROADCAST_INFO ; andrew@0: andrew@0: typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ; andrew@0: typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ; andrew@0: typedef sf_count_t (*sf_vio_read) (void *ptr, sf_count_t count, void *user_data) ; andrew@0: typedef sf_count_t (*sf_vio_write) (const void *ptr, sf_count_t count, void *user_data) ; andrew@0: typedef sf_count_t (*sf_vio_tell) (void *user_data) ; andrew@0: andrew@0: struct SF_VIRTUAL_IO andrew@0: { sf_vio_get_filelen get_filelen ; andrew@0: sf_vio_seek seek ; andrew@0: sf_vio_read read ; andrew@0: sf_vio_write write ; andrew@0: sf_vio_tell tell ; andrew@0: } ; andrew@0: andrew@0: typedef struct SF_VIRTUAL_IO SF_VIRTUAL_IO ; andrew@0: andrew@0: /* Open the specified file for read, write or both. On error, this will andrew@0: ** return a NULL pointer. To find the error number, pass a NULL SNDFILE andrew@0: ** to sf_perror () or sf_error_str (). andrew@0: ** All calls to sf_open() should be matched with a call to sf_close(). andrew@0: */ andrew@0: andrew@0: SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ; andrew@0: andrew@0: /* Use the existing file descriptor to create a SNDFILE object. If close_desc andrew@0: ** is TRUE, the file descriptor will be closed when sf_close() is called. If andrew@0: ** it is FALSE, the descritor will not be closed. andrew@0: ** When passed a descriptor like this, the library will assume that the start andrew@0: ** of file header is at the current file offset. This allows sound files within andrew@0: ** larger container files to be read and/or written. andrew@0: ** On error, this will return a NULL pointer. To find the error number, pass a andrew@0: ** NULL SNDFILE to sf_perror () or sf_error_str (). andrew@0: ** All calls to sf_open_fd() should be matched with a call to sf_close(). andrew@0: andrew@0: */ andrew@0: andrew@0: SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ; andrew@0: andrew@0: SNDFILE* sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ; andrew@0: andrew@0: /* sf_error () returns a error number which can be translated to a text andrew@0: ** string using sf_error_number(). andrew@0: */ andrew@0: andrew@0: int sf_error (SNDFILE *sndfile) ; andrew@0: andrew@0: /* sf_strerror () returns to the caller a pointer to the current error message for andrew@0: ** the given SNDFILE. andrew@0: */ andrew@0: andrew@0: const char* sf_strerror (SNDFILE *sndfile) ; andrew@0: andrew@0: /* sf_error_number () allows the retrieval of the error string for each internal andrew@0: ** error number. andrew@0: ** andrew@0: */ andrew@0: andrew@0: const char* sf_error_number (int errnum) ; andrew@0: andrew@0: /* The following three error functions are deprecated but they will remain in the andrew@0: ** library for the forseeable future. The function sf_strerror() should be used andrew@0: ** in their place. andrew@0: */ andrew@0: andrew@0: int sf_perror (SNDFILE *sndfile) ; andrew@0: int sf_error_str (SNDFILE *sndfile, char* str, size_t len) ; andrew@0: andrew@0: andrew@0: /* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */ andrew@0: andrew@0: int sf_command (SNDFILE *sndfile, int command, void *data, int datasize) ; andrew@0: andrew@0: /* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */ andrew@0: andrew@0: int sf_format_check (const SF_INFO *info) ; andrew@0: andrew@0: /* Seek within the waveform data chunk of the SNDFILE. sf_seek () uses andrew@0: ** the same values for whence (SEEK_SET, SEEK_CUR and SEEK_END) as andrew@0: ** stdio.h function fseek (). andrew@0: ** An offset of zero with whence set to SEEK_SET will position the andrew@0: ** read / write pointer to the first data sample. andrew@0: ** On success sf_seek returns the current position in (multi-channel) andrew@0: ** samples from the start of the file. andrew@0: ** Please see the libsndfile documentation for moving the read pointer andrew@0: ** separately from the write pointer on files open in mode SFM_RDWR. andrew@0: ** On error all of these functions return -1. andrew@0: */ andrew@0: andrew@0: sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ; andrew@0: andrew@0: /* Functions for retrieving and setting string data within sound files. andrew@0: ** Not all file types support this features; AIFF and WAV do. For both andrew@0: ** functions, the str_type parameter must be one of the SF_STR_* values andrew@0: ** defined above. andrew@0: ** On error, sf_set_string() returns non-zero while sf_get_string() andrew@0: ** returns NULL. andrew@0: */ andrew@0: andrew@0: int sf_set_string (SNDFILE *sndfile, int str_type, const char* str) ; andrew@0: andrew@0: const char* sf_get_string (SNDFILE *sndfile, int str_type) ; andrew@0: andrew@0: /* Functions for reading/writing the waveform data of a sound file. andrew@0: */ andrew@0: andrew@0: sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ; andrew@0: sf_count_t sf_write_raw (SNDFILE *sndfile, const void *ptr, sf_count_t bytes) ; andrew@0: andrew@0: /* Functions for reading and writing the data chunk in terms of frames. andrew@0: ** The number of items actually read/written = frames * number of channels. andrew@0: ** sf_xxxx_raw read/writes the raw data bytes from/to the file andrew@0: ** sf_xxxx_short passes data in the native short format andrew@0: ** sf_xxxx_int passes data in the native int format andrew@0: ** sf_xxxx_float passes data in the native float format andrew@0: ** sf_xxxx_double passes data in the native double format andrew@0: ** All of these read/write function return number of frames read/written. andrew@0: */ andrew@0: andrew@0: sf_count_t sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ; andrew@0: sf_count_t sf_writef_short (SNDFILE *sndfile, const short *ptr, sf_count_t frames) ; andrew@0: andrew@0: sf_count_t sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ; andrew@0: sf_count_t sf_writef_int (SNDFILE *sndfile, const int *ptr, sf_count_t frames) ; andrew@0: andrew@0: sf_count_t sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ; andrew@0: sf_count_t sf_writef_float (SNDFILE *sndfile, const float *ptr, sf_count_t frames) ; andrew@0: andrew@0: sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ; andrew@0: sf_count_t sf_writef_double (SNDFILE *sndfile, const double *ptr, sf_count_t frames) ; andrew@0: andrew@0: /* Functions for reading and writing the data chunk in terms of items. andrew@0: ** Otherwise similar to above. andrew@0: ** All of these read/write function return number of items read/written. andrew@0: */ andrew@0: andrew@0: sf_count_t sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ; andrew@0: sf_count_t sf_write_short (SNDFILE *sndfile, const short *ptr, sf_count_t items) ; andrew@0: andrew@0: sf_count_t sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ; andrew@0: sf_count_t sf_write_int (SNDFILE *sndfile, const int *ptr, sf_count_t items) ; andrew@0: andrew@0: sf_count_t sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ; andrew@0: sf_count_t sf_write_float (SNDFILE *sndfile, const float *ptr, sf_count_t items) ; andrew@0: andrew@0: sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ; andrew@0: sf_count_t sf_write_double (SNDFILE *sndfile, const double *ptr, sf_count_t items) ; andrew@0: andrew@0: /* Close the SNDFILE and clean up all memory allocations associated with this andrew@0: ** file. andrew@0: ** Returns 0 on success, or an error number. andrew@0: */ andrew@0: andrew@0: int sf_close (SNDFILE *sndfile) ; andrew@0: andrew@0: /* If the file is opened SFM_WRITE or SFM_RDWR, call fsync() on the file andrew@0: ** to force the writing of data to disk. If the file is opened SFM_READ andrew@0: ** no action is taken. andrew@0: */ andrew@0: andrew@0: void sf_write_sync (SNDFILE *sndfile) ; andrew@0: andrew@0: #ifdef __cplusplus andrew@0: } /* extern "C" */ andrew@0: #endif /* __cplusplus */ andrew@0: andrew@0: #endif /* SNDFILE_H */