post   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/external/spectrogram.xtm

Implementation

(bind-func post ;;:XTMRENDERCB
  (let ((redfill (NVGcolor 1.0 0.0 0.0 0.5))
        (greenfill (NVGcolor 0.0 1.0 0.0 0.5))
        (bgfill (NVGcolor 0.0 0.0 0.0 1.0))
        (stroke (NVGcolor 0.0 0.0 1.0 0.5))
        (colour:|4,float|* (alloc))
        (dl:Complexf* (dsp.left))
        (dr:Complexf* (dsp.left))
        (t 0))
;        (clear_color:xtm_color* (alloc)))
;    (vguRect path 0. 0. 3.0 1.0)
    (lambda () ;;frame shader m v p data)
      (let ((i:float 0.0)
            (incr (/ width 200.)))
        (nvgBeginFrame vg (convert width) (convert height) pixel_ratio)
        (nvgResetTransform vg)
        (nvgFillColor vg bgfill)
        (nvgBeginPath vg)
        (nvgRect vg 0. 0. width height)
        (nvgFill vg)
        (dotimes (i 200.0)
          (nvgResetTransform vg)
          (nvgBeginPath vg)
          (nvgFillColor vg redfill)
          (nvgRect vg (convert (* incr i)) 0.0 3.0 (* 30. (Complex_mag (pref dl (ftoi64 i)))))
          (nvgFill vg)
          (nvgBeginPath vg)
          (nvgFillColor vg greenfill)
          (nvgRect vg (convert (* incr i)) height 3.0 (* -30. (Complex_mag (pref dr (ftoi64 i)))))
          (nvgFill vg))
        (nvgEndFrame vg)
        ;; (xtm_vg_print_error)
        void))))


Back to Index

Similar Entries