comparison 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
comparison
equal deleted inserted replaced
479:aa81beeb2500 480:91db9d1ce213
6 bootstrap-0 bootstrap-1)) 6 bootstrap-0 bootstrap-1))
7 (:require clojure.string) 7 (:require clojure.string)
8 (:import [com.aurellem.gb.gb_driver SaveState]) 8 (:import [com.aurellem.gb.gb_driver SaveState])
9 (:import java.io.File)) 9 (:import java.io.File))
10 10
11 (def third-kind
12 (File. "/home/r/proj/midi/third-kind.mid"))
13
14 (def pony 11 (def pony
15 (File. "/home/r/proj/vba-clojure/music/pony-title.mid")) 12 (File. "/home/r/proj/vba-clojure/music/pony-title.mid"))
16 13
14 (def pony-csv
15 (File. "/home/r/proj/vba-clojure/music/pony-title.csv"))
16
17 (def sync-test 17 (def sync-test
18 (File. "/home/r/proj/vba-clojure/music/sync-test.mid")) 18 (File. "/home/r/proj/vba-clojure/music/sync-test.mid"))
19 19
20 (def drum-test 20 (def drum-test
21 (File. "/home/r/proj/vba-clojure/music/drum-test.mid")) 21 (File. "/home/r/proj/vba-clojure/music/drum-test.mid"))
22 22
23 (def regret 23 (def regret
24 (File. "/home/r/proj/vba-clojure/music/ship-of-regret-and-sleep.mid")) 24 (File. "/home/r/proj/vba-clojure/music/ship-of-regret-and-sleep.mid"))
25 25
26 (def regret-csv
27 (File. "/home/r/proj/vba-clojure/music/ship-of-regret-and-sleep.csv"))
28
29 (def mother
30 (File. "/home/r/proj/vba-clojure/music/mother.mid"))
31
32 (def mother-csv
33 (File. "/home/r/proj/vba-clojure/music/mother.csv"))
34
35
26 (defn raw-midi-text [#^File midi-file] 36 (defn raw-midi-text [#^File midi-file]
27 (:out 37 (let [extention (apply str (take-last 3 (.getCanonicalPath
28 (clojure.java.shell/sh 38 midi-file)))]
29 "midicsv" 39 (cond (= "mid" extention)
30 (.getCanonicalPath midi-file) 40 (:out
31 "-"))) 41 (clojure.java.shell/sh
42 "midicsv"
43 (.getCanonicalPath midi-file)
44 "-"))
45 (= "csv" extention)
46 (slurp midi-file))))
32 47
33 (def command-line #"^(\d+), (\d+), ([^,]+)(.*)$") 48 (def command-line #"^(\d+), (\d+), ([^,]+)(.*)$")
34 49
35 (defmulti parse-command :command) 50 (defmulti parse-command :command)
36 51
670 (repeat 685 (repeat
671 500 686 500
672 [0xF0 687 [0xF0
673 0x05])])) 688 0x05])]))
674 689
675 690 (defn play-pony []
691 (run-moves (play-midi pony-csv) (repeat 1800 [])))
692
693 (defn play-regret []
694 (run-moves (play-midi regret-csv) (repeat 3380 [])))
695
696 (defn play-mother []
697 (run-moves (play-midi mother-csv) (repeat 2200 [])))
698
699 (defn demo [] (play-mother) (play-regret) (play-pony))
700
701
702