Parlatype.Waveloader

g GObject.Object GObject.Object Parlatype.Waveloader Parlatype.Waveloader GObject.Object->Parlatype.Waveloader

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (uri)

get_data ()

get_duration ()

load_async (pps, cancellable, callback, *user_data)

load_finish (result)

resize (pps)

resize_async (pps, cancellable, callback, *user_data)

resize_finish (result)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

uri

str

r/w/c

Signals

Inherited:

GObject.Object (1)

Name

Short Description

array-size-changed

The size of the array with waveform data has changed.

progress

While loading a waveform a progress signal is emitted, starting with a value greater than 0.0.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Parlatype.Waveloader(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Parlatype.WaveloaderClass

classmethod new(uri)
Parameters:

uri (str or None) – URI of the audio file to load

Returns:

a new Parlatype.Waveloader

Return type:

Parlatype.Waveloader

Returns a new Parlatype.Waveloader. The uri is not checked on construction, but calling Parlatype.Waveloader.load_async() will fail with an error message.

After use GObject.Object.unref() it.

New in version 1.4.

get_data()
Returns:

a GLib.Array with wave data

Return type:

[float]

This returns the pointer to a GLib.Array 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.

New in version 2.0.

get_duration()
Returns:

duration in nanoseconds as used by GStreamer

Return type:

int

Returns the duration of stream. As the whole stream is scanned, this is supposed to be an exact duration, not an estimate.

New in version 1.4.

load_async(pps, cancellable, callback, *user_data)
Parameters:

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.

Parlatype.Waveloader :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 Parlatype.Waveloader ::progress is emitted every 30 ms.

In your callback call Parlatype.Waveloader.load_finish to get the result of the operation.

You can get a pointer to the GLib.Array holding the data with Parlatype.Waveloader.get_data either before loading it or afterwards.

New in version 2.0.

load_finish(result)
Parameters:

result (Gio.AsyncResult) – the Gio.AsyncResult passed to your Gio.AsyncReadyCallback

Raises:

GLib.Error

Returns:

True if successful, or False with error set

Return type:

bool

Gives the result of the async load operation. A cancelled operation results in an error, too.

New in version 1.4.

resize(pps)
Parameters:

pps (int) – the requested pixel per second ratio

Raises:

GLib.Error

Returns:

True if successful, or False with error set

Return type:

bool

Sync version of Parlatype.Waveloader.resize_async.

New in version 2.0.

resize_async(pps, cancellable, callback, *user_data)
Parameters:

Resizes wave form data at the requested resolution pps. If the array’s size has to be changed, Parlatype.Waveloader ::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 Parlatype.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.

New in version 2.0.

resize_finish(result)
Parameters:

result (Gio.AsyncResult) – the Gio.AsyncResult passed to your Gio.AsyncReadyCallback

Raises:

GLib.Error

Returns:

True if successful, or False with error set

Return type:

bool

Gives the result of the async resize operation. A cancelled operation results in an error, too.

New in version 2.0.

Signal Details

Parlatype.Waveloader.signals.array_size_changed(waveloader)
Signal Name:

array-size-changed

Flags:

RUN_FIRST

Parameters:

waveloader (Parlatype.Waveloader) – The object which received the signal

The size of the array with waveform data has changed.

Parlatype.Waveloader.signals.progress(waveloader, progress)
Signal Name:

progress

Flags:

RUN_FIRST

Parameters:
  • waveloader (Parlatype.Waveloader) – The object which received the signal

  • progress (float) – the new progress state, ranging from 0.0 to 1.0

While loading a waveform a progress signal is emitted, starting with a value greater than 0.0. At the end of the operation, 1.0 is emitted in case of success, otherwise 0.0.

Property Details

Parlatype.Waveloader.props.uri
Name:

uri

Type:

str

Default Value:

''

Flags:

READABLE, WRITABLE, CONSTRUCT

URI of the audio file.