Repository navigation
Input const status and other TensorType aliases - #354
AlexHarker wants to merge 2 commits into
Conversation
|
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. |
There was a problem hiding this comment.
🟡 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
Frequency masking and squaring mutate a read-only input map · New Mutable frame map cannot bind to read-only input · New Mutable map declaration rejects read-only peak input · New Normalization and power branches mutate a read-only input map · New Mutable map declaration rejects read-only input · New Mean-centering writes through a read-only input map · New Mutable map declaration rejects read-only input · New Const input view breaks template deduction for mutable views · New Mutable input map cannot bind to read-only map · New
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, |
| 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, |
|
yes. what co-pilot can't possibly go on to realise is that if you |
|
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 |
|
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. |

Here is a first shot at using the types defined in TensorTypes.hpp mostly for const correctness.
Some notes:
If someone has time to test that would be great