summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/unheard/midi_test.clj52
1 files changed, 39 insertions, 13 deletions
diff --git a/src/unheard/midi_test.clj b/src/unheard/midi_test.clj
index cbf3d5a..bcfde3c 100644
--- a/src/unheard/midi_test.clj
+++ b/src/unheard/midi_test.clj
@@ -3,24 +3,50 @@
[hyperfiddle.rcf :refer [tests]])
(:import [javax.sound.midi ShortMessage]))
-(defn test-msg [cmd ch d1 d2]
+(defn short-message [cmd ch d1 d2]
(ShortMessage. cmd ch d1 d2))
(tests "short-message->notes"
- (let [msgs (into [] (map (fn [[cmd d1]] (test-msg cmd 0 d1 9))
- [[ShortMessage/NOTE_ON 1]
- [ShortMessage/CONTROL_CHANGE 1]
- [ShortMessage/NOTE_ON 2]
- [ShortMessage/NOTE_OFF 2]
- [ShortMessage/NOTE_OFF 1]
- [ShortMessage/NOTE_ON 3]
- [ShortMessage/NOTE_ON 4]]))]
+ (let [msgs
+ [(short-message ShortMessage/NOTE_ON 0 1 100)
+ ;; Irrelevant messages don't appear
+ (short-message ShortMessage/CONTROL_CHANGE 0 1 100)
+ (short-message ShortMessage/NOTE_ON 0 2 100)
+ ;; Notes are removed
+ (short-message ShortMessage/NOTE_OFF 0 2 100)
+ (short-message ShortMessage/NOTE_OFF 0 1 100)
+ (short-message ShortMessage/NOTE_ON 0 3 100)
+ (short-message ShortMessage/NOTE_ON 0 4 100)
+ ;; Specifying channel works
+ (short-message ShortMessage/NOTE_ON 1 1 100)
+ (short-message ShortMessage/NOTE_ON 1 2 100)
+ ;; All notes off works
+ (short-message ShortMessage/CONTROL_CHANGE 0 123 0)
+ (short-message ShortMessage/CONTROL_CHANGE 1 123 0)]]
+
(into []
(transduce
sut/short-message->notes
conj
[]
- (conj
- msgs
- (ShortMessage. ShortMessage/CONTROL_CHANGE 0 123 0))))
- := [#{1} #{1 2} #{1} #{} #{3} #{4 3} #{}]))
+ msgs))
+ := [{0 {1 100}}
+ {0 {1 100
+ 2 100}}
+ {0 {1 100}}
+ {0 {}}
+ {0 {3 100}}
+ {0 {3 100
+ 4 100}}
+ {0 {3 100
+ 4 100}
+ 1 {1 100}}
+ {0 {3 100
+ 4 100}
+ 1 {1 100
+ 2 100}}
+ {0 {}
+ 1 {1 100
+ 2 100}}
+ {0 {}
+ 1 {}}]))