comparison clojure/com/aurellem/run/music.clj @ 455:1c10fa8366a7

synchronized pony song.
author Robert McIntyre <rlm@mit.edu>
date Thu, 03 May 2012 10:28:05 -0500
parents bf87b87a4ad7
children 9c192737034d
comparison
equal deleted inserted replaced
454:bf87b87a4ad7 455:1c10fa8366a7
9 (:import java.io.File)) 9 (:import java.io.File))
10 10
11 (def third-kind 11 (def third-kind
12 (File. "/home/r/proj/midi/third-kind.mid")) 12 (File. "/home/r/proj/midi/third-kind.mid"))
13 13
14 (def pony "/home/r/proj/vba-clojure/music/pony-title.mid") 14 (def pony
15 (File. "/home/r/proj/vba-clojure/music/pony-title.mid"))
16
17 (def sync-test
18 (File. "/home/r/proj/vba-clojure/music/sync-test.mid"))
19
15 20
16 (defn raw-midi-text [#^File midi-file] 21 (defn raw-midi-text [#^File midi-file]
17 (:out 22 (:out
18 (clojure.java.shell/sh 23 (clojure.java.shell/sh
19 "midicsv" 24 "midicsv"
449 (:volume note-event) 454 (:volume note-event)
450 (int (* (:duration note-event) 0x100)))) 455 (int (* (:duration note-event) 0x100))))
451 notes-with-silence))) 456 notes-with-silence)))
452 457
453 (defn midi->mini-midi [#^File midi-file] 458 (defn midi->mini-midi [#^File midi-file]
454 {:track-1 (flatten (midi-track->mini-midi midi-file 1)) 459 {:track-1 (flatten (midi-track->mini-midi midi-file 0))
455 :track-2 (flatten (midi-track->mini-midi midi-file 2))}) 460 :track-2 (flatten (midi-track->mini-midi midi-file 1))})
456 461
457 (defn play-midi [#^File midi-file] 462 (defn play-midi [#^File midi-file]
458 (let [track-1-target 0xA000 463 (let [track-1-target 0xA000
459 track-2-target 0xB000 464 track-2-target 0xB000
460 program-target 0xC000 465 program-target 0xC000
466 (set-memory-range track-2-target long-silence) 471 (set-memory-range track-2-target long-silence)
467 (set-memory-range track-1-target (:track-1 mini-midi)) 472 (set-memory-range track-1-target (:track-1 mini-midi))
468 (set-memory-range track-2-target (:track-2 mini-midi)) 473 (set-memory-range track-2-target (:track-2 mini-midi))
469 (set-memory-range program-target (music-kernel)) 474 (set-memory-range program-target (music-kernel))
470 (PC! program-target)))) 475 (PC! program-target))))
471
472
473
474 476
475 (def C4 (partial note-codes 261.63)) 477 (def C4 (partial note-codes 261.63))
476 (def D4 (partial note-codes 293.66)) 478 (def D4 (partial note-codes 293.66))
477 (def E4 (partial note-codes 329.63)) 479 (def E4 (partial note-codes 329.63))
478 (def F4 (partial note-codes 349.23)) 480 (def F4 (partial note-codes 349.23))