Mercurial > vba-clojure
view clojure/com/aurellem/run/sound.clj @ 529:945c7b500433
added download script to get needed libraries for Dylan.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 24 Jun 2012 14:57:15 -0500 |
parents | 2620d6318e8d |
children | 8d3177d19d5f |
line wrap: on
line source
1 (ns com.aurellem.run.sound2 (:use (com.aurellem.gb saves gb-driver util constants3 items vbm characters money4 rlm-assembly))5 (:use (com.aurellem.run util music title save-corruption6 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)12 (:import com.aurellem.gb.WaveWriter))14 (defn sound-test []15 (step (mid-game))16 (println (frequencies (sound-bytes)))17 (run-moves @current-state (repeat 10 []))18 (println (frequencies (sound-bytes))))20 (defn record-sound!21 ([^File target-file state n]22 (set-state! state)23 (let [writer (WaveWriter. target-file)]24 (dorun25 (for [y (range n)]26 (do (step)27 (.process writer28 (sound-bytes)29 gb-sound-format))))30 (.cleanup writer)31 (Thread/sleep 1000)32 (clojure.java.shell/sh33 "aplay"34 (.getCanonicalPath target-file))))35 ([n] (record-sound!36 (File. "/home/r/proj/vba-clojure/sounds/test-sound.wav")37 (play-midi pony-csv) n)))39 (defn gen-pony! []40 (record-sound!41 (File. user-home "proj/vba-clojure/sounds/pony.wav")42 (play-midi pony-csv)43 1800))45 (defn gen-regret! []46 (record-sound!47 (File. user-home "proj/vba-clojure/sounds/regret.wav")48 (play-midi regret-csv)49 3380))51 (defn gen-mother! []52 (record-sound!53 (File. user-home "proj/vba-clojure/sounds/mother.wav")54 (play-midi mother-csv)55 2200))