anchor.diff:  (in-package #:qt-fft-viz)
   (named-readtables:in-readtable :qtools)
   
  +(declaim (otpimize (speed 3) (safety 1) (size 0) (debug 0)))
  +
  +(defparameter *fps* 90)
  +
   (define-widget main-window (QMainWindow)
  -  ())
  +  ((media-object :initform nil)
  +   (audio-output :initform nil)))
   
   (define-menu (main-window File)
     (:item ("Open" (ctrl o))
  
positive.code:                                                       "*.mp3"))
           (new-mp3-file (read-mp3-file filename))
           (sduration (mp3-file-duration-in-seconds new-mp3-file))
           (tframes (ceiling (* sduration 30))))
      (setf (slot-value viz-widget 'current-location) 0)
      (setf (slot-value viz-widget 'the-mp3) (copy-mp3-file new-mp3-file))
      (setf (slot-value viz-widget 'song-duration) sduration)
      (setf (slot-value viz-widget 'total-frames) tframes)
      (setf (q+:current-source media-object) (q+:make-phonon-mediasource (uiop:native-namestring filename)))
      (q+:play media-object)
      ))
  
  
  (define-initializer (main-window setup)
    "Set the window title and set the fft-controls to be the central widget."
    (setf (q+:window-title main-window) "Interactive FFT Explorer")
    (setf (q+:central-widget main-window) viz-widget))
  
  (defun main ()
  
negative.code:                                  1.0
                                   (/ width height 1.0)))
               
               (fft-window-size (* 4096 4))
               (win-center (ceiling (max 0 (- (* 44100 (interpolate 0.0 song-duration
                                                          current-location total-frames)) (round (/ fft-window-size 2))))))
  
               (left-fft-data (bordeaux-fft:windowed-fft (mp3-file-left-channel the-mp3) win-center fft-window-size))
               (right-fft-data (bordeaux-fft:windowed-fft (mp3-file-right-channel the-mp3) win-center fft-window-size))
               ;; (frame (generate-frame left-fft-data right-fft-data))
               )
          
          ;; Local functions for mapping logical coordinates to physical coordinates
          (flet (
                 ;; xmapper maps logical x coordinates in the range x-min to x-max to
                 ;; screen coordinates in the range 0 to width
                 (xmapper (x) (map-val (* x-aspect-ratio x) -300.0 300.0 0 width))
  
                 ;; ymapper does the same thing, but for y coordinates
                 (ymapper (y) (map-val (* y-aspect-ratio y) 0.0 200.0 0 height)))
  
            ;; Actual drawing goes here.  In this case, just a line.
              (loop
                 for lft across left-fft-data
                 for rgt across right-fft-data
                 for idx below height
                 do
                   (q+:draw-line painter
                                 (truncate (xmapper (- (abs lft)))) idx
                                 (truncate (xmapper (abs rgt))) idx)))))))
  
  
  ;; Create all of the controls
  