diff clojure/com/aurellem/run/music.clj @ 480:91db9d1ce213

added csv files, completed demo :)
author Robert McIntyre <rlm@mit.edu>
date Fri, 04 May 2012 08:55:15 -0500
parents ee000791ab4e
children 221b3fea9221
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/run/music.clj	Fri May 04 08:06:17 2012 -0500
     1.2 +++ b/clojure/com/aurellem/run/music.clj	Fri May 04 08:55:15 2012 -0500
     1.3 @@ -8,12 +8,12 @@
     1.4    (:import [com.aurellem.gb.gb_driver SaveState])
     1.5    (:import java.io.File))
     1.6  
     1.7 -(def third-kind
     1.8 -  (File. "/home/r/proj/midi/third-kind.mid"))
     1.9 -
    1.10  (def pony
    1.11    (File. "/home/r/proj/vba-clojure/music/pony-title.mid"))
    1.12  
    1.13 +(def pony-csv 
    1.14 +  (File. "/home/r/proj/vba-clojure/music/pony-title.csv"))
    1.15 +  
    1.16  (def sync-test
    1.17    (File. "/home/r/proj/vba-clojure/music/sync-test.mid"))
    1.18  
    1.19 @@ -23,12 +23,27 @@
    1.20  (def regret
    1.21    (File. "/home/r/proj/vba-clojure/music/ship-of-regret-and-sleep.mid"))
    1.22  
    1.23 +(def regret-csv
    1.24 +  (File. "/home/r/proj/vba-clojure/music/ship-of-regret-and-sleep.csv"))
    1.25 +
    1.26 +(def mother
    1.27 +  (File. "/home/r/proj/vba-clojure/music/mother.mid"))
    1.28 +
    1.29 +(def mother-csv
    1.30 +  (File. "/home/r/proj/vba-clojure/music/mother.csv"))
    1.31 +
    1.32 +
    1.33  (defn raw-midi-text [#^File midi-file]
    1.34 -  (:out 
    1.35 -   (clojure.java.shell/sh
    1.36 -    "midicsv"
    1.37 -    (.getCanonicalPath midi-file)
    1.38 -    "-")))
    1.39 +  (let [extention (apply str (take-last 3 (.getCanonicalPath
    1.40 +                                           midi-file)))]
    1.41 +    (cond (= "mid" extention)
    1.42 +          (:out 
    1.43 +           (clojure.java.shell/sh
    1.44 +            "midicsv"
    1.45 +            (.getCanonicalPath midi-file)
    1.46 +            "-"))
    1.47 +          (= "csv" extention)
    1.48 +             (slurp midi-file))))
    1.49  
    1.50  (def command-line #"^(\d+), (\d+), ([^,]+)(.*)$")
    1.51  
    1.52 @@ -672,4 +687,16 @@
    1.53       [0xF0
    1.54        0x05])]))
    1.55  
    1.56 +(defn play-pony []
    1.57 +  (run-moves (play-midi pony-csv) (repeat 1800 [])))
    1.58  
    1.59 +(defn play-regret []
    1.60 +  (run-moves (play-midi regret-csv) (repeat 3380 [])))
    1.61 +
    1.62 +(defn play-mother []
    1.63 +  (run-moves (play-midi mother-csv) (repeat 2200 [])))
    1.64 +
    1.65 +(defn demo [] (play-mother) (play-regret) (play-pony))
    1.66 +
    1.67 +
    1.68 +  
    1.69 \ No newline at end of file