IpatchSampleList

IpatchSampleList — Sample list data types and functions

Stability Level

Stable, unless otherwise indicated

Functions

Types and Values

Object Hierarchy

    GBoxed
    ├── IpatchSampleList
    ╰── IpatchSampleListItem

Description

Sample lists define audio data from concatenated segments of other audio sources. The lists are always mono (a single channel can be selected from multi-channel sources). Multi-channel audio can be created from combining multiple sample lists of the same length.

Functions

ipatch_sample_list_new ()

IpatchSampleList *
ipatch_sample_list_new (void);

Creates a new empty (zero item terminated) sample list.

Returns

Newly allocated empty sample list.


ipatch_sample_list_free ()

void
ipatch_sample_list_free (IpatchSampleList *list);

Free a sample list.

Parameters

list

Sample list to free

 

ipatch_sample_list_duplicate ()

IpatchSampleList *
ipatch_sample_list_duplicate (IpatchSampleList *list);

Duplicate a sample list.

Parameters

list

Sample list to duplicate

 

Returns

Newly allocated duplicate of list .


ipatch_sample_list_item_new ()

IpatchSampleListItem *
ipatch_sample_list_item_new (void);

Create a new node for a sample list.

Returns

Newly allocated list node which should be freed with ipatch_sample_list_item_free() when finished using it.


ipatch_sample_list_item_new_init ()

IpatchSampleListItem *
ipatch_sample_list_item_new_init (IpatchSample *sample,
                                  guint ofs,
                                  guint size,
                                  guint channel);

Create a new sample list item and initialize it with the provided parameters.

Parameters

sample

Sample containing audio for the segment

 

ofs

Offset in sample of audio segment

 

size

Size of audio segment in frames

 

channel

Channel to use from sample

 

Returns

Newly allocated sample list item which should be freed with ipatch_sample_list_item_free() when done with it.


ipatch_sample_list_item_free ()

void
ipatch_sample_list_item_free (IpatchSampleListItem *item);

Free a sample list item previously allocated by ipatch_sample_list_item_new().

Parameters

item

Sample list item to free

 

ipatch_sample_list_item_duplicate ()

IpatchSampleListItem *
ipatch_sample_list_item_duplicate (IpatchSampleListItem *item);

Duplicate a sample list item node.

Parameters

item

Sample list item to duplicate

 

Returns

New duplicate sample list item.


ipatch_sample_list_append ()

void
ipatch_sample_list_append (IpatchSampleList *list,
                           IpatchSample *sample,
                           guint ofs,
                           guint size,
                           guint channel);

Append an audio segment to a sample list.

Parameters

list

Sample list

 

sample

Sample containing audio segment to append

 

ofs

Offset in sample of beginning of audio segment (in frames)

 

size

Number of frames of audio segment to append

 

channel

Channel to use from sample

 

ipatch_sample_list_prepend ()

void
ipatch_sample_list_prepend (IpatchSampleList *list,
                            IpatchSample *sample,
                            guint ofs,
                            guint size,
                            guint channel);

Prepend an audio segment to a sample list.

Parameters

list

Sample list

 

sample

Sample containing audio segment to prepend

 

ofs

Offset in sample of beginning of audio segment (in frames)

 

size

Number of frames of audio segment to prepend

 

channel

Channel to use from sample

 

ipatch_sample_list_insert_index ()

void
ipatch_sample_list_insert_index (IpatchSampleList *list,
                                 guint index,
                                 IpatchSample *sample,
                                 guint ofs,
                                 guint size,
                                 guint channel);

Insert an audio segment into a sample list before a given list segment index .

Parameters

list

Sample list

 

index

List index to insert segment before (0 = prepend, -1 = append)

 

sample

Sample containing audio segment to insert

 

ofs

Offset in sample of beginning of audio segment (in frames)

 

size

Number of frames of audio segment to insert

 

channel

Channel to use from sample

 

ipatch_sample_list_insert ()

void
ipatch_sample_list_insert (IpatchSampleList *list,
                           guint pos,
                           IpatchSample *sample,
                           guint ofs,
                           guint size,
                           guint channel);

Insert an audio segment into a sample list at a given sample position in frames (pos ). Existing segments will be split as needed to accomodate the inserted segment.

Parameters

list

Sample list

 

pos

Position in audio data in frames to insert segment at

 

sample

Sample containing audio segment to insert

 

ofs

Offset in sample of beginning of audio segment (in frames)

 

size

Number of frames of audio segment to insert

 

channel

Channel to use from sample

 

ipatch_sample_list_cut ()

void
ipatch_sample_list_cut (IpatchSampleList *list,
                        guint pos,
                        guint size);

Cut a segment of audio from a sample list.

Parameters

list

Sample list

 

pos

Start position of sample data to cut, in frames

 

size

Size of area to cut, in frames

 

ipatch_sample_list_render ()

gboolean
ipatch_sample_list_render (IpatchSampleList *list,
                           gpointer buf,
                           guint pos,
                           guint frames,
                           int format,
                           GError **err);

Copies sample data from a sample list, converting as necessary and storing to buf .

[skip]

Parameters

list

Sample list

 

buf

Buffer to store the rendered audio to (should be frames * bytes_per_frame)

 

pos

Position in sample list audio to start from, in frames

 

frames

Size of sample data to render in frames

 

format

Sample format to render to (must be mono)

 

err

Location to store error to or NULL to ignore

 

Returns

TRUE on success, FALSE otherwise (in which case err may be set).


ipatch_sample_list_render_alloc ()

gpointer
ipatch_sample_list_render_alloc (IpatchSampleList *list,
                                 guint pos,
                                 guint size,
                                 int format,
                                 GError **err);

Copies sample data from a sample list, converting as necessary and returning an allocated buffer.

[rename-to ipatch_sample_list_render]

Parameters

list

Sample list

 

pos

Position in sample list audio to start from, in frames

 

size

Size of sample data to render in bytes (must be a multiple of frame size)

 

format

Sample format to render to (must be mono)

 

err

Location to store error to or NULL to ignore

 

Returns

Buffer containing rendered audio of the requested format or NULL on error (in which case err may be set).

[array length=size][element-type guint8][transfer full]

Since: 1.1.0

Types and Values

struct IpatchSampleList

struct IpatchSampleList {
    GList *items;			/* list of IpatchSampleListItem structs */
    guint total_size;		/* total size of audio data in frames */
};

A sample edit list. Allows for non-destructive sample editing by defining new audio samples from one or more audio sample segments.


struct IpatchSampleListItem

struct IpatchSampleListItem {
    IpatchSample *sample;	        /* Sample for this segment */
    guint ofs;                    /* Offset in sample of segment start */
    guint size;			/* Size in frames of audio segment */
    guint32 channel : 3;          /* Channel to use in sample */
    guint32 reserved : 29;
};

Defines an audio segment in a IpatchSampleList.