spectrum_visualiser   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/contrib/spectral_meter.xtm

Implementation

(bind-func spectrum_visualiser 1000000
  (let ((width 1080)
        (height 720)
        (surface (cairo_image_surface_create CAIRO_FORMAT_RGB24
                                             (i64toi32 width) (i64toi32  height)))
  (cr (cairo_create surface))
  (i:i64 0))
    ;; for drawing the frequency markings
    (cairo_select_font_face cr
                         "Helvetica"
                         CAIRO_FONT_SLANT_NORMAL
                         CAIRO_FONT_WEIGHT_NORMAL)
    (cairo_set_font_size cr 20.0)
    (lambda (spectrum:double* nbins)
      (let ((bar_width (i64tod (/ width nbins))))
        (cairo_set_source_rgb cr 0.0 0.0 0.0)
        (cairo_paint_with_alpha cr 0.25)
        (dotimes (i nbins)
          (draw_spectral_bar cr i
                             bar_width
                             (* 20.0 (pref spectrum i))))
        (draw_spectrum_key cr nbins bar_width)
        (cairo_image_surface_get_data surface)))))


Back to Index

Similar Entries