view clojure/com/aurellem/run/sound.clj @ 572:58a25fa15176

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