Top | ![]() |
![]() |
![]() |
![]() |
int | fine-tune | Read |
guint | loop-end | Read |
guint | loop-start | Read |
IpatchSampleLoopType | loop-type | Read |
int | root-note | Read |
IpatchSampleData * | sample-data | Read |
int | sample-format | Read |
int | sample-rate | Read |
guint | sample-size | Read |
struct | IpatchSampleHandle |
enum | IpatchSampleLoopType |
#define | IPATCH_SAMPLE_FORMAT_DEFAULT |
#define | IPATCH_SAMPLE_RATE_MIN |
#define | IPATCH_SAMPLE_RATE_MAX |
#define | IPATCH_SAMPLE_RATE_DEFAULT |
#define | IPATCH_SAMPLE_ROOT_NOTE_DEFAULT |
#define | IPATCH_SAMPLE_LOOP_TYPE_TERM |
gboolean (*IpatchSampleHandleOpenFunc) (IpatchSampleHandle *handle
,GError **err
);
IpatchSample interface method function type to open a sample for reading
or writing. This method is optional for an IpatchSample interface and if
not specified then it is assumed that the open was successful and nothing
additional need be done. All fields of handle
structure are already
initialized, except <structfield>data1</structfield>,
<structfield>data2</structfield> and <structfield>data3</structfield>
which are available for the interface implementation.
void
(*IpatchSampleHandleCloseFunc) (IpatchSampleHandle *handle
);
IpatchSample interface method to free any resources allocated in
IpatchSampleOpenFunc to handle
. This method is optional for an
IpatchSample interface and need not be specified if nothing needs to be done
to release any resources allocated by IpatchSampleHandleOpenFunc.
gboolean (*IpatchSampleHandleReadFunc) (IpatchSampleHandle *handle
,guint offset
,guint frames
,gpointer buf
,GError **err
);
IpatchSample interface method function type to read data from a
sample handle. Can be NULL
in IpatchSampleIface if sample data is not
readable. Sample data should be stored in its native format.
handle |
Handle to read from (as returned from IpatchSampleOpenFunc) |
|
offset |
Offset in sample to start read from (in frames), use IPATCH_SAMPLE_CUROFS to use current offset (starts at 0 if not specified) |
|
frames |
Size of sample data to read (in frames) |
|
buf |
Buffer to store sample data in |
|
err |
Location to store error information |
gboolean (*IpatchSampleHandleWriteFunc) (IpatchSampleHandle *handle
,guint offset
,guint frames
,gconstpointer buf
,GError **err
);
IpatchSample interface method function type to write data to a
sample handle. Can be NULL
in IpatchSampleIface if sample data is not
writable. Sample data will be supplied in its native format.
handle |
Handle to write to (as returned from IpatchSampleOpenFunc) |
|
offset |
Offset in sample to start write to (in frames), use IPATCH_SAMPLE_CUROFS to use current offset (starts at 0 if not specified) |
|
frames |
Size of sample data to write (in frames) |
|
buf |
Buffer to store sample data in |
|
err |
Location to store error information |
#define IPATCH_SAMPLE_HANDLE_FORMAT(handle) ((handle)->format)
Macro to access transform sample format of a sample handle.
int *
ipatch_sample_get_loop_types (IpatchSample *sample
);
Get an array of supported loop type enums for a sample object.
[skip]
-1 terminated array of IpatchSampleLoopType values. If no loop
types are supported, then NULL
is returned. Array is internal and should
not be modified or freed.
int *
ipatch_sample_type_get_loop_types (GType type
);
Like ipatch_sample_get_loop_types()
but retrieves the supported loop types
from an object type rather than an instance of an object.
[skip]
-1 terminated array of IpatchSampleLoopType values. If no loop
types are supported, then NULL
is returned. Array is internal and should
not be modified or freed.
int * ipatch_sample_get_loop_types_len (IpatchSample *sample
,int *len
);
Get an array of supported loop type enums for a sample object.
[rename-to ipatch_sample_get_loop_types]
sample |
Object with IpatchSample interface |
|
len |
Location to store number of indeces in returned array
(not including -1 terminator), can be |
[out][optional] |
-1 terminated array of IpatchSampleLoopType values.
If no loop types are supported, then NULL
is returned. Array is internal and should
not be modified or freed.
[array length=len]
Since: 1.1.0
int * ipatch_sample_type_get_loop_types_len (GType type
,int *len
);
Like ipatch_sample_get_loop_types_len()
but retrieves the supported loop types
from an object type rather than an instance of an object.
type |
A GType that has a IpatchItem interface |
|
len |
Location to store number of indeces in returned array
(not including -1 terminator), can be |
[out][optional] |
-1 terminated array of IpatchSampleLoopType values.
If no loop types are supported, then NULL
is returned. Array is internal and should
not be modified or freed.
[array length=len]
Since: 1.1.0
void ipatch_sample_set_format (IpatchSample *sample
,int format
);
Set sample format of a new sample. Should only be assigned once. Same as assigning to a sample's "sample-format" property.
sample |
Sample to set format of |
|
format |
Sample format to assign to sample (see IpatchSampleWidth, etc) |
int
ipatch_sample_get_format (IpatchSample *sample
);
Get the sample format of a sample. Same as getting a sample's "sample-format" property.
void ipatch_sample_set_size (IpatchSample *sample
,guint size
);
Set the size of a sample. Should be done once, and only once when created.
guint ipatch_sample_get_size (IpatchSample *sample
,guint *bytes
);
Get the size of a sample. Same as getting a sample's "sample-size" property.
int
ipatch_sample_get_frame_size (IpatchSample *sample
);
A convenience function to get size of a single sample frame for a given
sample
. This is useful for determining buffer allocation sizes when
reading or writing data.
IpatchSampleData *
ipatch_sample_get_sample_data (IpatchSample *sample
);
Get sample data object from a sample. Not every sample object supports this
property, in which case NULL
is returned.
gboolean ipatch_sample_set_sample_data (IpatchSample *sample
,IpatchSampleData *sampledata
);
Set sample data object of a sample. Not every sample object supports writing
to this property, in which case FALSE
will be returned.
gboolean ipatch_sample_read (IpatchSample *sample
,guint offset
,guint frames
,gpointer buf
,GError **err
);
Read sample data from a sample. This is a convenience function which
opens/reads/closes a IpatchSampleHandle and is therefore not as efficient
when making multiple accesses. Sample data transform
is also not handled (see ipatch_sample_read_transform()
).
[skip]
sample |
Sample to read from |
|
offset |
Offset in frames to read from |
|
frames |
Number of frames to read |
|
buf |
Buffer to store sample data in (should be at least |
|
err |
Location to store error info or |
gpointer ipatch_sample_read_size (IpatchSample *sample
,guint offset
,guint size
,GError **err
);
Read sample data from a sample. Like ipatch_sample_read()
but
is designed to be GObject introspection friendly and returned buffer is allocated.
[rename-to ipatch_sample_read]
sample |
Sample to read from |
|
offset |
Offset in frames to read from |
|
size |
Size of data to read in bytes |
|
err |
Location to store error info or |
Newly
allocated buffer with read data, NULL
on error (in which case
err
may be set). Free the buffer with g_free()
when finished with it.
[array length=size][element-type guint8][transfer full]
Since: 1.1.0
gboolean ipatch_sample_write (IpatchSample *sample
,guint offset
,guint frames
,gconstpointer buf
,GError **err
);
Write sample data to a sample. This is a convenience function which
opens/writes/closes a IpatchSampleHandle and is therefore not as efficient
when making multiple accesses. Sample data transform
is also not handled (see ipatch_sample_write_transform()
).
[skip]
sample |
Sample to write to |
|
offset |
Offset in frames to write to |
|
frames |
Number of frames to write |
|
buf |
Buffer of sample data to write (should be at least |
|
err |
Location to store error info or |
gboolean ipatch_sample_write_size (IpatchSample *sample
,guint offset
,gconstpointer buf
,guint size
,GError **err
);
Write sample data to a sample. Like ipatch_sample_write()
but is designed
to be GObject Inspection friendly.
[rename-to ipatch_sample_write]
sample |
Sample to write to |
|
offset |
Offset in frames to write to |
|
buf |
Buffer of sample data to write. |
[array length=size][element-type guint8][transfer none] |
size |
Size of buffer (must be multiple of audio frame size) |
|
err |
Location to store error info or |
Since: 1.1.0
gboolean ipatch_sample_read_transform (IpatchSample *sample
,guint offset
,guint frames
,gpointer buf
,int format
,guint32 channel_map
,GError **err
);
Like ipatch_sample_read()
but allows for sample transformation.
[skip]
sample |
Sample to read from |
|
offset |
Offset in frames to read from |
|
frames |
Number of frames to read |
|
buf |
Buffer to store sample data in (should be at least |
|
format |
Format to transform sample data to (if its the same as the native
format of |
|
channel_map |
Channel mapping if |
|
err |
Location to store error info or |
gpointer ipatch_sample_read_transform_size (IpatchSample *sample
,guint offset
,guint size
,int format
,guint32 channel_map
,GError **err
);
Like ipatch_sample_read_transform()
but is GObject Introspection friendly
and audio buffer is allocated.
[rename-to ipatch_sample_read_transform]
sample |
Sample to read from |
|
offset |
Offset in frames to read from |
|
size |
Size of sample data to read (in bytes) after conversion |
|
format |
Format to transform sample data to (if its the same as the native
format of |
|
channel_map |
Channel mapping if |
|
err |
Location to store error info or |
Newly
allocated buffer containing sample data or NULL
on error (in which case
err
may be set).
[array length=size][element-type guint8][transfer full]
Since: 1.1.0
gboolean ipatch_sample_write_transform (IpatchSample *sample
,guint offset
,guint frames
,gconstpointer buf
,int format
,guint32 channel_map
,GError **err
);
Like ipatch_sample_write()
but allows for sample transformation.
[skip]
sample |
Sample to write to |
|
offset |
Offset in frames to write to |
|
frames |
Number of frames to write |
|
buf |
Buffer of sample data to write (should be at least |
|
format |
Format to transform sample data from (if its the same as the native
format of |
|
channel_map |
Channel mapping if |
|
err |
Location to store error info or |
gboolean ipatch_sample_write_transform_size (IpatchSample *sample
,guint offset
,gconstpointer buf
,guint size
,int format
,guint32 channel_map
,GError **err
);
Like ipatch_sample_write()
but allows for sample transformation.
[rename-to ipatch_sample_write_transform]
sample |
Sample to write to |
|
offset |
Offset in frames to write to |
|
buf |
Buffer of sample data to write |
|
size |
Size of data in |
|
format |
Format to transform sample data from (if its the same as the native
format of |
|
channel_map |
Channel mapping if |
|
err |
Location to store error info or |
Since: 1.1.0
gboolean ipatch_sample_copy (IpatchSample *dest_sample
,IpatchSample *src_sample
,guint32 channel_map
,GError **err
);
Copy sample data from one sample to another. The two samples may differ
in format, in which case the sample data will be converted. The
dest_sample
must either be the same size in frames as src_sample
or not
yet assigned a size.
dest_sample |
Destination sample to copy data to |
|
src_sample |
Source sample to copy data from |
|
channel_map |
Channel mapping, use IPATCH_SAMPLE_UNITY_CHANNEL_MAP for 1 to 1
channel mapping (see |
|
err |
Location to store error information or |
gboolean ipatch_sample_save_to_file (IpatchSample *sample
,const char *filename
,int file_format
,int sub_format
,GError **err
);
Convenience function to save a sample to a file using libsndfile.
sample |
Sample to save to file |
|
filename |
File name to save to |
|
file_format |
A value from the dynamic GEnum "IpatchSndFileFormat". |
[type IpatchSndFileFormat] |
sub_format |
A value from the dynamic GEnum "IpatchSndFileSubFormat" or -1
to calculate optimal value based on the format of |
|
err |
Location to store error info or |
gboolean ipatch_sample_handle_open (IpatchSample *sample
,IpatchSampleHandle *handle
,char mode
,int format
,guint32 channel_map
,GError **err
);
Open a handle to a sample for reading or writing sample data. Can optionally
provide data conversion if format
is set. If it is desirable to have more
control over the transform object and buffer allocation, the transform object
can be assigned with ipatch_sample_handle_set_transform()
. Note that a sample
transform is acquired if format
is set, even if the format is identical to
the sample
format, as a convenience to always provide a data buffer.
sample |
Sample to open a handle to |
|
handle |
Caller supplied structure to initialize. |
[out] |
mode |
Access mode to sample, 'r' for reading and 'w' for writing |
|
format |
Sample format to convert to/from (0 for no conversion or to assign
a transform object with |
|
channel_map |
Channel mapping if |
|
err |
Location to store error information |
void
ipatch_sample_handle_close (IpatchSampleHandle *handle
);
Close a handle previously opened with ipatch_sample_handle_open()
.
IpatchSampleTransform *
ipatch_sample_handle_get_transform (IpatchSampleHandle *handle
);
Get sample transform from a sample handle. Only exists if sample
data conversion is taking place or even if formats are the same but was
implicitly supplied to ipatch_sample_handle_open()
. Transform should not be
modified unless it was assigned via ipatch_sample_handle_set_transform()
.
void ipatch_sample_handle_set_transform (IpatchSampleHandle *handle
,IpatchSampleTransform *transform
);
Assign a sample transform to a sample handle. Provided for added
control over transform
allocation. A transform can also be automatically
created and assigned with ipatch_sample_handle_open()
. Sample transform
allocation is taken over by handle
.
int
ipatch_sample_handle_get_format (IpatchSampleHandle *handle
);
Get the sample format of a sample handle. May differ from the IpatchSample format of the handle, if it was opened with a different format and is therefore being converted.
int
ipatch_sample_handle_get_frame_size (IpatchSampleHandle *handle
);
A convenience function to get size of a single sample frame for a given
sample handle
. This is useful for determining buffer allocation sizes when
reading or writing data.
guint
ipatch_sample_handle_get_max_frames (IpatchSampleHandle *handle
);
A convenience function to get the maximum transform frames that can fit
in the sample transform of handle
.
gpointer ipatch_sample_handle_read (IpatchSampleHandle *handle
,guint offset
,guint frames
,gpointer buf
,GError **err
);
Read sample data from a sample handle. If the number of
frames read is within the sample transform buffer size and buf
is NULL
then the transform buffer will be returned (extra copy not needed).
[skip]
handle |
Sample handle |
|
offset |
Offset in frames to read from |
|
frames |
Number of frames to read |
|
buf |
Buffer to store sample data in (should be at least |
|
err |
Location to store error info or |
gpointer ipatch_sample_handle_read_size (IpatchSampleHandle *handle
,guint offset
,guint size
,GError **err
);
Read sample data from a sample handle. Like ipatch_sample_handle_read()
but
is GObject Introspection friendly and allocates returned buffer.
[rename-to ipatch_sample_handle_read]
handle |
Sample handle |
|
offset |
Offset in frames to read from |
|
size |
Size of data to read (in bytes), must be a multiple of sample frame size |
|
err |
Location to store error info or |
Newly allocated
sample data or NULL
on error (in which case err
may be set).
[array length=size][element-type guint8][transfer full]
Since: 1.1.0
gboolean ipatch_sample_handle_write (IpatchSampleHandle *handle
,guint offset
,guint frames
,gconstpointer buf
,GError **err
);
Write sample data to a sample handle.
[skip]
handle |
Sample handle |
|
offset |
Offset in frames to write to |
|
frames |
Number of frames to write |
|
buf |
Buffer of sample data to write (should be at least |
|
err |
Location to store error info or |
gboolean ipatch_sample_handle_write_size (IpatchSampleHandle *handle
,guint offset
,gconstpointer buf
,guint size
,GError **err
);
Write sample data to a sample handle. Like ipatch_sample_handle_write()
but
is GObject Introspection friendly.
[rename-to ipatch_sample_handle_write]
handle |
Sample handle |
|
offset |
Offset in frames to write to |
|
buf |
Buffer of sample data to write. |
[array length=size][element-type guint8][transfer none] |
size |
Size of |
|
err |
Location to store error info or |
Since: 1.1.0
gboolean ipatch_sample_handle_cascade_open (IpatchSampleHandle *handle
,IpatchSample *sample
,GError **err
);
This can be called from IpatchSampleIface.open methods for objects which contain a pointer to an IpatchSample that contains the sample's data.
[skip]
GParamSpec * ipatch_sample_install_property (GObjectClass *oclass
,guint property_id
,const char *property_name
);
A helper function for objects that have an IpatchSample interface. Installs a IpatchSample interface property for the given object class. The parameter will be G_PARAM_READWRITE.
[skip]
oclass |
Object class to install IpatchSample property |
|
property_id |
Property ID for set/get property class method |
|
property_name |
IpatchSample property name to install |
GParamSpec * ipatch_sample_install_property_readonly (GObjectClass *oclass
,guint property_id
,const char *property_name
);
A helper function for objects that have an IpatchSample interface.
Identical to ipatch_sample_install_property()
but installs the property
as readonly and uses g_object_class_override_property()
instead of
creating a new GParamSpec.
[skip]
oclass |
Object class to install IpatchSample property |
|
property_id |
Property ID for set/get property class method |
|
property_name |
IpatchSample property name to install |
GParamSpec * ipatch_sample_new_property_param_spec (const char *property_name
,GParamFlags flags
);
Seldom used function that creates a new GParamSpec that is identical to
a IpatchSample property by the name property_name
, except the flags
can differ.
[skip]
struct IpatchSampleHandle { IpatchSample *sample; /* The sample which this handle applies to */ IpatchSampleTransform *transform; /* Set if sample is being converted */ IpatchSampleHandleReadFunc read; /* Read method pointer (copied from IpatchItem interface) */ IpatchSampleHandleWriteFunc write; /* Write method pointer (copied from IpatchItem interface) */ IpatchSampleHandleCloseFunc close; /* Close method pointer (copied from IpatchItem interface) */ guint32 read_mode : 1; /* TRUE if read mode, FALSE if write mode */ guint32 manual_transform : 1; /* Methods handle sample transform */ guint32 release_transform : 1; /* TRUE if transform should be released from transform pool */ guint32 format : 12; /* Format to transform to */ guint32 reserved : 17; guint32 channel_map; /* Channel map for multi-channel audio transform */ gpointer data1; /* sample interface defined */ gpointer data2; /* sample interface defined */ gpointer data3; /* sample interface defined */ gpointer data4; /* sample interface defined */ guint32 reserved2; };
#define IPATCH_SAMPLE_FORMAT_DEFAULT
Default sample format for IpatchSample interface.
#define IPATCH_SAMPLE_RATE_MIN 100
Minimum sample rate. SoundFont spec says 8000 Hz is minimum guaranteed, seen lots of smaller values though.
“fine-tune”
property “fine-tune” int
Fine tuning in cents.
Owner: IpatchSample
Flags: Read
Allowed values: [-99,99]
Default value: 0
“loop-end”
property “loop-end” guint
Loop end in frames (after loop).
Owner: IpatchSample
Flags: Read
Default value: 0
“loop-start”
property “loop-start” guint
Start of loop in frames.
Owner: IpatchSample
Flags: Read
Default value: 0
“loop-type”
property“loop-type” IpatchSampleLoopType
Loop method type.
Owner: IpatchSample
Flags: Read
Default value: IPATCH_SAMPLE_LOOP_NONE
“root-note”
property “root-note” int
Root MIDI note.
Owner: IpatchSample
Flags: Read
Allowed values: [0,127]
Default value: 60
“sample-data”
property“sample-data” IpatchSampleData *
Sample data.
Owner: IpatchSample
Flags: Read
“sample-format”
property “sample-format” int
Sample format.
Owner: IpatchSample
Flags: Read
Allowed values: >= 0
Default value: 2
“sample-rate”
property “sample-rate” int
Sampling rate in Hertz.
Owner: IpatchSample
Flags: Read
Allowed values: [100,192000]
Default value: 44100