+ // now from 1K down to 4Hz
+ for (int x = 0; x > -24; --x) {
+ float freq = powf (2.f, x / 3.0) * 1000.f;
+ if (freq >= _fft_end) { continue; }
+ if (freq <= _fft_start) { break; }
+
+ const float pos = currentScaleWidth * logf (freq / _fft_start) / _fft_log_base;
+ const int coord = floor (hl_margin + pos);
+
+ if (x != 0 && coord > overlap) {
+ continue;
+ }
+
+ std::stringstream ss;
+ if (freq >= 10000) {
+ ss << std::setprecision (1) << std::fixed << freq / 1000 << "K";
+ } else if (freq >= 1000) {
+ ss << std::setprecision (2) << std::fixed << freq / 1000 << "K";
+ } else {
+ ss << std::setprecision (0) << std::fixed << freq << "Hz";
+ }
+ layout->set_text (ss.str ());
+ int lw, lh;
+ layout->get_pixel_size (lw, lh);
+ overlap = coord - lw - 3;
+
+ if (coord - lw / 2 < hl_margin + 2) {
+ break;
+ }
+ if (x == 0) {
+ // just get overlap position
+ continue;
+ }
+ if (v_margin / 2 + lh > label_height) {
+ label_height = v_margin / 2 + lh;
+ }
+ window->draw_line (graph_gc, coord, v_margin, coord, height - v_margin - 1);
+ window->draw_layout (white, coord - lw / 2, v_margin / 2, layout);
+ }
+ return label_height;