commit ca347aa1112d5e521d1f3bed62b871a28a3d26aa
parent 0abeffe03c799329dbd19e1a98957b1f7f3607a4
Author: fundamental <mark.d.mccurry@gmail.com>
Date: Sun, 10 Jan 2021 21:16:20 -0500
Fix unit-test failures in PR #107
Outputs are expected to change as the PR makes volume and
filter changes smoother than they were.
Diffstat:
5 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/src/Misc/Part.cpp b/src/Misc/Part.cpp
@@ -942,8 +942,7 @@ void Part::ComputePartSmps()
float Part::volume127TodB(unsigned char volume_)
{
assert( volume_ <= 127 );
-
- return 20.0f * log10f(volume_ / 127.0f);
+ return (volume_ - 96.0f) / 96.0f * 40.0;
}
void Part::setVolumedB(float Volume_)
@@ -954,14 +953,14 @@ void Part::setVolumedB(float Volume_)
Volume_ = limit(Volume_, -40.0f, 13.333f);
- assert(Volume_ < 40.0);
+ assert(Volume_ < 14.0);
Volume = Volume_;
float volume = dB2rap( Volume_ );
/* printf( "Volume: %f, Expression %f\n", volume, ctl.expression.relvolume ); */
- assert( volume <= 1.0f );
+ assert( volume <= dB2rap(14.0f) );
gain = volume * ctl.expression.relvolume;
}
@@ -1301,7 +1300,7 @@ void Part::getfromXML(XMLwrapper& xml)
if (xml.hasparreal("volume")) {
setVolumedB(xml.getparreal("volume", Volume));
} else {
- setVolumedB(volume127TodB( xml.getpar127("volume", gain * 127.0f )));
+ setVolumedB(volume127TodB( xml.getpar127("volume", 96)));
}
setPpanning(xml.getpar127("panning", Ppanning));
diff --git a/src/Tests/AdNoteTest.h b/src/Tests/AdNoteTest.h
@@ -157,25 +157,25 @@ class AdNoteTest:public CxxTest::TestSuite
#endif
sampleCount += synth->buffersize;
- TS_ASSERT_DELTA(outL[255], 0.2555f, 0.0001f);
+ TS_ASSERT_DELTA(outL[255], 0.1924f, 0.0001f);
note->releasekey();
TS_ASSERT(!tr->hasNext());
w->add_watch("noteout/be4_mix");
note->noteout(outL, outR);
sampleCount += synth->buffersize;
- TS_ASSERT_DELTA(outL[255], -0.4688f, 0.0001f);
+ TS_ASSERT_DELTA(outL[255], -0.4717f, 0.0001f);
w->tick();
TS_ASSERT(tr->hasNext());
note->noteout(outL, outR);
sampleCount += synth->buffersize;
w->tick();
- TS_ASSERT_DELTA(outL[255], 0.0613f, 0.0001f);
+ TS_ASSERT_DELTA(outL[255], 0.0592f, 0.0001f);
note->noteout(outL, outR);
sampleCount += synth->buffersize;
- TS_ASSERT_DELTA(outL[255], 0.0971f, 0.0001f);
+ TS_ASSERT_DELTA(outL[255], 0.0989f, 0.0001f);
w->tick();
note->noteout(outL, outR);
sampleCount += synth->buffersize;
diff --git a/src/Tests/PadNoteTest.h b/src/Tests/PadNoteTest.h
@@ -151,7 +151,7 @@ class PadNoteTest:public CxxTest::TestSuite
#endif
sampleCount += synth->buffersize;
- TS_ASSERT_DELTA(outL[255], -0.0554, 0.0005f);
+ TS_ASSERT_DELTA(outL[255], 0.3950, 0.0005f);
note->releasekey();
@@ -160,21 +160,21 @@ class PadNoteTest:public CxxTest::TestSuite
w->add_watch("noteout");
note->noteout(outL, outR);
sampleCount += synth->buffersize;
- TS_ASSERT_DELTA(outL[255], -0.0729f, 0.0005f);
+ TS_ASSERT_DELTA(outL[255], -0.2305f, 0.0005f);
w->tick();
TS_ASSERT(!tr->hasNext());
note->noteout(outL, outR);
sampleCount += synth->buffersize;
- TS_ASSERT_DELTA(outL[255], -0.0331f, 0.0005f);
+ TS_ASSERT_DELTA(outL[255], -0.0754f, 0.0005f);
note->noteout(outL, outR);
sampleCount += synth->buffersize;
- TS_ASSERT_DELTA(outL[255], 0.0219f, 0.0005f);
+ TS_ASSERT_DELTA(outL[255], 0.0448f, 0.0005f);
note->noteout(outL, outR);
sampleCount += synth->buffersize;
- TS_ASSERT_DELTA(outL[255], 0.0137f, 0.0001f);
+ TS_ASSERT_DELTA(outL[255], 0.0220f, 0.0001f);
while(!note->finished()) {
note->noteout(outL, outR);
diff --git a/src/Tests/SubNoteTest.h b/src/Tests/SubNoteTest.h
@@ -117,7 +117,7 @@ class SubNoteTest:public CxxTest::TestSuite
#endif
sampleCount += synth->buffersize;
- TS_ASSERT_DELTA(outL[255], 0.0000f, 0.0001f);
+ TS_ASSERT_DELTA(outL[255], 0.0010f, 0.0001f);
note->releasekey();
@@ -126,12 +126,12 @@ class SubNoteTest:public CxxTest::TestSuite
note->noteout(outL, outR);
sampleCount += synth->buffersize;
- TS_ASSERT_DELTA(outL[255], 0.0029f, 0.0001f);
+ TS_ASSERT_DELTA(outL[255], 0.0114f, 0.0001f);
w->tick();
note->noteout(outL, outR);
sampleCount += synth->buffersize;
- TS_ASSERT_DELTA(outL[255], -0.0011f, 0.0001f);
+ TS_ASSERT_DELTA(outL[255], -0.0014f, 0.0001f);
w->tick();
TS_ASSERT(tr->hasNext());
@@ -141,7 +141,7 @@ class SubNoteTest:public CxxTest::TestSuite
w->add_watch("noteout/amp_int");
note->noteout(outL, outR);
sampleCount += synth->buffersize;
- TS_ASSERT_DELTA(outL[255], -0.0017f, 0.0001f);
+ TS_ASSERT_DELTA(outL[255], -0.0020f, 0.0001f);
w->tick();
note->noteout(outL, outR);
diff --git a/src/Tests/UnisonTest.h b/src/Tests/UnisonTest.h
@@ -100,37 +100,37 @@ class AdNoteTest:public CxxTest::TestSuite
note = new ADnote(params, pars);
note->noteout(outL, outR);
TS_ASSERT_DELTA(outL[80], values[0], 1.9e-5);
- printf("\n{%f,", outL[80]);
+ printf("{%f,", outL[80]);
note->noteout(outL, outR);
TS_ASSERT_DELTA(outR[90], values[1], 1.9e-5);
- printf("\n%f,", outR[90]);
+ printf("%f,", outR[90]);
note->noteout(outL, outR);
TS_ASSERT_DELTA(outL[20], values[2], 1.9e-5);
- printf("\n%f,", outL[20]);
+ printf("%f,", outL[20]);
note->noteout(outL, outR);
TS_ASSERT_DELTA(outR[200], values[3], 1.9e-5);
- printf("\n%f},\n", outR[200]);
+ printf("%f},\n", outR[200]);
}
void testUnison() {
sprng(0xbeef);
float data[][4] = {
- {-0.034547,0.034349,-0.000000,0.138284},
- {0.016801,-0.084991,0.000000,0.009240},
- {0.020383,-0.002424,-0.012952,-0.014037},
- {-0.041653,0.002287,0.000000,-0.098181},
- {-0.009189,-0.049860,0.000268,-0.084961},
- {0.056999,-0.084627,-0.018144,0.000666},
- {-0.015588,0.003690,0.003994,0.002435},
- {0.023178,-0.024961,0.004433,-0.015144},
- {0.042007,-0.006559,-0.005887,0.083685},
- {0.007638,0.057870,-0.014244,0.041457},
- {-0.018006,-0.017846,-0.063624,-0.016378},
- {0.004914,-0.001756,-0.046715,0.015975},
- {0.004341,-0.014575,0.000560,0.050902},
- {0.000470,-0.036961,0.038622,0.031383},
- {-0.045796,0.000262,0.009858,0.031958},
+ {0.125972,0.029887,0.000000,0.138013},
+ {-0.095414,-0.083965,-0.000000,0.009048},
+ {-0.077587,-0.001760,-0.021463,-0.013995},
+ {0.041240,-0.008561,-0.000000,-0.099298},
+ {-0.098969,-0.048030,-0.000052,-0.087053},
+ {0.104913,-0.081452,-0.017700,0.000978},
+ {0.041270,0.003788,0.006064,0.002436},
+ {-0.030791,-0.036072,-0.007964,-0.015141},
+ {0.009218,0.015333,-0.007500,0.083076},
+ {0.058909,0.064450,-0.002517,0.041595},
+ {-0.007731,-0.009040,-0.068033,-0.016573},
+ {-0.047286,-0.002355,-0.049196,0.016222},
+ {0.014014,-0.002635,0.006542,0.050710},
+ {-0.054877,-0.027135,0.040211,0.031927},
+ {-0.048367,0.022010,0.018224,0.032846},
};
int freq_spread[15];
@@ -147,6 +147,7 @@ class AdNoteTest:public CxxTest::TestSuite
inv_phase[i] = prng()%5;
}
+ printf("\n");
for(int i=0; i<15; ++i)
{
run_test(i, freq_spread[i], stereo_spread[i],