summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Schürmann <daschuer@mixxx.org>2019-06-07 22:10:04 +0200
committerDaniel Schürmann <daschuer@mixxx.org>2019-06-07 22:27:54 +0200
commitb8fb433b9f5ee86dbbfd1fde679328ea56d9e494 (patch)
treeefceace873d1100c4b6333565eb2938aa0fef848 /lib
parent8ebba3f352bb77604e2a505a0115253a58627cad (diff)
Update qm-dsp from https://github.com/c4dm/qm-dsp/commit/9b18a2294638e2a28c8b97ca04d870422a8da4ef
Diffstat (limited to 'lib')
-rw-r--r--lib/qm-dsp/CONTRIBUTING.md10
-rw-r--r--lib/qm-dsp/base/KaiserWindow.cpp26
-rw-r--r--lib/qm-dsp/base/KaiserWindow.h44
-rw-r--r--lib/qm-dsp/base/Pitch.cpp12
-rw-r--r--lib/qm-dsp/base/Pitch.h12
-rw-r--r--lib/qm-dsp/base/Restrict.h35
-rw-r--r--lib/qm-dsp/base/SincWindow.cpp30
-rw-r--r--lib/qm-dsp/base/SincWindow.h16
-rw-r--r--lib/qm-dsp/base/Window.h56
-rw-r--r--lib/qm-dsp/dsp/chromagram/CQprecalc.cpp49850
-rw-r--r--lib/qm-dsp/dsp/chromagram/Chromagram.cpp41
-rw-r--r--lib/qm-dsp/dsp/chromagram/Chromagram.h12
-rw-r--r--lib/qm-dsp/dsp/chromagram/ConstantQ.cpp387
-rw-r--r--lib/qm-dsp/dsp/chromagram/ConstantQ.h52
-rw-r--r--lib/qm-dsp/dsp/keydetection/GetKeyMode.cpp714
-rw-r--r--lib/qm-dsp/dsp/keydetection/GetKeyMode.h206
-rw-r--r--lib/qm-dsp/dsp/mfcc/MFCC.cpp6
-rw-r--r--lib/qm-dsp/dsp/mfcc/MFCC.h4
-rw-r--r--lib/qm-dsp/dsp/onsets/DetectionFunction.cpp111
-rw-r--r--lib/qm-dsp/dsp/onsets/DetectionFunction.h30
-rw-r--r--lib/qm-dsp/dsp/onsets/PeakPicking.cpp76
-rw-r--r--lib/qm-dsp/dsp/onsets/PeakPicking.h46
-rw-r--r--lib/qm-dsp/dsp/phasevocoder/PhaseVocoder.cpp8
-rw-r--r--lib/qm-dsp/dsp/phasevocoder/PhaseVocoder.h4
-rw-r--r--lib/qm-dsp/dsp/rateconversion/Decimator.cpp211
-rw-r--r--lib/qm-dsp/dsp/rateconversion/Decimator.h20
-rw-r--r--lib/qm-dsp/dsp/rateconversion/DecimatorB.cpp18
-rw-r--r--lib/qm-dsp/dsp/rateconversion/DecimatorB.h6
-rw-r--r--lib/qm-dsp/dsp/rateconversion/Resampler.cpp63
-rw-r--r--lib/qm-dsp/dsp/rateconversion/Resampler.h4
-rw-r--r--lib/qm-dsp/dsp/rhythm/BeatSpectrum.h4
-rw-r--r--lib/qm-dsp/dsp/segmentation/ClusterMeltSegmenter.cpp46
-rw-r--r--lib/qm-dsp/dsp/segmentation/ClusterMeltSegmenter.h33
-rw-r--r--lib/qm-dsp/dsp/segmentation/Segmenter.cpp11
-rw-r--r--lib/qm-dsp/dsp/segmentation/Segmenter.h50
-rw-r--r--lib/qm-dsp/dsp/segmentation/cluster_melt.c382
-rw-r--r--lib/qm-dsp/dsp/segmentation/cluster_melt.h24
-rw-r--r--lib/qm-dsp/dsp/segmentation/cluster_segmenter.c441
-rw-r--r--lib/qm-dsp/dsp/segmentation/cluster_segmenter.h22
-rw-r--r--lib/qm-dsp/dsp/segmentation/segment.h37
-rw-r--r--lib/qm-dsp/dsp/signalconditioning/DFProcess.cpp154
-rw-r--r--lib/qm-dsp/dsp/signalconditioning/DFProcess.h21
-rw-r--r--lib/qm-dsp/dsp/signalconditioning/FiltFilt.cpp94
-rw-r--r--lib/qm-dsp/dsp/signalconditioning/FiltFilt.h10
-rw-r--r--lib/qm-dsp/dsp/signalconditioning/Filter.cpp16
-rw-r--r--lib/qm-dsp/dsp/signalconditioning/Filter.h4
-rw-r--r--lib/qm-dsp/dsp/signalconditioning/Framer.cpp100
-rw-r--r--lib/qm-dsp/dsp/signalconditioning/Framer.h44
-rw-r--r--lib/qm-dsp/dsp/tempotracking/DownBeat.cpp66
-rw-r--r--lib/qm-dsp/dsp/tempotracking/DownBeat.h20
-rw-r--r--lib/qm-dsp/dsp/tempotracking/TempoTrack.cpp894
-rw-r--r--lib/qm-dsp/dsp/tempotracking/TempoTrack.h216
-rw-r--r--lib/qm-dsp/dsp/tempotracking/TempoTrackV2.cpp261
-rw-r--r--lib/qm-dsp/dsp/tempotracking/TempoTrackV2.h42
-rw-r--r--lib/qm-dsp/dsp/tonal/ChangeDetectionFunction.cpp207
-rw-r--r--lib/qm-dsp/dsp/tonal/ChangeDetectionFunction.h27
-rw-r--r--lib/qm-dsp/dsp/tonal/TCSgram.cpp48
-rw-r--r--lib/qm-dsp/dsp/tonal/TCSgram.h42
-rw-r--r--lib/qm-dsp/dsp/tonal/TonalEstimator.cpp130
-rw-r--r--lib/qm-dsp/dsp/tonal/TonalEstimator.h112
-rw-r--r--lib/qm-dsp/dsp/transforms/DCT.cpp18
-rw-r--r--lib/qm-dsp/dsp/transforms/DCT.h4
-rw-r--r--lib/qm-dsp/dsp/transforms/FFT.h4
-rw-r--r--lib/qm-dsp/dsp/wavelet/Wavelet.cpp70
-rw-r--r--lib/qm-dsp/dsp/wavelet/Wavelet.h67
-rw-r--r--lib/qm-dsp/hmm/hmm.c1323
-rw-r--r--lib/qm-dsp/hmm/hmm.h58
-rw-r--r--lib/qm-dsp/maths/Correlation.cpp32
-rw-r--r--lib/qm-dsp/maths/Correlation.h11
-rw-r--r--lib/qm-dsp/maths/CosineDistance.cpp1
-rw-r--r--lib/qm-dsp/maths/CosineDistance.h10
-rw-r--r--lib/qm-dsp/maths/KLDivergence.cpp2
-rw-r--r--lib/qm-dsp/maths/KLDivergence.h19
-rw-r--r--lib/qm-dsp/maths/MathAliases.h51
-rw-r--r--lib/qm-dsp/maths/MathUtilities.cpp150
-rw-r--r--lib/qm-dsp/maths/MathUtilities.h15
-rw-r--r--lib/qm-dsp/maths/MedianFilter.h71
-rw-r--r--lib/qm-dsp/maths/Polyfit.h322
-rw-r--r--lib/qm-dsp/maths/nan-inf.h4
-rw-r--r--lib/qm-dsp/maths/pca/pca.c449
-rw-r--r--lib/qm-dsp/maths/pca/pca.h4
-rw-r--r--lib/qm-dsp/mixxx-changes.patch242
-rw-r--r--lib/qm-dsp/thread/AsynchronousTask.h12
-rw-r--r--lib/qm-dsp/thread/BlockAllocator.h4
-rw-r--r--lib/qm-dsp/thread/Thread.h4
85 files changed, 3976 insertions, 54639 deletions
diff --git a/lib/qm-dsp/CONTRIBUTING.md b/lib/qm-dsp/CONTRIBUTING.md
index 6f6229e610..00b09d8148 100644
--- a/lib/qm-dsp/CONTRIBUTING.md
+++ b/lib/qm-dsp/CONTRIBUTING.md
@@ -71,9 +71,11 @@ Code style
at the start of a function or class definition where it gets a line
of its own
- * Please use braces around any conditional or loop block that
- occupies its own line
+ * Please use braces around any conditional or loop block that is not
+ on the same line as the test
-Some of the older code in this library does not follow these
-guidelines - usually this means the code needs to be updated.
+ * Please keep lines to no more than 80 characters in length
+
+ * Avoid using unsigned int types, unless doing bit manipulation (see
+ http://soundsoftware.ac.uk/c-pitfall-unsigned.html for rationale)
diff --git a/lib/qm-dsp/base/KaiserWindow.cpp b/lib/qm-dsp/base/KaiserWindow.cpp
index 4fe838e090..306b6aaacd 100644
--- a/lib/qm-dsp/base/KaiserWindow.cpp
+++ b/lib/qm-dsp/base/KaiserWindow.cpp
@@ -17,27 +17,27 @@
KaiserWindow::Parameters
KaiserWindow::parametersForTransitionWidth(double attenuation,
- double transition)
+ double transition)
{
Parameters p;
p.length = 1 + (attenuation > 21.0 ?
- ceil((attenuation - 7.95) / (2.285 * transition)) :
- ceil(5.79 / transition));
+ ceil((attenuation - 7.95) / (2.285 * transition)) :
+ ceil(5.79 / transition));
p.beta = (attenuation > 50.0 ?
- 0.1102 * (attenuation - 8.7) :
- attenuation > 21.0 ?
- 0.5842 * pow(attenuation - 21.0, 0.4) + 0.07886 * (attenuation - 21.0) :
- 0);
+ 0.1102 * (attenuation - 8.7) :
+ attenuation > 21.0 ?
+ 0.5842 * pow(attenuation - 21.0, 0.4) + 0.07886 * (attenuation - 21.0) :
+ 0);
return p;
}
static double besselTerm(double x, int i)
{
if (i == 0) {
- return 1;
+ return 1;
} else {
- double f = MathUtilities::factorial(i);
- return pow(x/2, i*2) / (f*f);
+ double f = MathUtilities::factorial(i);
+ return pow(x/2, i*2) / (f*f);
}
}
@@ -45,7 +45,7 @@ static double bessel0(double x)
{
double b = 0.0;
for (int i = 0; i < 20; ++i) {
- b += besselTerm(x, i);
+ b += besselTerm(x, i);
}
return b;
}
@@ -56,8 +56,8 @@ KaiserWindow::init()
double denominator = bessel0(m_beta);
bool even = (m_length % 2 == 0);
for (int i = 0; i < (even ? m_length/2 : (m_length+1)/2); ++i) {
- double k = double(2*i) / double(m_length-1) - 1.0;
- m_window.push_back(bessel0(m_beta * sqrt(1.0 - k*k)) / denominator);
+ double k = double(2*i) / double(m_length-1) - 1.0;
+ m_window.push_back(bessel0(m_beta * sqrt(1.0 - k*k)) / denominator);
}
for (int i = 0; i < (even ? m_length/2 : (m_length-1)/2); ++i) {
m_window.push_back(m_window[int(m_length/2) - i - 1]);
diff --git a/lib/qm-dsp/base/KaiserWindow.h b/lib/qm-dsp/base/KaiserWindow.h
index f16a4b6c16..23afe8c687 100644
--- a/lib/qm-dsp/base/KaiserWindow.h
+++ b/lib/qm-dsp/base/KaiserWindow.h
@@ -11,8 +11,8 @@
COPYING included with this distribution for more information.
*/
-#ifndef KAISER_WINDOW_H
-#define KAISER_WINDOW_H
+#ifndef QM_DSP_KAISER_WINDOW_H
+#define QM_DSP_KAISER_WINDOW_H
#include <vector>
#include <cmath>
@@ -26,8 +26,8 @@ class KaiserWindow
{
public:
struct Parameters {
- int length;
- double beta;
+ int length;
+ double beta;
};
/**
@@ -41,9 +41,9 @@ public:
* and transition width in samples.
*/
static KaiserWindow byTransitionWidth(double attenuation,
- double transition) {
- return KaiserWindow
- (parametersForTransitionWidth(attenuation, transition));
+ double transition) {
+ return KaiserWindow
+ (parametersForTransitionWidth(attenuation, transition));
}
/**
@@ -51,10 +51,10 @@ public:
* and transition bandwidth in Hz for the given samplerate.
*/
static KaiserWindow byBandwidth(double attenuation,
- double bandwidth,
- double samplerate) {
- return KaiserWindow
- (parametersForBandwidth(attenuation, bandwidth, samplerate));
+ double bandwidth,
+ double samplerate) {
+ return KaiserWindow
+ (parametersForBandwidth(attenuation, bandwidth, samplerate));
}
/**
@@ -62,7 +62,7 @@ public:
* given attenuation in dB and transition width in samples.
*/
static Parameters parametersForTransitionWidth(double attenuation,
- double transition);
+ double transition);
/**
* Obtain the parameters necessary for a Kaiser window of the
@@ -70,28 +70,28 @@ public:
* given samplerate.
*/
static Parameters parametersForBandwidth(double attenuation,
- double bandwidth,
- double samplerate) {
- return parametersForTransitionWidth
- (attenuation, (bandwidth * 2 * M_PI) / samplerate);
+ double bandwidth,
+ double samplerate) {
+ return parametersForTransitionWidth
+ (attenuation, (bandwidth * 2 * M_PI) / samplerate);
}
int getLength() const {
- return m_length;
+ return m_length;
}
const double *getWindow() const {
- return m_window.data();
+ return m_window.data();
}
void cut(double *src) const {
- cut(src, src);
+ cut(src, src);
}
void cut(const double *src, double *dst) const {
- for (int i = 0; i < m_length; ++i) {
- dst[i] = src[i] * m_window[i];
- }
+ for (int i = 0; i < m_length; ++i) {
+ dst[i] = src[i] * m_window[i];
+ }
}
private:
diff --git a/lib/qm-dsp/base/Pitch.cpp b/lib/qm-dsp/base/Pitch.cpp
index 9ba8b4b3f7..2b8fd8b9bd 100644
--- a/lib/qm-dsp/base/Pitch.cpp
+++ b/lib/qm-dsp/base/Pitch.cpp
@@ -18,8 +18,8 @@
float
Pitch::getFrequencyForPitch(int midiPitch,
- float centsOffset,
- float concertA)
+ float centsOffset,
+ float concertA)
{
float p = float(midiPitch) + (centsOffset / 100);
return concertA * powf(2.0, (p - 69.0) / 12.0);
@@ -27,8 +27,8 @@ Pitch::getFrequencyForPitch(int midiPitch,
int
Pitch::getPitchForFrequency(float frequency,
- float *centsOffsetReturn,
- float concertA)
+ float *centsOffsetReturn,
+ float concertA)
{
float p = 12.0 * (log(frequency / (concertA / 2.0)) / log(2.0)) + 57.0;
@@ -36,8 +36,8 @@ Pitch::getPitchForFrequency(float frequency,
float centsOffset = (p - midiPitch) * 100.0;
if (centsOffset >= 50.0) {
- midiPitch = midiPitch + 1;
- centsOffset = -(100.0 - centsOffset);
+ midiPitch = midiPitch + 1;
+ centsOffset = -(100.0 - centsOffset);
}
if (centsOffsetReturn) *centsOffsetReturn = centsOffset;
diff --git a/lib/qm-dsp/base/Pitch.h b/lib/qm-dsp/base/Pitch.h
index 5b55ecc4a3..3a564c30c6 100644
--- a/lib/qm-dsp/base/Pitch.h
+++ b/lib/qm-dsp/base/Pitch.h
@@ -12,8 +12,8 @@
COPYING included with this distribution for more information.
*/
-#ifndef _PITCH_H_
-#define _PITCH_H_
+#ifndef QM_DSP_PITCH_H
+#define QM_DSP_PITCH_H
/**
* Convert between musical pitch (i.e. MIDI pitch number) and
@@ -23,12 +23,12 @@ class Pitch
{
public:
static float getFrequencyForPitch(int midiPitch,
- float centsOffset = 0,
- float concertA = 440.0);
+ float centsOffset = 0,
+ float concertA = 440.0);
static int getPitchForFrequency(float frequency,
- float *centsOffsetReturn = 0,
- float concertA = 440.0);
+ float *centsOffsetReturn = 0,
+ float concertA = 440.0);
};
diff --git a/lib/qm-dsp/base/Restrict.h b/lib/qm-dsp/base/Restrict.h
index 723a8b3b67..47e1636721 100644
--- a/lib/qm-dsp/base/Restrict.h
+++ b/lib/qm-dsp/base/Restrict.h
@@ -1,17 +1,18 @@
-
-#ifndef QM_DSP_RESTRICT_H
-#define QM_DSP_RESTRICT_H
-
-#ifdef _MSC_VER
-#define QM_R__ __restrict
-#endif
-
-#ifdef __GNUC__
-#define QM_R__ __restrict__
-#endif
-
-#ifndef QM_R__
-#define QM_R__
-#endif
-
-#endif
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+#ifndef QM_DSP_RESTRICT_H
+#define QM_DSP_RESTRICT_H
+
+#ifdef _MSC_VER
+#define QM_R__ __restrict
+#endif
+
+#ifdef __GNUC__
+#define QM_R__ __restrict__
+#endif
+
+#ifndef QM_R__
+#define QM_R__
+#endif
+
+#endif
diff --git a/lib/qm-dsp/base/SincWindow.cpp b/lib/qm-dsp/base/SincWindow.cpp
index 5d31a631e3..0a795e535f 100644
--- a/lib/qm-dsp/base/SincWindow.cpp
+++ b/lib/qm-dsp/base/SincWindow.cpp
@@ -19,27 +19,27 @@ void
SincWindow::init()
{
if (m_length < 1) {
- return;
+ return;
} else if (m_length < 2) {
- m_window.push_back(1);
- return;
+ m_window.push_back(1);
+ return;
} else {
- int n0 = (m_length % 2 == 0 ? m_length/2 : (m_length - 1)/2);
- int n1 = (m_length % 2 == 0 ? m_length/2 : (m_length + 1)/2);
- double m = 2 * M_PI / m_p;
+ int n0 = (m_length % 2 == 0 ? m_length/2 : (m_length - 1)/2);
+ int n1 = (m_length % 2 == 0 ? m_length/2 : (m_length + 1)/2);
+ double m = 2 * M_PI / m_p;
- for (int i = 0; i < n0; ++i) {
- double x = ((m_length / 2) - i) * m;
- m_window.push_back(sin(x) / x);
- }
+ for (int i = 0; i < n0; ++i) {
+ double x = ((m_length / 2) - i) * m;
+ m_window.push_back(sin(x) / x);
+ }
- m_window.push_back(1.0);
+ m_window.push_back(1.0);
- for (int i = 1; i < n1; ++i) {
- double x = i * m;
- m_window.push_back(sin(x) / x);
- }
+ for (int i = 1; i < n1; ++i) {
+ double x = i * m;
+ m_window.push_back(sin(x) / x);
+ }
}
}
diff --git a/lib/qm-dsp/base/SincWindow.h b/lib/qm-dsp/base/SincWindow.h
index bb35d90c20..324639a598 100644
--- a/lib/qm-dsp/base/SincWindow.h
+++ b/lib/qm-dsp/base/SincWindow.h
@@ -11,8 +11,8 @@
COPYING included with this distribution for more information.
*/
-#ifndef SINC_WINDOW_H
-#define SINC_WINDOW_H
+#ifndef QM_DSP_SINC_WINDOW_H
+#define QM_DSP_SINC_WINDOW_H
#include <vector>
@@ -33,21 +33,21 @@ public:
SincWindow(int length, double p) : m_length(length), m_p(p) { init(); }
int getLength() const {
- return m_length;
+ return m_length;
}
const double *getWindow() const {
- return m_window.data();
+ return m_window.data();
}
void cut(double *src) const {
- cut(src, src);
+ cut(src, src);
}
void cut(const double *src, double *dst) const {
- for (int i = 0; i < m_length; ++i) {
- dst[i] = src[i] * m_window[i];
- }
+ for (int i = 0; i < m_length; ++i) {
+ dst[i] = src[i] * m_window[i];
+ }
}
private:
diff --git a/lib/qm-dsp/base/Window.h b/lib/qm-dsp/base/Window.h
index 93909115c0..8c327531b9 100644
--- a/