sndfile2k  1.2.0
Functions
Read/Write items

API for reading and writing data in particular format as items. More...

Functions

SNDFILE2K_EXPORT sf_count_t sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t items)
 Reads short (16-bit) samples from file. More...
 
SNDFILE2K_EXPORT sf_count_t sf_write_short (SNDFILE *sndfile, const short *ptr, sf_count_t items)
 Writes short (16-bit) samples to file. More...
 
SNDFILE2K_EXPORT sf_count_t sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t items)
 Reads integer (32-bit) samples from file. More...
 
SNDFILE2K_EXPORT sf_count_t sf_write_int (SNDFILE *sndfile, const int *ptr, sf_count_t items)
 Writes integer (32-bit) samples to file. More...
 
SNDFILE2K_EXPORT sf_count_t sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t items)
 Reads float (32-bit) samples from file. More...
 
SNDFILE2K_EXPORT sf_count_t sf_write_float (SNDFILE *sndfile, const float *ptr, sf_count_t items)
 Writes float (32-bit) samples to file. More...
 
SNDFILE2K_EXPORT sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items)
 Reads double (64-bit) samples from file. More...
 
SNDFILE2K_EXPORT sf_count_t sf_write_double (SNDFILE *sndfile, const double *ptr, sf_count_t items)
 Writes double (64-bit) samples to file. More...
 

Detailed Description

API for reading and writing data in particular format as items.

This set of high-level functions read/write data in terms of sample and/or performing type conversion and byte-swapping if necessary.

One item is one sample for each channel. For example, to read 10 samples as integers (32-bit) from stereo (2 channles) sound file you need to allocate buffer of 10 integers size and call sf_read_int() function with items parameter set to 10.

When file format data type differs from function type, e.g you read WAV file with float data, data type conversion if automatically performed.

When endianness of file data differs from host system endianness, byte-swapping is performed and no additional manipulations are required.

Function Documentation

◆ sf_read_double()

SNDFILE2K_EXPORT sf_count_t sf_read_double ( SNDFILE sndfile,
double *  ptr,
sf_count_t  items 
)

Reads double (64-bit) samples from file.

Parameters
[in]sndfilePointer to a sound file state
[out]ptrPointer to an allocated block of memory.
[in]itemsCount of samples to read
Returns
Number of samples actually read.

◆ sf_read_float()

SNDFILE2K_EXPORT sf_count_t sf_read_float ( SNDFILE sndfile,
float *  ptr,
sf_count_t  items 
)

Reads float (32-bit) samples from file.

Parameters
[in]sndfilePointer to a sound file state
[out]ptrPointer to an allocated block of memory.
[in]itemsCount of samples to read
Returns
Number of samples actually read.

◆ sf_read_int()

SNDFILE2K_EXPORT sf_count_t sf_read_int ( SNDFILE sndfile,
int *  ptr,
sf_count_t  items 
)

Reads integer (32-bit) samples from file.

Parameters
[in]sndfilePointer to a sound file state
[out]ptrPointer to an allocated block of memory.
[in]itemsCount of samples to read
Returns
Number of samples actually read.

◆ sf_read_short()

SNDFILE2K_EXPORT sf_count_t sf_read_short ( SNDFILE sndfile,
short *  ptr,
sf_count_t  items 
)

Reads short (16-bit) samples from file.

Parameters
[in]sndfilePointer to a sound file state
[out]ptrPointer to an allocated block of memory.
[in]itemsCount of samples to read
Returns
Number of samples actually read.

◆ sf_write_double()

SNDFILE2K_EXPORT sf_count_t sf_write_double ( SNDFILE sndfile,
const double *  ptr,
sf_count_t  items 
)

Writes double (64-bit) samples to file.

Parameters
[in]sndfilePointer to a sound file state
[in]ptrPointer to an allocated block of memory.
[in]itemsCount of samples to write
Returns
Number of samples actually written.

◆ sf_write_float()

SNDFILE2K_EXPORT sf_count_t sf_write_float ( SNDFILE sndfile,
const float *  ptr,
sf_count_t  items 
)

Writes float (32-bit) samples to file.

Parameters
[in]sndfilePointer to a sound file state
[in]ptrPointer to an allocated block of memory.
[in]itemsCount of samples to write
Returns
Number of samples actually written.

◆ sf_write_int()

SNDFILE2K_EXPORT sf_count_t sf_write_int ( SNDFILE sndfile,
const int *  ptr,
sf_count_t  items 
)

Writes integer (32-bit) samples to file.

Parameters
[in]sndfilePointer to a sound file state
[in]ptrPointer to an allocated block of memory.
[in]itemsCount of samples to write
Returns
Number of samples actually written.

◆ sf_write_short()

SNDFILE2K_EXPORT sf_count_t sf_write_short ( SNDFILE sndfile,
const short *  ptr,
sf_count_t  items 
)

Writes short (16-bit) samples to file.

Parameters
[in]sndfilePointer to a sound file state
[in]ptrPointer to an allocated block of memory.
[in]itemsCount of samples to write
Returns
Number of samples actually written.