Improvements to adaptive waveplot

Open
#1,540 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
python

Research direction

Start by locating the AdaptiveWaveplot class and the waveshow entry point, then trace how the viewport threshold selects the step or envelope view. Work out the unresolved downsampling-pyramid and figure-DPI decisions before implementation; done means selecting the lowest suitable envelope resolution without the blocky display described for long signals.

Written by the indexing model from the issue text.

Description

display enhancement

Is your feature request related to a problem? Please describe.
Documenting this conversation with @achabotl -

The AdaptiveWaveplot class is used by waveshow to dynamically switch between a step plot of the raw samples and an fill_between plot of the amplitude envelope based on the size of the viewport. If the viewport is smaller than max_points / sr, then the step plot is shown; otherwise, the envelope is shown.

To balance memory usage between the two views, the envelope plot is constructed so that it has about max_points horizontal steps. This works well enough for most cases, but if the signal is very long, and the user zooms in to just above the threshold for switching to step plots, it will result in a very blocky display.

Describe the solution you'd like
Instead of having only two modes (step and envelope), it might be worth maintaining a downsampling pyramid of envelopes at different resolutions.
This way, we'd never be off by more than a factor of two from a reasonably high-resolution display.

While this sounds expensive up front, I think it could end up being cheaper overall if we use more aggressive decimation in constructing the envelopes. Rather than pinning the number of horizontal steps to the sample threshold, we could instead derive a meaningful limit by querying the figure for its DPI.

The only change to the logic here would be that instead of one threshold, we have multiple, and switch to the lowest resolution that still provides reasonable resolution. (Some details to be fleshed out here.)

Dominant language
Python
Stars
8.6k
Forks
1.1k
Avg merge
6d 8h
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from librosa/librosa

All issues in librosa/librosa

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.