changeset 306:2873f50b7291

beginning to work on cry data
author Dylan Holmes <ocsenave@gmail.com>
date Sat, 31 Mar 2012 01:27:46 -0500
parents 7998b1cf18cf
children 872e032949ff
files clojure/com/aurellem/gb/hxc.clj clojure/com/aurellem/music/midi_util.clj
diffstat 2 files changed, 44 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/hxc.clj	Sat Mar 31 00:41:28 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/hxc.clj	Sat Mar 31 01:27:46 2012 -0500
     1.3 @@ -208,6 +208,12 @@
     1.4  
     1.5  
     1.6  
     1.7 +;; http://hax.iimarck.us/topic/581/
     1.8 +(defn hxc-pokedex-cry
     1.9 +  "The pokemon cry data in internal order. List begins at ROM@410B1
    1.10 +  []
    1.11 +
    1.12 +
    1.13  
    1.14  (def hxc-items-raw
    1.15    "The hardcoded names of the items in memory. List begins at
     2.1 --- a/clojure/com/aurellem/music/midi_util.clj	Sat Mar 31 00:41:28 2012 -0500
     2.2 +++ b/clojure/com/aurellem/music/midi_util.clj	Sat Mar 31 01:27:46 2012 -0500
     2.3 @@ -13,6 +13,7 @@
     2.4   (:use (com.aurellem.gb saves util constants gb-driver vbm items assembly characters))
     2.5   (:use (com.aurellem.run title))
     2.6   (:use (com.aurellem.exp pokemon item-bridge))
     2.7 + (:use (com.aurellem.world practice))
     2.8   (:import [com.aurellem.gb.gb_driver SaveState]))
     2.9  
    2.10  
    2.11 @@ -29,12 +30,6 @@
    2.12  
    2.13  
    2.14  
    2.15 -(def midi-play-file
    2.16 -  "Plays the MIDI file at the given location. The MIDI file runs in
    2.17 -the current thread until it finishes or is cancelled."
    2.18 -  (comp midi-play-seq midi-load))
    2.19 -
    2.20 -
    2.21  (defn midi-play-seq
    2.22    "Plays the MIDI Sequence. The MIDI runs in
    2.23  the current thread until it finishes or is cancelled."
    2.24 @@ -56,6 +51,14 @@
    2.25              (finally (.close song))))))
    2.26  
    2.27  
    2.28 +(def midi-play-file
    2.29 +  "Plays the MIDI file at the given location. The MIDI file runs in
    2.30 +the current thread until it finishes or is cancelled."
    2.31 +  (comp midi-play-seq midi-load))
    2.32 +
    2.33 +
    2.34 +
    2.35 +
    2.36  (defn midi-test-1 []
    2.37    (-> (.
    2.38         (midi-load
    2.39 @@ -154,10 +157,18 @@
    2.40        ;;(.add (midi-short 360 [-1 47 0])) ;; system reset = -1
    2.41  
    2.42      sequence
    2.43 -    )))
    2.44 +    ))
    2.45  
    2.46  
    2.47 -  
    2.48 +
    2.49 +
    2.50 +(defn read-memory 
    2.51 +  ([mem start length]
    2.52 +     (take length
    2.53 +           (drop start
    2.54 +                 mem)))
    2.55 +  ([start length]
    2.56 +     (read-memory (rom(root)) start length)))
    2.57  
    2.58  ;;; ROM MUSIC MANIPULATION
    2.59  
    2.60 @@ -203,9 +214,6 @@
    2.61     :trainer-girl 0x7C2EB 
    2.62     :trainer-angry 0x7C2F4
    2.63     })
    2.64 -   
    2.65 -
    2.66 -   })
    2.67  
    2.68  
    2.69  (defn low-high-format
    2.70 @@ -245,30 +253,30 @@
    2.71  
    2.72  
    2.73  
    2.74 -(defn note?
    2.75 -  "Does the given byte correspond to a note?"
    2.76 -  [n]
    2.77 +;; (defn note?
    2.78 +;;   "Does the given byte correspond to a note?"
    2.79 +;;   [n])
    2.80    
    2.81 -(defn parse-ops
    2.82 -  "Consumes the list of opcodes, returning a runnable MIDI Sequence object."
    2.83 -  [ops]
    2.84 -  (
    2.85 -   (fn [midi ops]
    2.86 -     (let [x (first ops)]
    2.87 -       (cond (empty? ops) midi
    2.88 -             (= x 0xDA)
    2.89 -               ;; set tempo (high-low (nth ops 1)(nth ops 2))
    2.90 -             (recur (identity midi) (drop 3 ops))
    2.91 +;; (comment defn parse-ops
    2.92 +;;   "Consumes the list of opcodes, returning a runnable MIDI Sequence object."
    2.93 +;;   [ops]
    2.94 +;;   (
    2.95 +;;    (fn [midi ops]
    2.96 +;;      (let [x (first ops)]
    2.97 +;;        (cond (empty? ops) midi
    2.98 +;;              (= x 0xDA)
    2.99 +;;                ;; set tempo (high-low (nth ops 1)(nth ops 2))
   2.100 +;;              (recur (identity midi) (drop 3 ops))
   2.101               
   2.102 -             (note? x)
   2.103 +;;              (note? x)
   2.104               
   2.105  
   2.106 -             )
   2.107 +;;              )
   2.108  
   2.109 -   (doto (Sequence. (float 30) 15) ;; 30 fps, 15 frames per beat
   2.110 -     (.createTrack))
   2.111 -   ops
   2.112 -   ))
   2.113 +;;    (doto (Sequence. (float 30) 15) ;; 30 fps, 15 frames per beat
   2.114 +;;      (.createTrack))
   2.115 +;;    ops
   2.116 +;;   ))))
   2.117  
   2.118  
   2.119