+#if COMPRESS_PITCH_DISPLAY
+// bend the scale a bit to get more precision around the interesting points
+double magnifying_glass(double x)
+{
+ double sigma = PITCH_COMPRESSION_SIGMA;
+ double div = 1.0 / sqrt(2.0 * sigma * sigma);
+ return
+ erf((x - find_linear_pos(notes[0].freq)) * div) +
+ erf((x - find_linear_pos(notes[1].freq)) * div) +
+ erf((x - find_linear_pos(notes[2].freq)) * div) +
+ erf((x - find_linear_pos(notes[3].freq)) * div) +
+ erf((x - find_linear_pos(notes[4].freq)) * div) +
+ erf((x - find_linear_pos(notes[5].freq)) * div);
+}
+
+// like nonlinear_func, but f(MIN_X) = MIN_X and f(MAX_X) = MAX_X
+double normalized_magnifying_glass(double x)
+{
+ double y = magnifying_glass(x);
+ double min_y = magnifying_glass(MIN_X);
+ double max_y = magnifying_glass(MAX_X);
+ return (y - min_y) * (MAX_X - MIN_X) / (max_y - min_y) + MIN_X;
+}
+#endif /* COMPRESS_PITCH_DISPLAY */
+
+double find_display_pos(double freq)
+{
+ double linear_pos = find_linear_pos(freq);
+#if COMPRESS_PITCH_DISPLAY
+ return normalized_magnifying_glass(linear_pos);
+#else
+ return linear_pos;
+#endif
+}
+