]> git.sesse.net Git - kdenlive/blobdiff - src/audioscopes/ffttools.h
Reorganize and cleanup build structure
[kdenlive] / src / audioscopes / ffttools.h
index 9014d47e54fb8234e83a6e4f96df85ea450537f7..26cee848288bfcca5015de29da86389d50bc8182 100644 (file)
@@ -13,7 +13,7 @@
 
 #include <QVector>
 #include <QHash>
-#include <tools/kiss_fftr.h>
+#include "kiss_fft/tools/kiss_fftr.h"
 
 class FFTTools
 {
@@ -56,6 +56,23 @@ public:
     void fftNormalized(const QVector<int16_t> audioFrame, const uint channel, const uint numChannels, float *freqSpectrum,
                        const WindowType windowType, const uint windowSize, const float param = 0);
 
+
+    /** This is linear interpolation with the special property that it preserves peaks, which is required
+        for e.g. showing correct Decibel values (where the peak values are of interest because of clipping which
+        may occur for too strong frequencies; The lower values are smeared by the window function anyway).
+        Consider f = {0, 100, 0}
+                 x = {0.5,  1.5}: With default linear interpolation x0 and x1 would both be mapped to 50.
+        This function maps x1 (the first position after the peak) to 100.
+
+        @param in           The source vector containing the data
+        @param targetSize   Number of interpolation nodes between ...
+        @param left         the left array index in the in-vector and ...
+        @param right        the right array index (both inclusive).
+        @param fill         If right lies outside of the array bounds (which is perfectly fine here) then this value
+                            will be used for filling the missing information.
+        */
+    static const QVector<float> interpolatePeakPreserving(const QVector<float> in, const uint targetSize, uint left = 0, uint right = 0, float fill = 0.0);
+
 private:
     QHash<QString, kiss_fftr_cfg> m_fftCfgs; // FFT cfg cache
     QHash<QString, QVector<float> > m_windowFunctions; // Window function cache