summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Schürmann <daschuer@mixxx.org>2019-05-12 23:20:04 +0200
committerDaniel Schürmann <daschuer@mixxx.org>2019-05-12 23:20:04 +0200
commit957aed588ba6c4806538bb10f05869d60137fc18 (patch)
tree7101fc9167aa7ef7f29724a520af856294594359 /lib
parent2c81fb90d40c6947e157cad66c2059c46b464995 (diff)
Use double precision for FS (sample rate)
This fixes a rounding error when using source sample rates not divisible by 8
Diffstat (limited to 'lib')
-rw-r--r--lib/qm-dsp/dsp/chromagram/Chromagram.cpp2
-rw-r--r--lib/qm-dsp/dsp/chromagram/Chromagram.h2
-rw-r--r--lib/qm-dsp/dsp/chromagram/ConstantQ.cpp5
-rw-r--r--lib/qm-dsp/dsp/chromagram/ConstantQ.h4
-rw-r--r--lib/qm-dsp/dsp/keydetection/GetKeyMode.cpp3
5 files changed, 8 insertions, 8 deletions
diff --git a/lib/qm-dsp/dsp/chromagram/Chromagram.cpp b/lib/qm-dsp/dsp/chromagram/Chromagram.cpp
index 2d6d8d194f..c913b310b8 100644
--- a/lib/qm-dsp/dsp/chromagram/Chromagram.cpp
+++ b/lib/qm-dsp/dsp/chromagram/Chromagram.cpp
@@ -44,7 +44,7 @@ int Chromagram::initialise( ChromaConfig Config )
// Populate CQ config structure with parameters
// inherited from the Chroma config
- ConstantQConfig.FS = Config.FS;
+ ConstantQConfig.FS = Config.FS;
ConstantQConfig.min = m_FMin;
ConstantQConfig.max = m_FMax;
ConstantQConfig.BPO = m_BPO;
diff --git a/lib/qm-dsp/dsp/chromagram/Chromagram.h b/lib/qm-dsp/dsp/chromagram/Chromagram.h
index bd928f5d48..b2ad72e0ac 100644
--- a/lib/qm-dsp/dsp/chromagram/Chromagram.h
+++ b/lib/qm-dsp/dsp/chromagram/Chromagram.h
@@ -21,7 +21,7 @@
#include "ConstantQ.h"
struct ChromaConfig{
- unsigned int FS;
+ double FS;
double min;
double max;
unsigned int BPO;
diff --git a/lib/qm-dsp/dsp/chromagram/ConstantQ.cpp b/lib/qm-dsp/dsp/chromagram/ConstantQ.cpp
index b764235fcd..5e14f0af78 100644
--- a/lib/qm-dsp/dsp/chromagram/ConstantQ.cpp
+++ b/lib/qm-dsp/dsp/chromagram/ConstantQ.cpp
@@ -125,8 +125,9 @@ void ConstantQ::sparsekernel()
hammingWindowIm[u] = 0;
}
- // Computing a hamming window
- const unsigned hammingLength = (int) ceil( m_dQ * m_FS / ( m_FMin * pow(2,((double)(k))/(double)m_BPO)));
+ // Computing a hamming window
+ const unsigned hammingLength = (int) ceil(
+ m_dQ * m_FS / (m_FMin * pow(2, (double)k / (double)m_BPO)));
unsigned origin = m_FFTLength/2 - hammingLength/2;
diff --git a/lib/qm-dsp/dsp/chromagram/ConstantQ.h b/lib/qm-dsp/dsp/chromagram/ConstantQ.h
index c06f60a9d0..bd666ddd6f 100644
--- a/lib/qm-dsp/dsp/chromagram/ConstantQ.h
+++ b/lib/qm-dsp/dsp/chromagram/ConstantQ.h
@@ -21,7 +21,7 @@
#include "maths/MathUtilities.h"
struct CQConfig{
- unsigned int FS; // samplerate
+ double FS; // samplerate
double min; // minimum frequency
double max; // maximum frequency
unsigned int BPO; // bins per octave
@@ -58,7 +58,7 @@ private:
void deInitialise();
double* m_CQdata;
- unsigned int m_FS;
+ double m_FS;
double m_FMin;
double m_FMax;
double m_dQ;
diff --git a/lib/qm-dsp/dsp/keydetection/GetKeyMode.cpp b/lib/qm-dsp/dsp/keydetection/GetKeyMode.cpp
index 3fb0470ccb..5a82edfef2 100644
--- a/lib/qm-dsp/dsp/keydetection/GetKeyMode.cpp
+++ b/lib/qm-dsp/dsp/keydetection/GetKeyMode.cpp
@@ -60,8 +60,7 @@ GetKeyMode::GetKeyMode( int sampleRate, float tuningFrequency,
// Chromagram configuration parameters
m_ChromaConfig.normalise = MathUtilities::NormaliseUnitMax;
- m_ChromaConfig.FS = lrint(sampleRate/(double)m_DecimationFactor);
- if (m_ChromaConfig.FS < 1) m_ChromaConfig.FS = 1;
+ m_ChromaConfig.FS = sampleRate/(double)m_DecimationFactor;
// Set C3 (= MIDI #48) as our base:
// This implies that key = 1 => Cmaj, key = 12 => Bmaj, key = 13 => Cmin, etc.