;;; THINWHL.CAL
;;;
;;; A CAL program to "thin" pitch wheel data.
;;;
;;; Keeps every N'th pitch wheel event and those whose wheel value is
;;; is -8191, 0, or 8191 (min, center, and max values, respectively).
;;;
;;;

;;; Prolog
(do
  (int N 4)   ; keep every N'th event
  (int i 0)   ; index for moving through

  (getInt N "Keep every Nth wheel event:" 1 100 )
)

;;; Body
(if (== Event.Kind WHEEL)
  (do
    (switch Wheel.Val
      0      NIL       ; If one of these special values,
      -8192  NIL       ; do nothing
      8191   NIL       ;

      Wheel.Val        ;default
        (if (== (% i N) 0)           ; Is it the N'th event?
          (do
             NIL
          )
          (delete)          ; Yes: delete it
          (message "Deleted #" i)   ; Let 'em know how it's going            
        )
    )
    (++ i) ; this counts
  )
  NIL
)

;;; Epilog
NIL


