Mercurial > vba-clojure
diff clojure/com/aurellem/run/music.clj @ 541:cd557c922cec
working on basic choreo.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 25 Jun 2012 15:32:16 -0500 |
parents | 04f61ade7879 |
children | b69a3dba8045 |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/run/music.clj Mon Jun 25 15:08:52 2012 -0500 1.2 +++ b/clojure/com/aurellem/run/music.clj Mon Jun 25 15:32:16 2012 -0500 1.3 @@ -585,36 +585,36 @@ 1.4 :duty (zipmap (map :out duty-info) 1.5 (map #(get % :duty 0) duty-info))})) 1.6 1.7 -(defn midi-bytes [^File midi-file] 1.8 - (let [voice-1-target 0xC400 1.9 - voice-2-target 0xC800 1.10 - noise-target 0xCC00 1.11 - program-target 0xC000 1.12 - mini-midi (midi->mini-midi midi-file) 1.13 - long-silence (flatten (note-codes 20 0 3000)) 1.14 - long-noise-silence 1.15 - (interleave (range 20) (repeat 0x00) (repeat 255)) 1.16 - voice-1 (flatten (:voice-1 mini-midi)) 1.17 - wave-duty-1 ((:duty mini-midi) 0 0) 1.18 +(defn midi-bytes 1.19 + ([^File midi-file voice-1-target voice-2-target 1.20 + noise-target program-target] 1.21 + (let [mini-midi (midi->mini-midi midi-file) 1.22 + long-silence (flatten (note-codes 20 0 3000)) 1.23 + long-noise-silence 1.24 + (interleave (range 20) (repeat 0x00) (repeat 255)) 1.25 + voice-1 (flatten (:voice-1 mini-midi)) 1.26 + wave-duty-1 ((:duty mini-midi) 0 0) 1.27 1.28 - voice-2 (flatten (:voice-2 mini-midi)) 1.29 - wave-duty-2 ((:duty mini-midi) 1 0) 1.30 + voice-2 (flatten (:voice-2 mini-midi)) 1.31 + wave-duty-2 ((:duty mini-midi) 1 0) 1.32 1.33 - noise (flatten (:noise mini-midi)) 1.34 - kernel (music-kernel 1.35 - voice-1-target 1.36 - voice-2-target 1.37 - noise-target 1.38 - wave-duty-1 wave-duty-2)] 1.39 - 1.40 - {:voice-1 {:address voice-1-target 1.41 - :data (concat voice-1 long-silence)} 1.42 - :voice-2 {:address voice-2-target 1.43 - :data (concat voice-2 long-silence)} 1.44 - :noise {:address noise-target 1.45 - :data (concat noise long-noise-silence)} 1.46 - :kernel {:address program-target 1.47 - :data kernel}})) 1.48 + noise (flatten (:noise mini-midi)) 1.49 + kernel (music-kernel 1.50 + voice-1-target 1.51 + voice-2-target 1.52 + noise-target 1.53 + wave-duty-1 wave-duty-2)] 1.54 + 1.55 + {:voice-1 {:address voice-1-target 1.56 + :data (concat voice-1 long-silence)} 1.57 + :voice-2 {:address voice-2-target 1.58 + :data (concat voice-2 long-silence)} 1.59 + :noise {:address noise-target 1.60 + :data (concat noise long-noise-silence)} 1.61 + :kernel {:address program-target 1.62 + :data kernel}})) 1.63 + ([^File midi-file] 1.64 + (midi-bytes midi-file 0xC400 0xC800 0xCC00 0xC000))) 1.65 1.66 (defn play-midi [^File midi-file] 1.67 (let [bytes (midi-bytes midi-file)]