comparison clojure/com/aurellem/run/music.clj @ 434:988f0fda6c93

paramaterized music-step
author Robert McIntyre <rlm@mit.edu>
date Wed, 25 Apr 2012 01:58:44 -0500
parents 985c90ffa1fe
children 3939ad680681
comparison
equal deleted inserted replaced
433:985c90ffa1fe 434:988f0fda6c93
224 ;; 0x18 ;; set frequency-low-bits 224 ;; 0x18 ;; set frequency-low-bits
225 225
226 ;; 0x2A ;; load duration 226 ;; 0x2A ;; load duration
227 ;; ]) 227 ;; ])
228 228
229 (defn music-step [] 229 (defn music-step [sound-base-address]
230 ;; C == current-ticks 230 ;; C == current-ticks
231 ;; A == desired-ticks 231 ;; A == desired-ticks
232 232
233 (flatten 233 (flatten
234 [0xF5 ;; push A 234 [0xF5 ;; push A
247 247
248 ;; if desired-ticks = current ticks 248 ;; if desired-ticks = current ticks
249 ;; go to next note ; set current set ticks to 0. 249 ;; go to next note ; set current set ticks to 0.
250 250
251 0x20 251 0x20
252 (+ (count (do-message)) 2) 252 (+ (count (do-message 0)) 2)
253 253
254 (do-message) 254 (do-message sound-base-address)
255 255
256 0x0E 256 0x0E
257 0x00])) ;; 0->C (current-ticks) 257 0x00])) ;; 0->C (current-ticks)
258
259 (def music-2 0x16)
258 260
259 (defn music-kernel [] 261 (defn music-kernel []
260 (flatten 262 (flatten
261 [;; global initilization section 263 [;; global initilization section
262 (clear-music-registers) 264 (clear-music-registers)
282 0xAF ;; 0->A 284 0xAF ;; 0->A
283 285
284 286
285 287
286 288
287 (music-step) 289 (music-step music-2)
288 0x18 290 0x18
289 (->signed-8-bit (+ (- (count (music-step))) 291 (->signed-8-bit (+ (- (count (music-step 0)))
290 -2))])) 292 -2))]))
291 293
292 (defn frequency-code->frequency 294 (defn frequency-code->frequency
293 [code] 295 [code]
294 (assert (<= 0 code 2047)) 296 (assert (<= 0 code 2047))