In version 0 of the library, the prototype looked like this:
int sf_command (SNDFILE *sndfile, const char *cmd, void *data, size_t datasize) ;
For version 1 of the library, the command will not longer be encoded as a string
but rather as an integer as follows:
int sf_command (SNDFILE *sndfile, int command, void *data, int datasize) ;
The valid values for command will have symbolic names beginning with SFC_
and will be listed in the header file <sndfile.h>.
Most of the commands (other than things like retrieving the library version) will work
on a per file basis, allowing float normalisation to be turned on for some files and
off for others.
When an integer values needs to be passed to the library via the sf_command interface,
the data parameter should be a NULL pointer and the value passed in the datasize
argument (see example below).
Here are some examples of its uses:
char buffer [1024] ;
int value ;
/* Retrieve a string containing the library version. No SNDFILE*
** pointer needed
*/
sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ;
/* Retrieve the log generated by the file header parser. */
sf_command (file, SFC_GET_LOG_INFO, buffer, sizeof (buffer)) ;
/* Turn on normalisation of data read/written as float. */
sf_command (file, SFC_SET_NORM_FLOAT, NULL, SF_TRUE) ;
/* Turn off normalisation of data read/written as float. */
sf_command (file, SFC_SET_NORM_FLOAT, NULL, SF_FALSE) ;
/* Turn on normalisation of data read/written as double. */
sf_command (file, SFC_SET_NORM_DOUBLE, NULL, SF_TRUE) ;
/* Retrieve current normalisation settings for doubles. */
sf_command (file, SFC_GET_NORM_DOUBLE, &value, sizeof (value)) ;
This function returns zero on success.