Mercurial > vba-clojure
annotate clojure/com/aurellem/run/sound.clj @ 606:47572d444485
final video rendered.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 02 Sep 2012 23:44:22 -0500 |
parents | 8d3177d19d5f |
children |
rev | line source |
---|---|
rlm@523 | 1 (ns com.aurellem.run.sound |
rlm@523 | 2 (:use (com.aurellem.gb saves gb-driver util constants |
rlm@523 | 3 items vbm characters money |
rlm@523 | 4 rlm-assembly)) |
rlm@523 | 5 (:use (com.aurellem.run util music title save-corruption |
rlm@523 | 6 bootstrap-0 bootstrap-1)) |
rlm@523 | 7 (:require clojure.string) |
rlm@523 | 8 (:import [com.aurellem.gb.gb_driver SaveState]) |
rlm@523 | 9 (:import java.awt.image.BufferedImage) |
rlm@525 | 10 (:import java.io.File) |
rlm@525 | 11 (:import com.aurellem.gb.WaveWriter)) |
rlm@523 | 12 |
rlm@523 | 13 (defn sound-test [] |
rlm@523 | 14 (step (mid-game)) |
rlm@526 | 15 (println (frequencies (sound-bytes))) |
rlm@523 | 16 (run-moves @current-state (repeat 10 [])) |
rlm@526 | 17 (println (frequencies (sound-bytes)))) |
rlm@523 | 18 |
rlm@526 | 19 (defn record-sound! |
rlm@526 | 20 ([^File target-file state n] |
rlm@526 | 21 (set-state! state) |
rlm@526 | 22 (let [writer (WaveWriter. target-file)] |
rlm@526 | 23 (dorun |
rlm@526 | 24 (for [y (range n)] |
rlm@526 | 25 (do (step) |
rlm@526 | 26 (.process writer |
rlm@526 | 27 (sound-bytes) |
rlm@526 | 28 gb-sound-format)))) |
rlm@526 | 29 (.cleanup writer) |
rlm@526 | 30 (Thread/sleep 1000) |
rlm@526 | 31 (clojure.java.shell/sh |
rlm@526 | 32 "aplay" |
rlm@526 | 33 (.getCanonicalPath target-file)))) |
rlm@526 | 34 ([n] (record-sound! |
rlm@526 | 35 (File. "/home/r/proj/vba-clojure/sounds/test-sound.wav") |
rlm@526 | 36 (play-midi pony-csv) n))) |
rlm@524 | 37 |
rlm@526 | 38 (defn gen-pony! [] |
rlm@526 | 39 (record-sound! |
rlm@526 | 40 (File. user-home "proj/vba-clojure/sounds/pony.wav") |
rlm@526 | 41 (play-midi pony-csv) |
rlm@526 | 42 1800)) |
rlm@525 | 43 |
rlm@526 | 44 (defn gen-regret! [] |
rlm@526 | 45 (record-sound! |
rlm@526 | 46 (File. user-home "proj/vba-clojure/sounds/regret.wav") |
rlm@526 | 47 (play-midi regret-csv) |
rlm@526 | 48 3380)) |
rlm@525 | 49 |
rlm@526 | 50 (defn gen-mother! [] |
rlm@526 | 51 (record-sound! |
rlm@526 | 52 (File. user-home "proj/vba-clojure/sounds/mother.wav") |
rlm@526 | 53 (play-midi mother-csv) |
rlm@526 | 54 2200)) |
rlm@525 | 55 |
rlm@526 | 56 |