## IpatchSndFile IpatchSndFile — libsndfile file object |

## Stability Level

Stable, unless otherwise indicated

## Synopsis

    #define             IPATCH_TYPE_SND_FILE_FORMAT
    #define             IPATCH_TYPE_SND_FILE_SUB_FORMAT
    enum                IpatchSndFileEndian;
    #define             IPATCH_SND_FILE_DEFAULT_FORMAT
    #define             IPATCH_SND_FILE_DEFAULT_SUB_FORMAT
    #define             IPATCH_SND_FILE_DEFAULT_ENDIAN
                        IpatchSndFile;
    IpatchSndFile *     ipatch_snd_file_new                 (void);
    GType               ipatch_snd_file_format_get_type     (void);
    GType               ipatch_snd_file_sub_format_get_type (void);
    int *               ipatch_snd_file_format_get_sub_formats
                                                            (int format,
                                                             guint *size);
    int                 ipatch_snd_file_sample_format_to_sub_format
                                                            (int sample_format,
                                                             int file_format);

## Object Hierarchy

      GObject
       +----IpatchItem
             +----IpatchFile
                   +----IpatchSndFile

## Description

Object type for libsndfile audio file identification.

## Details

### IPATCH_TYPE_SND_FILE_FORMAT

    #define             IPATCH_TYPE_SND_FILE_FORMAT

### IPATCH_TYPE_SND_FILE_SUB_FORMAT

    #define             IPATCH_TYPE_SND_FILE_SUB_FORMAT

### enum IpatchSndFileEndian

    typedef enum
    {
      IPATCH_SND_FILE_ENDIAN_FILE,
      IPATCH_SND_FILE_ENDIAN_LITTLE,
      IPATCH_SND_FILE_ENDIAN_BIG,
      IPATCH_SND_FILE_ENDIAN_CPU
    } IpatchSndFileEndian;

Endian byte order libsndfile enum.

`IPATCH_SND_FILE_ENDIAN_FILE` | Use the default endian for the file format
`IPATCH_SND_FILE_ENDIAN_LITTLE` | Little endian byte order
`IPATCH_SND_FILE_ENDIAN_BIG` | Big endian byte order
`IPATCH_SND_FILE_ENDIAN_CPU` | Native CPU byte order

### IPATCH_SND_FILE_DEFAULT_FORMAT

    #define IPATCH_SND_FILE_DEFAULT_FORMAT     SF_FORMAT_WAV

Default file format enum for IPATCH_TYPE_SND_FILE_FORMAT.

### IPATCH_SND_FILE_DEFAULT_SUB_FORMAT

    #define IPATCH_SND_FILE_DEFAULT_SUB_FORMAT SF_FORMAT_PCM_16

Default file sub format enum for IPATCH_TYPE_SND_FILE_SUB_FORMAT.

### IPATCH_SND_FILE_DEFAULT_ENDIAN

    #define IPATCH_SND_FILE_DEFAULT_ENDIAN     IPATCH_SND_FILE_ENDIAN_FILE

Default endian byte order from enum IPATCH_TYPE_SND_FILE_ENDIAN.

### IpatchSndFile

    typedef struct _IpatchSndFile IpatchSndFile;

### ipatch_snd_file_new ()

    IpatchSndFile *     ipatch_snd_file_new                 (void);

Create a new libsndfile file object.

Returns : | New libsndfile file object (derived from IpatchFile) with a reference count of 1. Caller owns the reference and removing it will destroy the item.

### ipatch_snd_file_format_get_type ()

    GType               ipatch_snd_file_format_get_type     (void);

### ipatch_snd_file_sub_format_get_type ()

    GType               ipatch_snd_file_sub_format_get_type (void);

### ipatch_snd_file_format_get_sub_formats ()

    int *               ipatch_snd_file_format_get_sub_formats
                                                            (int format,
                                                             guint *size);

Get supported sub formats of a given libsndfile format.

`format` : | "IpatchSndFileFormat" GEnum to get sub formats of
`size` : | Location to store size of returned sub formats array
Returns : | Newly allocated list of sub format enum values or `NULL` if `format` is invalid

### ipatch_snd_file_sample_format_to_sub_format ()

    int                 ipatch_snd_file_sample_format_to_sub_format
                                                            (int sample_format,
                                                             int file_format);

Get the optimal libsndfile sub format for a libinstpatch sample format. The returned value may not be an exact equivalent, in the case of unsigned sample data with bit widths greater than 8, but will return the optimal format in those cases. If `file_format` is not -1 then the resulting sub format is guaranteed to be valid for it.

`sample_format` : | libinstpatch sample format (see sample)
`file_format` : | libsndfile format GEnum "IpatchSndFileFormat" value or -1 to not limit sub formats to a given file format.
Returns : | Optimal libsndfile sub format enum value or -1 on error (invalid `sample_format`).