Mercurial > vba-clojure
view clojure/com/aurellem/run/final_cut.clj @ 530:8d3177d19d5f
added full recording function.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 24 Jun 2012 16:47:18 -0500 |
parents | |
children | c6ad363e36f7 |
line wrap: on
line source
1 (ns com.aurellem.run.final-cut2 (:use (com.aurellem.gb saves gb-driver util constants3 items vbm characters money4 rlm-assembly))5 (:use (com.aurellem.run util sound music title save-corruption6 bootstrap-0 bootstrap-17 ram-display8 ))9 (:require clojure.string)10 (:import [com.aurellem.gb.gb_driver SaveState])11 (:import java.awt.image.BufferedImage)12 (:import java.io.File)13 (:import com.aurellem.gb.WaveWriter))16 (def render-dir (File. user-home "proj/vba-clojure/render"))18 (defn render-files!19 ([^File target-dir initial-state moves]20 (let [ram-map-dir (File. target-dir "ram-map")21 frames-dir (File. target-dir "frames")22 audio-file (File. target-dir "audio.wav")23 _ (.mkdirs ram-map-dir)24 _ (.mkdirs frames-dir)25 wave-writer (WaveWriter. audio-file)26 moves (vec moves)]27 (set-state! initial-state)28 (dorun29 (map30 (fn [index]31 (run-moves @current-state (vector (moves index)))33 ;; record audio34 (.process wave-writer (sound-bytes)35 gb-sound-format)37 ;; write screenshot38 (write-png!39 @current-state40 (File. frames-dir (format "%07d.png" index)))42 ;; write ram-image43 (write-ram-image!44 @current-state45 (File. ram-map-dir (format "%07d.png" index))))46 (range (count moves))))47 (.cleanup wave-writer)))48 ([initial-state moves]49 (render-files! render-dir initial-state moves))50 ([moves]51 (render-files! (root) moves)))