diff clojure/com/aurellem/music/midi_util.clj @ 306:2873f50b7291

beginning to work on cry data
author Dylan Holmes <ocsenave@gmail.com>
date Sat, 31 Mar 2012 01:27:46 -0500
parents 5b59c6f17cd5
children e6a5dfd31230
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/music/midi_util.clj	Sat Mar 31 00:41:28 2012 -0500
     1.2 +++ b/clojure/com/aurellem/music/midi_util.clj	Sat Mar 31 01:27:46 2012 -0500
     1.3 @@ -13,6 +13,7 @@
     1.4   (:use (com.aurellem.gb saves util constants gb-driver vbm items assembly characters))
     1.5   (:use (com.aurellem.run title))
     1.6   (:use (com.aurellem.exp pokemon item-bridge))
     1.7 + (:use (com.aurellem.world practice))
     1.8   (:import [com.aurellem.gb.gb_driver SaveState]))
     1.9  
    1.10  
    1.11 @@ -29,12 +30,6 @@
    1.12  
    1.13  
    1.14  
    1.15 -(def midi-play-file
    1.16 -  "Plays the MIDI file at the given location. The MIDI file runs in
    1.17 -the current thread until it finishes or is cancelled."
    1.18 -  (comp midi-play-seq midi-load))
    1.19 -
    1.20 -
    1.21  (defn midi-play-seq
    1.22    "Plays the MIDI Sequence. The MIDI runs in
    1.23  the current thread until it finishes or is cancelled."
    1.24 @@ -56,6 +51,14 @@
    1.25              (finally (.close song))))))
    1.26  
    1.27  
    1.28 +(def midi-play-file
    1.29 +  "Plays the MIDI file at the given location. The MIDI file runs in
    1.30 +the current thread until it finishes or is cancelled."
    1.31 +  (comp midi-play-seq midi-load))
    1.32 +
    1.33 +
    1.34 +
    1.35 +
    1.36  (defn midi-test-1 []
    1.37    (-> (.
    1.38         (midi-load
    1.39 @@ -154,10 +157,18 @@
    1.40        ;;(.add (midi-short 360 [-1 47 0])) ;; system reset = -1
    1.41  
    1.42      sequence
    1.43 -    )))
    1.44 +    ))
    1.45  
    1.46  
    1.47 -  
    1.48 +
    1.49 +
    1.50 +(defn read-memory 
    1.51 +  ([mem start length]
    1.52 +     (take length
    1.53 +           (drop start
    1.54 +                 mem)))
    1.55 +  ([start length]
    1.56 +     (read-memory (rom(root)) start length)))
    1.57  
    1.58  ;;; ROM MUSIC MANIPULATION
    1.59  
    1.60 @@ -203,9 +214,6 @@
    1.61     :trainer-girl 0x7C2EB 
    1.62     :trainer-angry 0x7C2F4
    1.63     })
    1.64 -   
    1.65 -
    1.66 -   })
    1.67  
    1.68  
    1.69  (defn low-high-format
    1.70 @@ -245,30 +253,30 @@
    1.71  
    1.72  
    1.73  
    1.74 -(defn note?
    1.75 -  "Does the given byte correspond to a note?"
    1.76 -  [n]
    1.77 +;; (defn note?
    1.78 +;;   "Does the given byte correspond to a note?"
    1.79 +;;   [n])
    1.80    
    1.81 -(defn parse-ops
    1.82 -  "Consumes the list of opcodes, returning a runnable MIDI Sequence object."
    1.83 -  [ops]
    1.84 -  (
    1.85 -   (fn [midi ops]
    1.86 -     (let [x (first ops)]
    1.87 -       (cond (empty? ops) midi
    1.88 -             (= x 0xDA)
    1.89 -               ;; set tempo (high-low (nth ops 1)(nth ops 2))
    1.90 -             (recur (identity midi) (drop 3 ops))
    1.91 +;; (comment defn parse-ops
    1.92 +;;   "Consumes the list of opcodes, returning a runnable MIDI Sequence object."
    1.93 +;;   [ops]
    1.94 +;;   (
    1.95 +;;    (fn [midi ops]
    1.96 +;;      (let [x (first ops)]
    1.97 +;;        (cond (empty? ops) midi
    1.98 +;;              (= x 0xDA)
    1.99 +;;                ;; set tempo (high-low (nth ops 1)(nth ops 2))
   1.100 +;;              (recur (identity midi) (drop 3 ops))
   1.101               
   1.102 -             (note? x)
   1.103 +;;              (note? x)
   1.104               
   1.105  
   1.106 -             )
   1.107 +;;              )
   1.108  
   1.109 -   (doto (Sequence. (float 30) 15) ;; 30 fps, 15 frames per beat
   1.110 -     (.createTrack))
   1.111 -   ops
   1.112 -   ))
   1.113 +;;    (doto (Sequence. (float 30) 15) ;; 30 fps, 15 frames per beat
   1.114 +;;      (.createTrack))
   1.115 +;;    ops
   1.116 +;;   ))))
   1.117  
   1.118  
   1.119