;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;

;;  FILTER EXAMPLE

;;

;;  This example shows how real time effects can be applied

;;

;;  A complete list of filters and filter parameters can

;;  be found in apples "Core Image Programming Guide".

;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(define canvas (gfx:make-canvas))

(define movie (gfx:load-movie "/tmp/myfilm.mov"))

(define lgth (- (gfx:get-movie-duration movie) 1.0))

(define frame-length (* *second* 0.1))


;; print a complete list of filters installed on the users machine

(gfx:print-filters)


;; define a bloom filter

(define bloom (gfx:make-filter "CIBloom"))

(print bloom)

;; set filter parameter

(gfx:set-filter-param bloom "inputIntensity" 3.0)


(define loop

   (lambda (time movie-time)

      (let* ((image (gfx:get-movie-frame movie movie-time))

             (filtered-image (gfx:apply-filter bloom image)))

         (gfx:draw-image time canvas filtered-image 1.0)

         (set! time (+ time frame-length))

         (objc:release time image filtered-image)

         (if (> movie-time lgth)

             (callback (- time 4000) 'loop time 0.0)

             (callback (- time 4000) 'loop time (+ movie-time 0.1))))))


(loop (now) 0.0)