comparison 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 (2012-06-24)
parents
children c6ad363e36f7
comparison
equal deleted inserted replaced
529:945c7b500433 530:8d3177d19d5f
1 (ns com.aurellem.run.final-cut
2 (:use (com.aurellem.gb saves gb-driver util constants
3 items vbm characters money
4 rlm-assembly))
5 (:use (com.aurellem.run util sound music title save-corruption
6 bootstrap-0 bootstrap-1
7 ram-display
8 ))
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))
14
15
16 (def render-dir (File. user-home "proj/vba-clojure/render"))
17
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 (dorun
29 (map
30 (fn [index]
31 (run-moves @current-state (vector (moves index)))
32
33 ;; record audio
34 (.process wave-writer (sound-bytes)
35 gb-sound-format)
36
37 ;; write screenshot
38 (write-png!
39 @current-state
40 (File. frames-dir (format "%07d.png" index)))
41
42 ;; write ram-image
43 (write-ram-image!
44 @current-state
45 (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)))
52
53