sndfile2k  1.2.0
Functions
Read/Write frames

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

Functions

SNDFILE2K_EXPORT sf_count_t sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames)
 Reads short (16-bit) frames from file. More...
 
SNDFILE2K_EXPORT sf_count_t sf_writef_short (SNDFILE *sndfile, const short *ptr, sf_count_t frames)
 Writes short (16-bit) frames to file. More...
 
SNDFILE2K_EXPORT sf_count_t sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames)
 Reads integer (32-bit) frames from file. More...
 
SNDFILE2K_EXPORT sf_count_t sf_writef_int (SNDFILE *sndfile, const int *ptr, sf_count_t frames)
 Writes integer (32-bit) frames to file. More...
 
SNDFILE2K_EXPORT sf_count_t sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames)
 Reads float (32-bit) frames from file. More...
 
SNDFILE2K_EXPORT sf_count_t sf_writef_float (SNDFILE *sndfile, const float *ptr, sf_count_t frames)
 Writes float (32-bit) frames to file. More...
 
SNDFILE2K_EXPORT sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames)
 Reads double (64-bit) frames from file. More...
 
SNDFILE2K_EXPORT sf_count_t sf_writef_double (SNDFILE *sndfile, const double *ptr, sf_count_t frames)
 Writes double (64-bit) frames to file. More...
 

Detailed Description

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

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

One frame is one item (sample) for each channel. For example, to read 10 frames as integers (32-bit) from stereo (2 channles) sound file you need to allocate buffer of 20 integers size and call sf_readf_int() function with frames 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_readf_double()

SNDFILE2K_EXPORT sf_count_t sf_readf_double ( SNDFILE sndfile,
double *  ptr,
sf_count_t  frames 
)

Reads double (64-bit) frames from file.

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

◆ sf_readf_float()

SNDFILE2K_EXPORT sf_count_t sf_readf_float ( SNDFILE sndfile,
float *  ptr,
sf_count_t  frames 
)

Reads float (32-bit) frames from file.

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

◆ sf_readf_int()

SNDFILE2K_EXPORT sf_count_t sf_readf_int ( SNDFILE sndfile,
int *  ptr,
sf_count_t  frames 
)

Reads integer (32-bit) frames from file.

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

◆ sf_readf_short()

SNDFILE2K_EXPORT sf_count_t sf_readf_short ( SNDFILE sndfile,
short *  ptr,
sf_count_t  frames 
)

Reads short (16-bit) frames from file.

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

◆ sf_writef_double()

SNDFILE2K_EXPORT sf_count_t sf_writef_double ( SNDFILE sndfile,
const double *  ptr,
sf_count_t  frames 
)

Writes double (64-bit) frames to file.

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

◆ sf_writef_float()

SNDFILE2K_EXPORT sf_count_t sf_writef_float ( SNDFILE sndfile,
const float *  ptr,
sf_count_t  frames 
)

Writes float (32-bit) frames to file.

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

◆ sf_writef_int()

SNDFILE2K_EXPORT sf_count_t sf_writef_int ( SNDFILE sndfile,
const int *  ptr,
sf_count_t  frames 
)

Writes integer (32-bit) frames to file.

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

◆ sf_writef_short()

SNDFILE2K_EXPORT sf_count_t sf_writef_short ( SNDFILE sndfile,
const short *  ptr,
sf_count_t  frames 
)

Writes short (16-bit) frames to file.

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