Mercurial > vba-clojure
view clojure/com/aurellem/run/sound.clj @ 536:c2ee7222a3c4
investigating a problem with bad sound when writing RAM with bootstrapping program
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 25 Jun 2012 14:23:16 -0500 |
parents | 8d3177d19d5f |
children |
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)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 (dorun24 (for [y (range n)]25 (do (step)26 (.process writer27 (sound-bytes)28 gb-sound-format))))29 (.cleanup writer)30 (Thread/sleep 1000)31 (clojure.java.shell/sh32 "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))