| libInstPatch Reference Manual |
|---|
IpatchSampleTransformIpatchSampleTransform — Sample format conversion object |
IpatchSampleTransform;
IpatchSampleTransformClass;
void (*IpatchSampleTransformFunc) (IpatchSampleTransform *transform);
IpatchSampleTransform* ipatch_sample_transform_new
(int src_format,
int dest_format);
void ipatch_sample_transform_set_formats
(IpatchSampleTransform *transform,
int src_format,
int dest_format);
void ipatch_sample_transform_alloc (IpatchSampleTransform *transform,
guint frames);
int ipatch_sample_transform_alloc_size
(IpatchSampleTransform *transform,
guint size);
void ipatch_sample_transform_free_buffers
(IpatchSampleTransform *transform);
void ipatch_sample_transform_set_buffers
(IpatchSampleTransform *transform,
gpointer buf1,
gpointer buf2,
guint max_frames);
void ipatch_sample_transform_get_buffers
(IpatchSampleTransform *transform,
gpointer *buf1,
gpointer *buf2);
void ipatch_sample_transform_get_frame_sizes
(IpatchSampleTransform *transform,
guint *buf1_size,
guint *buf2_size);
gpointer ipatch_sample_transform_convert (IpatchSampleTransform *transform,
guint frames);
An object type for converting between audio formats. Audio formats are specified as libInstPatch audio format integers (see Sample format for more details).
typedef struct _IpatchSampleTransform IpatchSampleTransform;
Private structure, use functions to access it.
void (*IpatchSampleTransformFunc) (IpatchSampleTransform *transform);
Audio conversion handler prototype. Handler will modify
samples of transform if number of samples
changes (a change in the number of channels occurs).
transform : |
Sample transform object |
IpatchSampleTransform* ipatch_sample_transform_new (int src_format, int dest_format);
Create a new sample transform object. If src_format and dest_format are
not 0 then the transform is initialized for the given source and destination
formats, otherwise they are expected to be set later with
ipatch_sample_transform_set_formats().
src_format : |
Source sample format or 0 to set later |
dest_format : |
Destination sample format or 0 to set later |
| Returns : | New sample transform object with a refcount of 1 which the caller owns. |
void ipatch_sample_transform_set_formats
(IpatchSampleTransform *transform,
int src_format,
int dest_format);
Initialize a sample transform object for converting from
src_format to dest_format.
transform : |
Transform object |
src_format : |
Source audio format to convert from |
dest_format : |
Destination audio format to convert to |
void ipatch_sample_transform_alloc (IpatchSampleTransform *transform, guint frames);
Allocate buffers for transforming between two audio formats, for
which transform has previously been initialized for with
ipatch_sample_transform_new() or ipatch_sample_transform_set_formats().
transform : |
Sample transform object |
frames : |
Number of frames to allocate for (max frames processed in batch) |
int ipatch_sample_transform_alloc_size
(IpatchSampleTransform *transform,
guint size);
Like ipatch_sample_transform_alloc() but allocates buffers based on a
maximum size and returns the maximum number of sample frames which can be
converted at a time using this size.
transform : |
Sample transform object |
size : |
Maximum total size in bytes of allocation for both transform buffers. |
| Returns : | The maximum number of frames that can be converted at a time for
the given size of transform buffers.
|
void ipatch_sample_transform_free_buffers
(IpatchSampleTransform *transform);
Free sample transform buffers.
transform : |
Sample transform object |
void ipatch_sample_transform_set_buffers
(IpatchSampleTransform *transform,
gpointer buf1,
gpointer buf2,
guint max_frames);
Assign user allocated buffers to be used for transforming sample
data. Either this function, ipatch_sample_transform_set_buffers_size(),
ipatch_sample_transform_alloc() or
ipatch_sample_transform_alloc_size() must be called before
conversion can commence. buf1 and buf2 should be large enough to
convert max_frames at a time - see
ipatch_sample_transform_get_frame_sizes().
transform : |
Sample transform object |
buf1 : |
First buffer (source sample data) |
buf2 : |
Second buffer |
max_frames : |
Maximum frames that can be converted at a time |
void ipatch_sample_transform_get_buffers
(IpatchSampleTransform *transform,
gpointer *buf1,
gpointer *buf2);
Get the sample data buffers in a sample transform object.
transform : |
Sample transform object |
buf1 : |
Output - first buffer or NULL to ignore
|
buf2 : |
Output - second buffer or NULL to ignore
|
void ipatch_sample_transform_get_frame_sizes
(IpatchSampleTransform *transform,
guint *buf1_size,
guint *buf2_size);
Get max frame sizes for transform buffers. When transforming audio the first buffer must be at least frames * buf1_size bytes in size and the second buffer must be at least frames * buf2_size, where frames is the max number of frames to convert in batch.
transform : |
Initialized transform object |
buf1_size : |
Out: Maximum frame size for buffer 1 or NULL to ignore
|
buf2_size : |
Out: Maximum frame size for buffer 2 or NULL to ignore
|
gpointer ipatch_sample_transform_convert (IpatchSampleTransform *transform, guint frames);
Convert the format of a buffer of audio. The transform object must have
had its sample formats set and buffers assigned or allocated.
transform : |
An initialized sample transform object |
frames : |
Number of frames to convert |
| Returns : | Pointer to converted audio data (buffer is internal to transform
object).
|
| << IpatchSampleFile | Sample format >> |