-#ifndef SLIDER_DECIBELS_H
-#define SLIDER_DECIBELS_H
-#include "slider.qc"
-CLASS(XonoticDecibelsSlider, XonoticSlider)
- METHOD(XonoticDecibelsSlider, loadCvars, void(entity));
- METHOD(XonoticDecibelsSlider, saveCvars, void(entity));
- METHOD(XonoticDecibelsSlider, valueToText, string(entity, float));
-ENDCLASS(XonoticDecibelsSlider)
-entity makeXonoticDecibelsSlider_T(float, float, float, string, string);
-entity makeXonoticDecibelsSlider(float, float, float, string);
-#endif
-
-#ifdef IMPLEMENTATION
+#include "slider_decibels.qh"
float toDecibelOfSquare(float f, float mi)
{
{
// linear scale part
float t = 1 / A + mi;
- float y = exp(1 + A * mi);
- if(f <= y)
- return mi + (t - mi) * (f / y);
+ float u = exp(1 + A * mi);
+ if(f <= u)
+ return mi + (t - mi) * (f / u);
}
return log(f) / A;
}
{
// linear scale part
float t = 1 / A + mi;
- float y = exp(1 + A * mi);
+ float u = exp(1 + A * mi);
if(f <= t)
- return y * ((f - mi) / (t - mi));
+ return u * ((f - mi) / (t - mi));
}
return exp(A * f);
}
float v = fromDecibelOfSquare(db, -40);
float dbv = toDecibelOfSquare(v, -40);
float d = dbv - db;
- LOG_INFOF("%f -> %f -> %f (diff: %f)\n", db, v, dbv, d);
+ LOG_INFOF("%f -> %f -> %f (diff: %f)", db, v, dbv, d);
EXPECT_GT(fabs(d), 0.02);
}
SUCCEED();
}
-
-#endif