Mercurial > vba-clojure
comparison 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 |
comparison
equal
deleted
inserted
replaced
540:7f8030812ac2 | 541:cd557c922cec |
---|---|
583 :voice-2 (midi-track->mini-midi-voice midi-file (nth targets 1)) | 583 :voice-2 (midi-track->mini-midi-voice midi-file (nth targets 1)) |
584 :noise (midi-track->mini-midi-noise midi-file (nth targets 2)) | 584 :noise (midi-track->mini-midi-noise midi-file (nth targets 2)) |
585 :duty (zipmap (map :out duty-info) | 585 :duty (zipmap (map :out duty-info) |
586 (map #(get % :duty 0) duty-info))})) | 586 (map #(get % :duty 0) duty-info))})) |
587 | 587 |
588 (defn midi-bytes [^File midi-file] | 588 (defn midi-bytes |
589 (let [voice-1-target 0xC400 | 589 ([^File midi-file voice-1-target voice-2-target |
590 voice-2-target 0xC800 | 590 noise-target program-target] |
591 noise-target 0xCC00 | 591 (let [mini-midi (midi->mini-midi midi-file) |
592 program-target 0xC000 | 592 long-silence (flatten (note-codes 20 0 3000)) |
593 mini-midi (midi->mini-midi midi-file) | 593 long-noise-silence |
594 long-silence (flatten (note-codes 20 0 3000)) | 594 (interleave (range 20) (repeat 0x00) (repeat 255)) |
595 long-noise-silence | 595 voice-1 (flatten (:voice-1 mini-midi)) |
596 (interleave (range 20) (repeat 0x00) (repeat 255)) | 596 wave-duty-1 ((:duty mini-midi) 0 0) |
597 voice-1 (flatten (:voice-1 mini-midi)) | 597 |
598 wave-duty-1 ((:duty mini-midi) 0 0) | 598 voice-2 (flatten (:voice-2 mini-midi)) |
599 | 599 wave-duty-2 ((:duty mini-midi) 1 0) |
600 voice-2 (flatten (:voice-2 mini-midi)) | 600 |
601 wave-duty-2 ((:duty mini-midi) 1 0) | 601 noise (flatten (:noise mini-midi)) |
602 | 602 kernel (music-kernel |
603 noise (flatten (:noise mini-midi)) | 603 voice-1-target |
604 kernel (music-kernel | 604 voice-2-target |
605 voice-1-target | 605 noise-target |
606 voice-2-target | 606 wave-duty-1 wave-duty-2)] |
607 noise-target | 607 |
608 wave-duty-1 wave-duty-2)] | 608 {:voice-1 {:address voice-1-target |
609 | 609 :data (concat voice-1 long-silence)} |
610 {:voice-1 {:address voice-1-target | 610 :voice-2 {:address voice-2-target |
611 :data (concat voice-1 long-silence)} | 611 :data (concat voice-2 long-silence)} |
612 :voice-2 {:address voice-2-target | 612 :noise {:address noise-target |
613 :data (concat voice-2 long-silence)} | 613 :data (concat noise long-noise-silence)} |
614 :noise {:address noise-target | 614 :kernel {:address program-target |
615 :data (concat noise long-noise-silence)} | 615 :data kernel}})) |
616 :kernel {:address program-target | 616 ([^File midi-file] |
617 :data kernel}})) | 617 (midi-bytes midi-file 0xC400 0xC800 0xCC00 0xC000))) |
618 | 618 |
619 (defn play-midi [^File midi-file] | 619 (defn play-midi [^File midi-file] |
620 (let [bytes (midi-bytes midi-file)] | 620 (let [bytes (midi-bytes midi-file)] |
621 (-> (second (music-base)) | 621 (-> (second (music-base)) |
622 (set-memory-range | 622 (set-memory-range |