Skip to content

Fix/const views - #355

Open
weefuzzy wants to merge 4 commits into
flucoma:mainfrom
weefuzzy:fix/const_views
Open

weefuzzy wants to merge 4 commits into
flucoma:mainfrom
weefuzzy:fix/const_views

Conversation

@weefuzzy

Copy link
Copy Markdown
Member

Make inputs to algorithms const correct with Input(Real|Complex)(Vector|Matrix)View. Repair with the fallout (cases where inputs were being mutated). Fixes #353

Builds and passes tests (here) but not given a proper road test. Functionality should be unaltered.

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.

🟡 Changes recommended

The changes introduce a compilation failure in ChromaFilterBank by mutating a read-only Eigen map and inconsistent dictionary normalization in NMFFilterClient that halves output in the single-basis example.

2 open issues
What changed in this PR

This PR addresses #353 by making algorithm inputs accept views over const data and removing input mutations where needed.

Changes:

  • Replace mutable input-view types with InputReal and InputComplex views across algorithm APIs.
  • Adapt Eigen mappings and use copies or expressions where processing previously modified inputs.
  • Clean up includes and correct integer division in NMFCross attenuation.
File Description
include/​flucoma/​algorithms/​util/​TruePeak.hpp Accept const input frames and remove an unused include.
include/​flucoma/​algorithms/​public/​YINFFT.hpp Accept const input frames.
include/​flucoma/​algorithms/​public/​TransientSegmentation.hpp Accept const input samples.
include/​flucoma/​algorithms/​public/​TransientExtraction.hpp Update input views and statistic callback signatures.
include/​flucoma/​algorithms/​public/​STFT.hpp Accept const audio and spectra in analysis helpers.
include/​flucoma/​algorithms/​public/​Standardization.hpp Support const initialization and processing inputs.
include/​flucoma/​algorithms/​public/​SpectralShape.hpp Accept const spectral input.
include/​flucoma/​algorithms/​public/​RobustScaling.hpp Support const inputs and inferred Eigen mappings.
include/​flucoma/​algorithms/​public/​PCA.hpp Center input within the projection expression without mutation.
include/​flucoma/​algorithms/​public/​NoveltySegmentation.hpp Accept const feature input.
include/​flucoma/​algorithms/​public/​NoveltyFeature.hpp Accept const feature input.
include/​flucoma/​algorithms/​public/​Normalization.hpp Support const inputs and inferred Eigen mappings.
include/​flucoma/​algorithms/​public/​NMFCross.hpp Update input types and use floating-point attenuation.
include/​flucoma/​algorithms/​public/​NMF.hpp Accept const inputs and copy the frame-processing dictionary.
include/​flucoma/​algorithms/​public/​MultiStats.hpp Accept const matrix input.
include/​flucoma/​algorithms/​public/​MelBands.hpp Add reusable scratch storage for input transformations.
include/​flucoma/​algorithms/​public/​Loudness.hpp Accept const frames and infer the Eigen map type.
include/​flucoma/​algorithms/​public/​HPS.hpp Accept const spectral input.
include/​flucoma/​algorithms/​public/​DCT.hpp Accept const frames and infer the Eigen map type.
include/​flucoma/​algorithms/​public/​ChromaFilterBank.hpp Change input to a const view and infer its Eigen mapping.
include/​flucoma/​algorithms/​public/​CepstrumF0.hpp Accept const spectral input.

Review effort: Balanced

using namespace std;

FluidEigenMap<Eigen::Array> frame = _impl::asEigen<Eigen::Array>(in);
auto frame = _impl::asEigen<Eigen::Array>(in);
Comment on lines +52 to +53
ScopedEigenMap<MatrixXd> W{W0.rows(),W0.cols(),alloc};
W = asEigen<Matrix>(W0);
@AlexHarker

Copy link
Copy Markdown
Contributor

Thought some of the items that the co-pilot review surfaced in #354 might still be at play. I think there might still be more to check. Tests don't compile everything as far as I can see - probably usage with one of the CCE repos might reveal more, although it looks like one of the fixes also breaks NMF (see above).

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.

Feature Request: const correctness on inputs to algorithms supported properly

3 participants