Mercurial > vba-clojure
annotate clojure/com/aurellem/run/sound.clj @ 527:8960150ec761
remove print statement.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 24 Jun 2012 13:36:09 -0500 |
parents | 2620d6318e8d |
children | 8d3177d19d5f |
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@526 | 11 |
rlm@525 | 12 (:import com.aurellem.gb.WaveWriter)) |
rlm@523 | 13 |
rlm@523 | 14 (defn sound-test [] |
rlm@523 | 15 (step (mid-game)) |
rlm@526 | 16 (println (frequencies (sound-bytes))) |
rlm@523 | 17 (run-moves @current-state (repeat 10 [])) |
rlm@526 | 18 (println (frequencies (sound-bytes)))) |
rlm@523 | 19 |
rlm@526 | 20 (defn record-sound! |
rlm@526 | 21 ([^File target-file state n] |
rlm@526 | 22 (set-state! state) |
rlm@526 | 23 (let [writer (WaveWriter. target-file)] |
rlm@526 | 24 (dorun |
rlm@526 | 25 (for [y (range n)] |
rlm@526 | 26 (do (step) |
rlm@526 | 27 (.process writer |
rlm@526 | 28 (sound-bytes) |
rlm@526 | 29 gb-sound-format)))) |
rlm@526 | 30 (.cleanup writer) |
rlm@526 | 31 (Thread/sleep 1000) |
rlm@526 | 32 (clojure.java.shell/sh |
rlm@526 | 33 "aplay" |
rlm@526 | 34 (.getCanonicalPath target-file)))) |
rlm@526 | 35 ([n] (record-sound! |
rlm@526 | 36 (File. "/home/r/proj/vba-clojure/sounds/test-sound.wav") |
rlm@526 | 37 (play-midi pony-csv) n))) |
rlm@524 | 38 |
rlm@526 | 39 (defn gen-pony! [] |
rlm@526 | 40 (record-sound! |
rlm@526 | 41 (File. user-home "proj/vba-clojure/sounds/pony.wav") |
rlm@526 | 42 (play-midi pony-csv) |
rlm@526 | 43 1800)) |
rlm@525 | 44 |
rlm@526 | 45 (defn gen-regret! [] |
rlm@526 | 46 (record-sound! |
rlm@526 | 47 (File. user-home "proj/vba-clojure/sounds/regret.wav") |
rlm@526 | 48 (play-midi regret-csv) |
rlm@526 | 49 3380)) |
rlm@525 | 50 |
rlm@526 | 51 (defn gen-mother! [] |
rlm@526 | 52 (record-sound! |
rlm@526 | 53 (File. user-home "proj/vba-clojure/sounds/mother.wav") |
rlm@526 | 54 (play-midi mother-csv) |
rlm@526 | 55 2200)) |
rlm@525 | 56 |
rlm@526 | 57 |