## IpatchSF2File

IpatchSF2File — SoundFont file object

## Stability Level

Stable, unless otherwise indicated

## Synopsis

                        IpatchSF2Phdr;
                        IpatchSF2Ihdr;
                        IpatchSF2Shdr;
                        IpatchSF2Bag;
                        IpatchSF2File;
    #define             IPATCH_SFONT_FOURCC_SFBK
    #define             IPATCH_SFONT_FOURCC_INFO
    #define             IPATCH_SFONT_FOURCC_SDTA
    #define             IPATCH_SFONT_FOURCC_PDTA
    #define             IPATCH_SFONT_FOURCC_SMPL
    #define             IPATCH_SFONT_FOURCC_SM24
    #define             IPATCH_SFONT_FOURCC_PHDR
    #define             IPATCH_SFONT_FOURCC_PBAG
    #define             IPATCH_SFONT_FOURCC_PMOD
    #define             IPATCH_SFONT_FOURCC_PGEN
    #define             IPATCH_SFONT_FOURCC_INST
    #define             IPATCH_SFONT_FOURCC_IBAG
    #define             IPATCH_SFONT_FOURCC_IMOD
    #define             IPATCH_SFONT_FOURCC_IGEN
    #define             IPATCH_SFONT_FOURCC_SHDR
    #define             IPATCH_SFONT_FOURCC_IFIL
    #define             IPATCH_SFONT_FOURCC_ISNG
    #define             IPATCH_SFONT_FOURCC_INAM
    #define             IPATCH_SFONT_FOURCC_IROM
    #define             IPATCH_SFONT_FOURCC_IVER
    #define             IPATCH_SFONT_FOURCC_ICRD
    #define             IPATCH_SFONT_FOURCC_IENG
    #define             IPATCH_SFONT_FOURCC_IPRD
    #define             IPATCH_SFONT_FOURCC_ICOP
    #define             IPATCH_SFONT_FOURCC_ICMT
    #define             IPATCH_SFONT_FOURCC_ISFT
    #define             IPATCH_SFONT_VERSION_SIZE
    #define             IPATCH_SFONT_PHDR_SIZE
    #define             IPATCH_SFONT_INST_SIZE
    #define             IPATCH_SFONT_SHDR_SIZE
    #define             IPATCH_SFONT_BAG_SIZE
    #define             IPATCH_SFONT_MOD_SIZE
    #define             IPATCH_SFONT_GEN_SIZE
    #define             IPATCH_SFONT_NAME_SIZE
    enum                IpatchSF2FileSampleType;
    IpatchSF2File *     ipatch_sf2_file_new                 (void);
    void                ipatch_sf2_file_set_sample_pos      (IpatchSF2File *file,
                                                             guint sample_pos);
    guint               ipatch_sf2_file_get_sample_pos      (IpatchSF2File *file);
    void                ipatch_sf2_file_set_sample_size     (IpatchSF2File *file,
                                                             guint sample_size);
    guint               ipatch_sf2_file_get_sample_size     (IpatchSF2File *file);
    void                ipatch_sf2_file_set_sample24_pos    (IpatchSF2File *file,
                                                             guint sample24_pos);
    guint               ipatch_sf2_file_get_sample24_pos    (IpatchSF2File *file);

## Object Hierarchy

      GObject
       +----IpatchItem
             +----IpatchFile
                   +----IpatchSF2File

## Properties

      "sample-pos"               guint                 : Read / Write
      "sample-size"              guint                 : Read / Write
      "sample24-pos"             guint                 : Read / Write

## Description

A IpatchFile object type specifically for SoundFont files.

## Details

### IpatchSF2Phdr

    typedef struct {
      char name[20];		/* preset name */
      guint16 program;		/* MIDI program number */
      guint16 bank;			/* MIDI bank number */
      guint16 bag_index;	      /* index into preset bag (#IPFileBag) */
      guint32 library;		/* Not used (preserved) */
      guint32 genre;		/* Not used (preserved) */
      guint32 morphology;		/* Not used (preserved) */
    } IpatchSF2Phdr;

### IpatchSF2Ihdr

    typedef struct {
      char name[20];		/* name of instrument */
      guint16 bag_index;		/* instrument bag index (#IPFileBag) */
    } IpatchSF2Ihdr;

### IpatchSF2Shdr

    typedef struct {
      char name[20];		/* sample name */
      guint32 start;		/* offset to start of sample */
      guint32 end;			/* offset to end of sample */
      guint32 loop_start;		/* offset to start of loop */
      guint32 loop_end;		/* offset to end of loop */
      guint32 rate;			/* sample rate recorded at */
      guint8 root_note;		/* root midi note number */
      gint8 fine_tune;		/* pitch correction in cents */
      guint16 link_index;	  /* linked sample index for stereo samples */
      guint16 type;	       /* type of sample (see IpatchSF2SampleFlags) */
    } IpatchSF2Shdr;

### IpatchSF2Bag

    typedef struct {
      guint16 mod_index;		/* index into modulator list */
      guint16 gen_index;		/* index into generator list */
    } IpatchSF2Bag;

### IpatchSF2File

    typedef struct _IpatchSF2File IpatchSF2File;

### IPATCH_SFONT_FOURCC_SFBK

    #define IPATCH_SFONT_FOURCC_SFBK  IPATCH_FOURCC ('s','f','b','k')

### IPATCH_SFONT_FOURCC_INFO

    #define IPATCH_SFONT_FOURCC_INFO  IPATCH_FOURCC ('I','N','F','O')

### IPATCH_SFONT_FOURCC_SDTA

    #define IPATCH_SFONT_FOURCC_SDTA  IPATCH_FOURCC ('s','d','t','a')

### IPATCH_SFONT_FOURCC_PDTA

    #define IPATCH_SFONT_FOURCC_PDTA  IPATCH_FOURCC ('p','d','t','a')

### IPATCH_SFONT_FOURCC_SMPL

    #define IPATCH_SFONT_FOURCC_SMPL  IPATCH_FOURCC ('s','m','p','l')

### IPATCH_SFONT_FOURCC_SM24

    #define IPATCH_SFONT_FOURCC_SM24  IPATCH_FOURCC ('s','m','2','4')

### IPATCH_SFONT_FOURCC_PHDR

    #define IPATCH_SFONT_FOURCC_PHDR  IPATCH_FOURCC ('p','h','d','r')

### IPATCH_SFONT_FOURCC_PBAG

    #define IPATCH_SFONT_FOURCC_PBAG  IPATCH_FOURCC ('p','b','a','g')

### IPATCH_SFONT_FOURCC_PMOD

    #define IPATCH_SFONT_FOURCC_PMOD  IPATCH_FOURCC ('p','m','o','d')

### IPATCH_SFONT_FOURCC_PGEN

    #define IPATCH_SFONT_FOURCC_PGEN  IPATCH_FOURCC ('p','g','e','n')

### IPATCH_SFONT_FOURCC_INST

    #define IPATCH_SFONT_FOURCC_INST  IPATCH_FOURCC ('i','n','s','t')

### IPATCH_SFONT_FOURCC_IBAG

    #define IPATCH_SFONT_FOURCC_IBAG  IPATCH_FOURCC ('i','b','a','g')

### IPATCH_SFONT_FOURCC_IMOD

    #define IPATCH_SFONT_FOURCC_IMOD  IPATCH_FOURCC ('i','m','o','d')

### IPATCH_SFONT_FOURCC_IGEN

    #define IPATCH_SFONT_FOURCC_IGEN  IPATCH_FOURCC ('i','g','e','n')

### IPATCH_SFONT_FOURCC_SHDR

    #define IPATCH_SFONT_FOURCC_SHDR  IPATCH_FOURCC ('s','h','d','r')

### IPATCH_SFONT_FOURCC_IFIL

    #define IPATCH_SFONT_FOURCC_IFIL  IPATCH_FOURCC ('i','f','i','l')

### IPATCH_SFONT_FOURCC_ISNG

    #define IPATCH_SFONT_FOURCC_ISNG  IPATCH_FOURCC ('i','s','n','g')

### IPATCH_SFONT_FOURCC_INAM

    #define IPATCH_SFONT_FOURCC_INAM  IPATCH_FOURCC ('I','N','A','M')

### IPATCH_SFONT_FOURCC_IROM

    #define IPATCH_SFONT_FOURCC_IROM  IPATCH_FOURCC ('i','r','o','m')

### IPATCH_SFONT_FOURCC_IVER

    #define IPATCH_SFONT_FOURCC_IVER  IPATCH_FOURCC ('i','v','e','r')

### IPATCH_SFONT_FOURCC_ICRD

    #define IPATCH_SFONT_FOURCC_ICRD  IPATCH_FOURCC ('I','C','R','D')

### IPATCH_SFONT_FOURCC_IENG

    #define IPATCH_SFONT_FOURCC_IENG  IPATCH_FOURCC ('I','E','N','G')

### IPATCH_SFONT_FOURCC_IPRD

    #define IPATCH_SFONT_FOURCC_IPRD  IPATCH_FOURCC ('I','P','R','D')

### IPATCH_SFONT_FOURCC_ICOP

    #define IPATCH_SFONT_FOURCC_ICOP  IPATCH_FOURCC ('I','C','O','P')

### IPATCH_SFONT_FOURCC_ICMT

    #define IPATCH_SFONT_FOURCC_ICMT  IPATCH_FOURCC ('I','C','M','T')

### IPATCH_SFONT_FOURCC_ISFT

    #define IPATCH_SFONT_FOURCC_ISFT  IPATCH_FOURCC ('I','S','F','T')

### IPATCH_SFONT_VERSION_SIZE

    #define IPATCH_SFONT_VERSION_SIZE 4 /* file version info size */

### IPATCH_SFONT_PHDR_SIZE

    #define IPATCH_SFONT_PHDR_SIZE 38  /* file preset header size */

### IPATCH_SFONT_INST_SIZE

    #define IPATCH_SFONT_INST_SIZE 22  /* file instrument header size */

### IPATCH_SFONT_SHDR_SIZE

    #define IPATCH_SFONT_SHDR_SIZE 46  /* file sample header size */

### IPATCH_SFONT_BAG_SIZE

    #define IPATCH_SFONT_BAG_SIZE  4   /* file bag (zone) size */

### IPATCH_SFONT_MOD_SIZE

    #define IPATCH_SFONT_MOD_SIZE  10  /* file modulator size */

### IPATCH_SFONT_GEN_SIZE

    #define IPATCH_SFONT_GEN_SIZE  4   /* file generator size */

### IPATCH_SFONT_NAME_SIZE

    #define IPATCH_SFONT_NAME_SIZE 20  /* name string size (Preset/Inst/Sample) */

### enum IpatchSF2FileSampleType

    typedef enum
    {
      IPATCH_SF2_FILE_SAMPLE_TYPE_MONO      = 1 << 0,
      IPATCH_SF2_FILE_SAMPLE_TYPE_RIGHT     = 1 << 1,
      IPATCH_SF2_FILE_SAMPLE_TYPE_LEFT      = 1 << 2,
      IPATCH_SF2_FILE_SAMPLE_TYPE_LINKED    = 1 << 3,
      IPATCH_SF2_FILE_SAMPLE_TYPE_ROM       = 1 << 15
    } IpatchSF2FileSampleType;

SoundFont file sample channel mode

`IPATCH_SF2_FILE_SAMPLE_TYPE_MONO` | Mono channel
`IPATCH_SF2_FILE_SAMPLE_TYPE_RIGHT` | Right channel of a stereo pair
`IPATCH_SF2_FILE_SAMPLE_TYPE_LEFT` | Left channel of a stereo pair
`IPATCH_SF2_FILE_SAMPLE_TYPE_LINKED` | Linked list of samples (not yet used)
`IPATCH_SF2_FILE_SAMPLE_TYPE_ROM` | A ROM sample

### ipatch_sf2_file_new ()

    IpatchSF2File *     ipatch_sf2_file_new                 (void);

Create a new SoundFont file object.

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

### ipatch_sf2_file_set_sample_pos ()

    void                ipatch_sf2_file_set_sample_pos      (IpatchSF2File *file,
                                                             guint sample_pos);

Sets the position of the sample data chunk in a SoundFont file object.

`file` : | SoundFont file object to set position of sample chunk
`sample_pos` : | Position in the SoundFont file of the first sample of the sample data chunk, in bytes

### ipatch_sf2_file_get_sample_pos ()

    guint               ipatch_sf2_file_get_sample_pos      (IpatchSF2File *file);

Gets the position of the sample data chunk in a SoundFont file object.

`file` : | SoundFont file object to get position of sample chunk from
Returns : | Position in the SoundFont file of the first sample of the sample data chunk, in bytes

### ipatch_sf2_file_set_sample_size ()

    void                ipatch_sf2_file_set_sample_size     (IpatchSF2File *file,
                                                             guint sample_size);

Sets the size of the sample data chunk in a SoundFont file object.

`file` : | SoundFont file object to set the size of the sample chunk
`sample_size` : | Size of the sample data chunk, in samples

### ipatch_sf2_file_get_sample_size ()

    guint               ipatch_sf2_file_get_sample_size     (IpatchSF2File *file);

Gets the size of the sample data chunk in a SoundFont file object.

`file` : | SoundFont file object to get the size of the sample chunk from
Returns : | Size of the sample data chunk, in samples

### ipatch_sf2_file_set_sample24_pos ()

    void                ipatch_sf2_file_set_sample24_pos    (IpatchSF2File *file,
                                                             guint sample24_pos);

Sets the position of the sample 24 data chunk in a SoundFont file object. This optional chunk contains the lower significant bytes of 24 bit samples.

`file` : | SoundFont file object to set position of sample24 chunk
`sample24_pos` : | Position in the SoundFont file of the first sample of the sample 24 data chunk, in bytes

### ipatch_sf2_file_get_sample24_pos ()

    guint               ipatch_sf2_file_get_sample24_pos    (IpatchSF2File *file);

Gets the position of the sample24 data chunk in a SoundFont file object.

`file` : | SoundFont file object to get position of sample24 chunk from
Returns : | Position in the SoundFont file of the first byte of the sample24 data chunk, in bytes

## Property Details

### The `"sample-pos"` property

      "sample-pos"               guint                 : Read / Write

Position in file of sample data chunk.

Default value: 0

### The `"sample-size"` property

      "sample-size"              guint                 : Read / Write

Size of sample data chunk, in samples.

Default value: 0

### The `"sample24-pos"` property

      "sample24-pos"             guint                 : Read / Write

Position in file of 24 bit sample chunk.

Default value: 0