Skip to content

Commit 60b7683

Browse files
committed
Fixes for broken tests/warnings
1 parent 0e4402e commit 60b7683

4 files changed

Lines changed: 13 additions & 11 deletions

File tree

LibSource/Oscillator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class Oscillator : public SignalGenerator {
6868
template<class T, class BaseOscillator=Oscillator, typename Sample=float>
6969
class OscillatorTemplate : public BaseOscillator {
7070
protected:
71-
float mul;
71+
float mul = 1; // Prevent having NaN as default getFrequency result
7272
float phase = 0;
7373
float incr = 0;
7474
public:

TestPatches/QuadratureSineOscillatorTestPatch.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ class QuadratureSineOscillatorTestPatch : public TestPatch {
4545
AudioBuffer* s2 = AudioBuffer::create(2, 1000);
4646
ComplexFloatArray cmp = ComplexFloatArray::create(1000);
4747
osc1->generate(cmp);
48-
cmp.copyTo(s1->getSamples(0), s2->getSamples(1));
48+
cmp.copyTo(s1->getSamples(0), s1->getSamples(1));
4949
for(size_t i=0; i<1000; ++i) {
5050
ComplexFloat sample = osc2->generate();
5151
s2->getSamples(0)[i] = sample.re;
5252
s2->getSamples(1)[i] = sample.im;
5353
}
5454
for(size_t i=0; i<1000; ++i) {
55+
CHECK_CLOSE(cmp[i].re, s2->getSamples(0)[i], 0.00002);
56+
CHECK_CLOSE(cmp[i].im, s2->getSamples(1)[i], 0.00002);
5557
CHECK_CLOSE(s1->getSamples(0)[i], s2->getSamples(0)[i], 0.00002);
5658
CHECK_CLOSE(s1->getSamples(1)[i], s2->getSamples(1)[i], 0.00002);
5759
}
@@ -65,10 +67,10 @@ class QuadratureSineOscillatorTestPatch : public TestPatch {
6567
CHECK_CLOSE(cmp[i].re, s2->getSamples(0)[i], 0.00002);
6668
CHECK_CLOSE(cmp[i].im, s2->getSamples(1)[i], 0.00002);
6769
}
68-
AudioBuffer::destroy(s1);
69-
AudioBuffer::destroy(s2);
70-
QuadratureSineOscillator::destroy(osc1);
71-
QuadratureSineOscillator::destroy(osc2);
70+
AudioBuffer::destroy(s1);
71+
AudioBuffer::destroy(s2);
72+
QuadratureSineOscillator::destroy(osc1);
73+
QuadratureSineOscillator::destroy(osc2);
7274
}
7375
}
7476
};

TestPatches/SineOscillatorTestPatch.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ class SineOscillatorTestPatch : public TestPatch {
4545
FloatArray s2 = FloatArray::create(1000);
4646
osc1->generate(s1);
4747
for(size_t i=0; i<1000; ++i)
48-
s2[i] = osc2->generate();
48+
s2[i] = osc2->generate();
4949
for(size_t i=0; i<1000; ++i)
50-
CHECK_CLOSE(s1[i], s2[i], 0.00002);
50+
CHECK_CLOSE(s1[i], s2[i], 0.00002);
5151
osc1->generate(s1);
5252
for(size_t i=0; i<1000; ++i)
53-
s2[i] = osc2->generate();
53+
s2[i] = osc2->generate();
5454
for(size_t i=0; i<1000; ++i)
55-
CHECK_CLOSE(s1[i], s2[i], 0.00002);
55+
CHECK_CLOSE(s1[i], s2[i], 0.00002);
5656
FloatArray::destroy(s1);
5757
FloatArray::destroy(s2);
5858
SineOscillator::destroy(osc1);

TestPatches/fileio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extern "C"{
4141
errx(1, "Data buffer not specified");
4242
if ((fd = creat(file_name, 0666)) < 1)
4343
errx(1, "Error creating file");
44-
if (write(fd, data, size) < size)
44+
if (write(fd, data, size) < ssize_t(size))
4545
errx(1, "Error writing samples");
4646
close(fd);
4747
return size;

0 commit comments

Comments
 (0)