;; draw the frequency markins on the spectral meter
(bind-func draw_spectrum_key
(let ((num_ticks:i64 8)
(str_buf:i8* (alloc 100))
(i:i64 0))
(lambda (cr nbins bar_width)
(cairo_set_source_rgb cr 1.0 1.0 1.0)
(dotimes (i nbins)
(if (= (modulo i (/ nbins num_ticks)) 2)
(let ((freq (* 22050.0 (/ (i64tod i) (i64tod nbins)))))
(cairo_move_to cr (- (* bar_width (i64tod i)) 30.0) 300.0)
(if (< freq 1000.0)
(sprintf str_buf "%3.0fHz" freq)
(sprintf str_buf "%3.1fkHz" (/ freq 1000.0)))
(cairo_show_text cr str_buf)))))))