aboutsummaryrefslogtreecommitdiffstats
path: root/testing/libkeyfinder/issue_22.patch
blob: a21338ccf87abc9bf6a7a4e3fb3e6de79c52821d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
commit 1be2a3290389b53e1e9f91710bcc6d1ccad2abe9
Author: Jean-Louis Fuchs <ganwell@fangorn.ch>
Date:   Thu Mar 23 23:09:14 2017 +0100

    Alpine patch

diff --git a/fftadapter.cpp b/fftadapter.cpp
index 57e8197..1ec7c6c 100644
--- a/fftadapter.cpp
+++ b/fftadapter.cpp
@@ -40,6 +40,7 @@ namespace KeyFinder {
     frameSize = inFrameSize;
     priv->inputReal = (double*)fftw_malloc(sizeof(double) * frameSize);
     priv->outputComplex = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * frameSize);
+    memset(priv->outputComplex, 0, sizeof(fftw_complex) * frameSize);
     fftwPlanMutex.lock();
     priv->plan = fftw_plan_dft_r2c_1d(frameSize, priv->inputReal, priv->outputComplex, FFTW_ESTIMATE);
     fftwPlanMutex.unlock();
diff --git a/tests/audiodatatest.cpp b/tests/audiodatatest.cpp
index 30657a7..a96e0ab 100644
--- a/tests/audiodatatest.cpp
+++ b/tests/audiodatatest.cpp
@@ -296,12 +296,12 @@ TEST_CASE ("AudioDataTest/DownsamplerResamplesNonintegralRelationship") {
   KeyFinder::AudioData a;
   a.setChannels(1);
   a.setFrameRate(100);
-  a.addToSampleCount(12);
+  a.addToSampleCount(15);
   for (unsigned int i = 0; i < 5; i++)
     a.setSample(i, 100.0);
   for (unsigned int i = 5; i < 10; i++)
     a.setSample(i, 500.0);
-  for (unsigned int i = 10; i < 12; i++)
+  for (unsigned int i = 10; i < 15; i++)
     a.setSample(i, 1000.0);
 
   a.downsample(5);
@@ -309,7 +309,6 @@ TEST_CASE ("AudioDataTest/DownsamplerResamplesNonintegralRelationship") {
   ASSERT_EQ(3, a.getSampleCount());
   ASSERT_FLOAT_EQ(100.0, a.getSample(0));
   ASSERT_FLOAT_EQ(500.0, a.getSample(1));
-  // this doesn't make total mathematical sense but I'm taking a shortcut for performance
   ASSERT_FLOAT_EQ(1000.0, a.getSample(2));
 }
 
diff --git a/tests/lowpassfiltertest.cpp b/tests/lowpassfiltertest.cpp
index 6135ed0..21220ff 100644
--- a/tests/lowpassfiltertest.cpp
+++ b/tests/lowpassfiltertest.cpp
@@ -194,7 +194,6 @@ TEST (LowPassFilterTest, WorksOnRepetitiveWaves) {
 TEST (LowPassFilterTest, DefaultFilterMatchesFisherCoefficients) {
   KeyFinder::LowPassFilter* lpf = new KeyFinder::LowPassFilter(160, 44100, 2000.0, 2048);
   std::vector<double>* myCoeffs = (std::vector<double>*)lpf->getCoefficients();
-  delete lpf;
 
   float fisherCoeffsFirstHalf[] = {
     -0.0022979864, -0.0014851155, -0.0005276345, +0.0005287637,
@@ -224,4 +223,5 @@ TEST (LowPassFilterTest, DefaultFilterMatchesFisherCoefficients) {
     ASSERT_FLOAT_EQ(fisherCoeffsFirstHalf[i], myCoeffs->at(i));
     ASSERT_FLOAT_EQ(myCoeffs->at(i), myCoeffs->at(160 - i));
   }
+  delete lpf;
 }