[all] Interpolation (curves) was less precise than before! Automatic google test added to avoid this later...
This commit is contained in:
@@ -463,6 +463,17 @@ TEST(Mixer, RecursiveAddChannel)
|
||||
EXPECT_EQ(chans[1], 0);
|
||||
}
|
||||
|
||||
TEST(Curves, LinearIntpol)
|
||||
{
|
||||
MODEL_RESET();
|
||||
for (int8_t i=-2; i<=2; i++) {
|
||||
g_model.points[2+i] = 50*i;
|
||||
}
|
||||
EXPECT_EQ(intpol(-1024, 0), -1024);
|
||||
EXPECT_EQ(intpol(0, 0), 0);
|
||||
EXPECT_EQ(intpol(1024, 0), 1024);
|
||||
EXPECT_EQ(intpol(-192, 0), -192);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
StartEepromThread(NULL);
|
||||
|
||||
+5
-5
@@ -429,17 +429,17 @@ void modelDefault(uint8_t id)
|
||||
#endif
|
||||
}
|
||||
|
||||
int16_t intpol(int16_t x, uint8_t idx) // -100, -75, -50, -25, 0, 25 ,50, 75, 100
|
||||
int16_t intpol(int16_t x, uint8_t idx) // -100, -75, -50, -25, 0 ,25 ,50, 75, 100
|
||||
{
|
||||
CurveInfo crv = curveinfo(idx);
|
||||
int16_t erg = 0;
|
||||
|
||||
x+=RESXu;
|
||||
if (x < 0) {
|
||||
erg = (int16_t)crv.crv[0];
|
||||
erg = (int16_t)crv.crv[0] * (RESX/4);
|
||||
}
|
||||
else if (x >= (RESX*2)) {
|
||||
erg = (int16_t)crv.crv[crv.points-1];
|
||||
erg = (int16_t)crv.crv[crv.points-1] * (RESX/4);
|
||||
}
|
||||
else {
|
||||
uint16_t a=0, b=0;
|
||||
@@ -457,10 +457,10 @@ int16_t intpol(int16_t x, uint8_t idx) // -100, -75, -50, -25, 0, 25 ,50, 75, 10
|
||||
a = i * d;
|
||||
b = a + d;
|
||||
}
|
||||
erg = (int16_t)crv.crv[i] + ((int32_t)(x-a) * (crv.crv[i+1]-crv.crv[i])) / (b-a);
|
||||
erg = (int16_t)crv.crv[i]*(RESX/4) + ((int32_t)(x-a) * (crv.crv[i+1]-crv.crv[i]) * (RESX/4)) / ((b-a));
|
||||
}
|
||||
|
||||
return calc100toRESX(erg);
|
||||
return erg / 25; // 100*D5/RESX;
|
||||
}
|
||||
|
||||
#if defined(CURVES)
|
||||
|
||||
Reference in New Issue
Block a user