summaryrefslogtreecommitdiff
path: root/src/unheard/midi_test.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/unheard/midi_test.clj')
-rw-r--r--src/unheard/midi_test.clj67
1 files changed, 22 insertions, 45 deletions
diff --git a/src/unheard/midi_test.clj b/src/unheard/midi_test.clj
index bcfde3c..790cf69 100644
--- a/src/unheard/midi_test.clj
+++ b/src/unheard/midi_test.clj
@@ -3,50 +3,27 @@
[hyperfiddle.rcf :refer [tests]])
(:import [javax.sound.midi ShortMessage]))
-(defn short-message [cmd ch d1 d2]
- (ShortMessage. cmd ch d1 d2))
+(defn short-message [cmd ch d1 d2] (ShortMessage. cmd ch d1 d2))
(tests "short-message->notes"
- (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
- []
- 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 {}}]))
+ (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 [] 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 {}}]))