Skip to content

9769 spectrogram painting - #9948

Merged
saintmatthieu merged 66 commits into
audacity:masterfrom
saintmatthieu:9769-spectrogram-painting
Dec 17, 2025
Merged

saintmatthieu merged 66 commits into
audacity:masterfrom
saintmatthieu:9769-spectrogram-painting

Conversation

@saintmatthieu

@saintmatthieu saintmatthieu commented Nov 27, 2025 •

Copy link
Copy Markdown
Contributor

Resolves: #9769

  • I signed CLA
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

QA:
Please note that spectral selection isn't part of this PR.

  • Track settings are persistent
  • Clip accessibility works in all 3 views
  • Stereo channel resizing works in all track views
  • Sample drawing still works in multi-view
  • works for trimmed and stretched clips
  • Spectrogram is painted upon undo/redo or when a clip got generated
  • Preview button works
  • Changing spectrogram settings on one track doesn't affect the settings of another track
  • Works at different zoom levels
  • Works in multiview and for stereo tracks
  • Autobot test cases have been run

@saintmatthieu saintmatthieu self-assigned this Nov 27, 2025
@saintmatthieu
saintmatthieu force-pushed the 9769-spectrogram-painting branch 8 times, most recently from 1ccd96d to f105fda Compare December 4, 2025 16:01
@saintmatthieu
saintmatthieu marked this pull request as ready for review December 4, 2025 16:42
@embarc-gabriel

Copy link
Copy Markdown
Contributor

Stereo tracks channel height ratio change should also reflect on the spectrogram on multiview.
Also, changing the ratio on the waveform seems broken on multiview compared to waveform alone.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements spectrogram painting functionality for Audacity, allowing spectrograms to be rendered dynamically based on track settings. The implementation includes a preview/apply mechanism with automatic revert-on-cancel functionality.

Key Changes

  • Added spectrogram painter infrastructure with AU3 integration to render spectrogram visuals
  • Implemented settings management with preview, apply, and automatic revert functionality using snapshot pattern
  • Refactored UI components to support both waveform and spectrogram views through a common abstract base class

Reviewed changes

Copilot reviewed 66 out of 66 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/trackedit/view/trackspectrogramsettingsmodel.* Adds preview/apply logic and destructor-based revert using configuration snapshots
src/trackedit/internal/trackspectrogramsettingsupdater.* Manages global settings propagation to tracks using global settings
src/trackedit/internal/snapshotspectrogramconfiguration.h Immutable snapshot class for storing/reverting spectrogram settings
src/spectrogram/ispectrogrampainter.h Defines painter interface for rendering spectrograms
src/spectrogram/internal/au3/au3spectrogrampainter.* Implements spectrogram painting using AU3 backend
src/spectrogram/internal/au3/au3spectrogramclipchannelpainter.* Handles per-channel spectrogram rendering with caching
src/spectrogram/internal/spectrogramutils.* Utility functions for time/position conversion and pixel alignment
src/spectrogram/internal/spectrogramcolors.* Pre-computed color gradients for spectrogram visualization
src/projectscene/view/tracksitemsview/abstractclipview.* New base class extracting common clip view properties and behavior
src/projectscene/view/tracksitemsview/spectrogramview.* Spectrogram-specific view implementation with viewport observation
src/projectscene/view/tracksitemsview/waveview.* Refactored to inherit from AbstractClipView
src/appshell/internal/appshellconfiguration.* Adds notification for settings apply events
au3/libraries/lib-wave-track-settings/SpectrogramSettings.cpp Updates window caching logic for spectrogram algorithms
CMakeLists.txt files Adds new source files to build system

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@audacity audacity deleted a comment from Copilot AI Dec 8, 2025
@saintmatthieu
saintmatthieu force-pushed the 9769-spectrogram-painting branch 4 times, most recently from 785f72b to dd61129 Compare December 9, 2025 22:35
@saintmatthieu
saintmatthieu force-pushed the 9769-spectrogram-painting branch from dd61129 to ccabb60 Compare December 10, 2025 11:44
// First time assignment of global variable identifying a colour
iIndex = index;
mColourNames.push_back(Name);
wxASSERT(allNames.insert(Name).second);

@embarc-gabriel embarc-gabriel Dec 10, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove asserts from wxWidgets?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's possible. I'll push a commit where all wx references are removed from the spectrogram module.


#include <QColor>

#include <wx/arrstr.h>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More wxWidgets dependencies. Is it too much work to remove these dependencies?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// RegisterImage( myFlags, bmpRecordButton, some image, wxT("RecordButton"));
int myFlags = resFlagPaired;
NameSet allNames;
#define SPECTROGRAM_COLORS_INITS

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a code smell to me but I know this is a legacy code and you are not suppose to improve all of it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an unusual system all right, but trying to rewrite is isn't necessary now (and maybe ever).

@@ -213,13 +213,19 @@ void AppShellConfiguration::startEditSettings()
void AppShellConfiguration::applySettings()
{
settings()->commitTransaction();
m_settingsApplied.notify();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to be notified if any settings have been applied?
Can we make it more granular, listening only to specific settings like?

muse::settings()->valueChanged(SETTING_I_CARE_ABOUT).onReceive...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That solution you propose fires when a setting is changed in the dialog, on the fly. Here there's a new use case (new AFAICS): only react to settings changes when they get confirmed by the "Apply" button.
Note: this change should go away with the optimization follow-up PR: then spectrogram recalculation and repaint should become fast enough that changes can be reflected on the fly.

visibleT0 = std::max(hiddenDurationLeft, .0);
const auto visibleT1 = std::max(std::min(tpost, clipLength - blank), 0.0);

// Make sure visibleT1 is greater than visibleT0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a fan of this type of comment. It is just translating code to English, which I could easily deduce by just reading the code.
Apart from that visibleT0 is a member variable without m_ prefix.
Once again, I understand this is legacy code, so I don't have strong opinions on whether we need to refactor all this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree, this comment is superfluous. Removed.
About the absence of m_, yeah, I agree that it's confusing. I have a local commit that addresses this, will push it in due time.

@embarc-gabriel

Copy link
Copy Markdown
Contributor

@saintmatthieu this is a big step and very nice work. It removed a lot of code, which is a clear +1 for me and it is structurally well organized as far as I could tell.
I saw some wxWidgets stuff, different naming conversion for member variables and functions, and other tricks, probably from the legacy code you used and moved around.
If it is hard to fix these small things, I suggest that we move it to QA and create a ticket so we don't forget about this in the future.
I'll wait for your comments though.

…ck attachments...

Global configuration uses the Au4 preferences system.
@saintmatthieu
saintmatthieu force-pushed the 9769-spectrogram-painting branch from 75f46b2 to c96c8fc Compare December 17, 2025 11:04
@saintmatthieu
saintmatthieu merged commit 1f3a54a into audacity:master Dec 17, 2025
@saintmatthieu
saintmatthieu deleted the 9769-spectrogram-painting branch August 28, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement drawing of spectrum view

4 participants