librosa.display.AdaptiveWaveplot#

class librosa.display.AdaptiveWaveplot(times, y, steps, envelope, sr=22050, max_samples=11025, transpose=False, label=None)[source]#

A helper class for managing adaptive wave visualizations.

This object is used to dynamically switch between sample-based and envelope-based visualizations of waveforms. When the display is zoomed in such that no more than max_samples would be visible, the sample-based display is used. When displaying the raw samples would require more than max_samples, an envelope-based plot is used instead.

You should never need to instantiate this object directly, as it is constructed automatically by waveshow.

Parameters:
timesnp.ndarray

An array containing the time index (in seconds) for each sample.

ynp.ndarray

An array containing the (monophonic) wave samples.

stepsmatplotlib.lines.Line2D

The matplotlib artist used for the sample-based visualization. This is constructed by matplotlib.pyplot.step.

envelopematplotlib.collections.PolyCollection

The matplotlib artist used for the envelope-based visualization. This is constructed by matplotlib.pyplot.fill_between.

srnumber > 0

The sampling rate of the audio

max_samplesint > 0

The maximum number of samples to use for sample-based display.

transposebool

If True, display the wave vertically instead of horizontally.

labelstr or None

An optional label for the waveplot, used in legend entries.

See also

waveshow
__init__(times, y, steps, envelope, sr=22050, max_samples=11025, transpose=False, label=None)[source]#

Methods

connect(ax, *[, signal])

Connect the adaptor to a signal on an axes object.

disconnect(*[, strict])

Disconnect the adaptor's update callback.

update(ax)

Update the matplotlib display according to the current viewport limits.

connect(ax, *, signal='xlim_changed')[source]#

Connect the adaptor to a signal on an axes object.

Note that if the adaptor has already been connected to an axes object, that connect is first broken and then replaced by a new callback.

Parameters:
axmatplotlib.axes.Axes

The axes to connect with this adaptor’s update

signalstring, {“xlim_changed”, “ylim_changed”}

The signal to connect

See also

disconnect
disconnect(*, strict=False)[source]#

Disconnect the adaptor’s update callback.

Parameters:
strictbool

If True, remove references to the connected axes. If False (default), only disconnect the callback.

This functionality is intended primarily for internal use, and should have no observable effects for users.

See also

connect
update(ax)[source]#

Update the matplotlib display according to the current viewport limits.

This is a callback function, and should not be used directly.

Parameters:
axmatplotlib.axes.Axes

The axes object to update

Attributes

ax

The connected Axes, or None if not connected or garbage collected.

envelope

The envelope artist (PolyCollection), or None if garbage collected.

steps

The step plot artist (Line2D), or None if garbage collected.

times

samples

sr

max_samples

transpose

cid

label_proxy_

ax#

The connected Axes, or None if not connected or garbage collected.

Returns:
matplotlib.axes.Axes or None

The connected axes, or None if not connected or garbage collected.

envelope#

The envelope artist (PolyCollection), or None if garbage collected.

Returns:
PolyCollection or None

The envelope artist, or None if it has been garbage collected.

steps#

The step plot artist (Line2D), or None if garbage collected.

Returns:
Line2D or None

The step plot artist, or None if it has been garbage collected.

times#
samples#
sr#
max_samples#
transpose#
cid#
label_proxy_#