Mercurial > vba-clojure
comparison clojure/com/aurellem/run/music.clj @ 496:a6d060a64246
pixel introspection. but entire image is upside down.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 11 Jun 2012 06:04:25 -0500 |
parents | 346b91ae503a |
children | 2de44c6184ee |
comparison
equal
deleted
inserted
replaced
495:1d81ddd4fa41 | 496:a6d060a64246 |
---|---|
448 | 448 |
449 ;; have: clock-pulses | 449 ;; have: clock-pulses |
450 ;; want: seconds | 450 ;; want: seconds |
451 | 451 |
452 | 452 |
453 (defn silence [length] | 453 (defn silent-note [length] |
454 {:frequency 1 | 454 {:frequency 1 |
455 :duration length | 455 :duration length |
456 :volume 0}) | 456 :volume 0}) |
457 | 457 |
458 (defn commands | 458 (defn commands |
516 silences | 516 silences |
517 (map (fn [note-1 note-2] | 517 (map (fn [note-1 note-2] |
518 (let [note-1-space (- (:time-stamp note-2) | 518 (let [note-1-space (- (:time-stamp note-2) |
519 (:time-stamp note-1)) | 519 (:time-stamp note-1)) |
520 note-1-length (:duration note-1)] | 520 note-1-length (:duration note-1)] |
521 (silence (- note-1-space note-1-length)))) | 521 (silent-note (- note-1-space note-1-length)))) |
522 ;; to handle silence at the beginning. | 522 ;; to handle silence at the beginning. |
523 (concat [(assoc (silence 0) | 523 (concat [(assoc (silent-note 0) |
524 :time-stamp 0)] notes) | 524 :time-stamp 0)] notes) |
525 notes) | 525 notes) |
526 | 526 |
527 notes-with-silence | 527 notes-with-silence |
528 (concat | 528 (concat |
529 (filter (comp not zero? :duration) | 529 (filter (comp not zero? :duration) |
530 (interleave silences notes)) | 530 (interleave silences notes)) |
531 [(silence 3)])] | 531 [(silent-note 3)])] |
532 notes-with-silence)) | 532 notes-with-silence)) |
533 | 533 |
534 (defn midi-track->mini-midi-voice [#^File midi-file track-num] | 534 (defn midi-track->mini-midi-voice [#^File midi-file track-num] |
535 (let [abstract-mini-midi | 535 (let [abstract-mini-midi |
536 (midi-track->abstract-mini-midi midi-file track-num)] | 536 (midi-track->abstract-mini-midi midi-file track-num)] |