Skip to content

Input const status and other TensorType aliases - #354

Closed
AlexHarker wants to merge 2 commits into
mainfrom
input-const-status
Closed

AlexHarker wants to merge 2 commits into
mainfrom
input-const-status

Conversation

@AlexHarker

Copy link
Copy Markdown
Contributor

Here is a first shot at using the types defined in TensorTypes.hpp mostly for const correctness.

Some notes:

  • there are two commits
    • the first has more files but should be quicker to check
    • the second has more involved files and a lot more chance of incorrect replacement and/or compilation failure
  • none of this is tested in any way whatsoever

If someone has time to test that would be great

@AlexHarker

Copy link
Copy Markdown
Contributor Author

OK - it looks like some of the conversions to Eigen types have been messed up here - I was afraid that might happen, because that gets a lot more complex - let's see what the bots come up with on this.

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 const-input changes cause compilation failures across multiple headers through incompatible Eigen map types and break template deduction for the existing RunningStatsClient call.

9 open issues
What changed in this PR

This PR adopts shared tensor-view aliases across FluCoMa’s algorithms to distinguish read-only inputs from writable outputs and improve const correctness.

Changes:

  • Changes algorithm inputs to const-element real and complex tensor views.
  • Replaces explicit tensor-view types and KDTree’s local alias with shared aliases.
  • Updates transient-processing helper signatures and RunningStats’ templated input type.
File Description
include/​flucoma/​algorithms/​util/​TruePeak.hpp Uses read-only input views for interpolation and peak analysis.
include/​flucoma/​algorithms/​util/​ARModel.hpp Adopts shared aliases throughout prediction and estimation.
include/​flucoma/​algorithms/​public/​YINFFT.hpp Makes pitch-analysis input read-only.
include/​flucoma/​algorithms/​public/​TransientSegmentation.hpp Makes segmentation input read-only.
include/​flucoma/​algorithms/​public/​TransientExtraction.hpp Updates input views, helper signatures, and aliases.
include/​flucoma/​algorithms/​public/​STFT.hpp Uses read-only audio and complex-spectrum inputs.
include/​flucoma/​algorithms/​public/​Standardization.hpp Makes initialization and frame inputs read-only.
include/​flucoma/​algorithms/​public/​SpectralShape.hpp Makes spectral-analysis input read-only.
include/​flucoma/​algorithms/​public/​RunningStats.hpp Adds const elements to the templated input view.
include/​flucoma/​algorithms/​public/​RobustScaling.hpp Makes scaling input read-only.
include/​flucoma/​algorithms/​public/​PCA.hpp Makes projection input read-only.
include/​flucoma/​algorithms/​public/​NoveltySegmentation.hpp Makes novelty-segmentation input read-only.
include/​flucoma/​algorithms/​public/​NoveltyFeature.hpp Makes novelty-feature input read-only.
include/​flucoma/​algorithms/​public/​Normalization.hpp Makes normalization input read-only.
include/​flucoma/​algorithms/​public/​NMF.hpp Makes the activation-estimation frame input read-only.
include/​flucoma/​algorithms/​public/​MelBands.hpp Makes mel-band input read-only.
include/​flucoma/​algorithms/​public/​Loudness.hpp Makes loudness-analysis input read-only.
include/​flucoma/​algorithms/​public/​KDTree.hpp Replaces its local const-view alias with the shared alias.
include/​flucoma/​algorithms/​public/​HPS.hpp Makes pitch-analysis input read-only.
include/​flucoma/​algorithms/​public/​DCT.hpp Makes transform input read-only.
include/​flucoma/​algorithms/​public/​ChromaFilterBank.hpp Makes chroma-analysis input read-only.
include/​flucoma/​algorithms/​public/​CepstrumF0.hpp Makes cepstral pitch-analysis input read-only.

Review effort: Balanced

}

void processFrame(const RealVectorView in, RealVectorView out,
void processFrame(const InputRealVectorView in, RealVectorView out,
}

void processFrame(const RealVectorView in, RealVectorView out)
void processFrame(const InputRealVectorView in, RealVectorView out)
}

void processFrame(const RealVectorView& input, RealVectorView output,
void processFrame(const InputRealVectorView& input, RealVectorView output,
Comment on lines +79 to 80
void processFrame(const InputRealVectorView in, RealVectorView out, bool magNorm,
bool usePower, bool logOutput, Allocator&)
}

void processFrame(const RealVectorView in, RealVectorView out,
void processFrame(const InputRealVectorView in, RealVectorView out,
}

void processFrame(const RealVectorView in, RealVectorView out, index k,
void processFrame(const InputRealVectorView in, RealVectorView out, index k,
}

void processFrame(const RealVectorView in, RealVectorView out,
void processFrame(const InputRealVectorView in, RealVectorView out,

template<typename T>
void process(FluidTensorView<T, 1> in, FluidTensorView<T, 1> meanOut,
void process(FluidTensorView<const T, 1> in, FluidTensorView<T, 1> meanOut,
}

void processFrame(const RealVectorView in, RealVectorView out,
void processFrame(const InputRealVectorView in, RealVectorView out,
@weefuzzy

Copy link
Copy Markdown
Member

yes. what co-pilot can't possibly go on to realise is that if you auto all the things it says (fair call, tbf), you then discover a bunch of places where the supposedly const input gets mutated (mea culpa: because I stopped it allocating and copying in a bunch of places, but evidently with undue haste)

@weefuzzy

Copy link
Copy Markdown
Member

Some of those places need to be audio-thread friendly, so I will fix them up and put a fresh PR in with more extensive surgery. Thanks for this x

@AlexHarker

Copy link
Copy Markdown
Contributor Author

No worries - it seems it is a bigger can of worms than I thought.

Is now a useful time to mention that ARModel.hpp and the related transient extraction code already had extensive nice use of const?

No...I thought not.

@weefuzzy weefuzzy closed this Nov 10, 2026
@AlexHarker AlexHarker mentioned this pull request Nov 10, 2026
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.

3 participants