Top |
An object to load waveform data from an audio file. The raw data can be used by a widget to visually represent a waveform.
PtWaveloader *
pt_waveloader_new (gchar *uri
);
Returns a new PtWaveloader. The uri
is not checked on construction, but
calling pt_waveloader_load_async()
will fail with an error message.
After use g_object_unref()
it.
Since: 1.4
void pt_waveloader_load_async (PtWaveloader *wl
,gint pps
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Saves sample data to private memory. To keep the memory footprint low, the raw data is downsampled to 8000 samples per second (16 bit per sample). This requires approx. 1 MB of memory per minute.
“uri” must be set. If it is not valid, an error will be returned. If there is another load operation going on, an error will be returned.
While saving data “progress” is emitted every 30 ms.
In your callback call pt_waveloader_load_finish to get the result of the operation.
You can get a pointer to the GArray holding the data with pt_waveloader_get_data either before loading it or afterwards.
wl |
||
pps |
pixels per second |
|
cancellable |
a GCancellable or NULL. |
[nullable] |
callback |
a GAsyncReadyCallback to call when the operation is complete. |
[scope async] |
user_data |
user_data for callback. |
[closure] |
Since: 2.0
gboolean pt_waveloader_load_finish (PtWaveloader *wl
,GAsyncResult *result
,GError **error
);
Gives the result of the async load operation. A cancelled operation results in an error, too.
wl |
||
result |
the GAsyncResult passed to your GAsyncReadyCallback |
|
error |
a pointer to a NULL GError, or NULL. |
[nullable] |
Since: 1.4
void pt_waveloader_resize_async (PtWaveloader *wl
,gint pps
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Resizes wave form data at the requested resolution pps
. If the array's
size has to be changed, “array-size-changed” is emitted.
Any data in the array will be overwritten.
The resolution is given as pixel per seconds, e.g. 100 means one second
is represented by 100 samples, is 100 pixels wide. pps
must be >= 25 and <= 200.
You should have loaded a file with pt_waveloader_load_async before resizing it. There are no concurrent operations allowed. An error is returned, if the file was not loaded before, if it is still loading or if there is another pt_waveloader_get_data_async operation going on.
Cancelling the operation returns an error and lets the array in an inconsistent state. Its size will be according to the requested new resolution, but the data will be partly old, partly new.
In your callback call pt_waveloader_get_data_finish to get the result of the operation.
wl |
||
pps |
the requested pixel per second ratio |
|
cancellable |
a GCancellable or NULL. |
[nullable] |
callback |
a GAsyncReadyCallback to call when the operation is complete. |
[scope async] |
user_data |
user_data for callback. |
[closure] |
Since: 2.0
gboolean pt_waveloader_resize_finish (PtWaveloader *wl
,GAsyncResult *result
,GError **error
);
Gives the result of the async resize operation. A cancelled operation results in an error, too.
wl |
||
result |
the GAsyncResult passed to your GAsyncReadyCallback |
|
error |
a pointer to a NULL GError, or NULL. |
[nullable] |
Since: 2.0
gboolean pt_waveloader_resize (PtWaveloader *wl
,gint pps
,GError **error
);
Sync version of pt_waveloader_resize_async.
wl |
||
pps |
the requested pixel per second ratio |
|
error |
return location for an error, or NULL. |
[nullable] |
Since: 2.0
gint64
pt_waveloader_get_duration (PtWaveloader *wl
);
Returns the duration of stream. As the whole stream is scanned, this is supposed to be an exact duration, not an estimate.
Since: 1.4
GArray *
pt_waveloader_get_data (PtWaveloader *wl
);
This returns the pointer to a GArray that is holding all the wave form data. It consists of a minimum value in the range of -1 to 0 and a maximum value in the range of 0 to 1, repeating this until the end. Each min/max pair can be drawn by the application as one vertical line in the wave form.
Don't modify the data.
Since: 2.0
struct PtWaveloader;
The PtWaveloader contains only private fields and should not be directly accessed.
“array-size-changed”
signalvoid user_function (PtWaveloader *wl, gpointer user_data)
The size of the array with waveform data has changed.
wl |
the waveloader emitting the signal |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
“progress”
signalvoid user_function (PtWaveloader *wl, double progress, gpointer user_data)
Indicates progress on a scale from 0.0 to 1.0, however it does not emit the value 0.0 nor 1.0. Wait for a successful operation until any gui element showing progress is dismissed.
wl |
the waveloader emitting the signal |
|
progress |
the new progress state, ranging from 0.0 to 1.0 |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First