feat(plot): lock axes and calculate marker levels in dB
This commit is contained in:
@@ -11,9 +11,9 @@ static int finite_values(const double *v, size_t n) {
|
||||
uint32_t set_plot_abi_version(void) { return 1U; }
|
||||
|
||||
size_t set_plot_eval(uint32_t op, const double *v, size_t n, double *out, size_t cap) {
|
||||
static const size_t sizes[] = {10, 3, 4, 4, 6, 2, 3};
|
||||
static const size_t sizes[] = {10, 3, 4, 4, 6, 2, 3, 2};
|
||||
double span, fraction;
|
||||
if (op > SET_PLOT_DELTA || !v || !out || n != sizes[op] ||
|
||||
if (op > SET_PLOT_DB_DELTA || !v || !out || n != sizes[op] ||
|
||||
cap < (op == SET_PLOT_TRANSFORM ? 4U : 1U)) return 0;
|
||||
if (op == SET_PLOT_TRANSFORM) {
|
||||
double w, h, fx, fy;
|
||||
@@ -65,6 +65,10 @@ size_t set_plot_eval(uint32_t op, const double *v, size_t n, double *out, size_t
|
||||
break;
|
||||
}
|
||||
case SET_PLOT_DELTA: out[0] = (v[1] - v[0]) * v[2]; break;
|
||||
case SET_PLOT_DB_DELTA:
|
||||
if (v[0] == 0 || v[1] == 0) return 0;
|
||||
out[0] = 20 * log10(fabs(v[1] / v[0]));
|
||||
break;
|
||||
default: return 0;
|
||||
}
|
||||
return isfinite(out[0]) ? 1 : 0;
|
||||
|
||||
Reference in New Issue
Block a user