-
Notifications
You must be signed in to change notification settings - Fork 27
/
test_midi.ml
35 lines (31 loc) · 1.12 KB
/
test_midi.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(*---------------------------------------------------------------------------
Copyright (c) 2020 The brr programmers. All rights reserved.
SPDX-License-Identifier: ISC
---------------------------------------------------------------------------*)
open Brr
open Fut.Result_syntax
open Brr_webmidi
let test log =
Fut.map (Console.log_if_error ~use:()) @@
let opts = Midi.Access.opts ~sysex:true () in
let* a = Midi.Access.of_navigator ~opts G.navigator in
log El.[txt' "Enumerating IO…"];
let log_input mi () =
Console.(log [mi]);
log El.[txt' "Input: "; txt (Midi.Port.name (Midi.Input.as_port mi))]
in
let log_output mo () =
Console.(log [mo]);
log El.[txt' "Output: "; txt (Midi.Port.name (Midi.Output.as_port mo))]
in
let () = Midi.Access.inputs a log_input () in
let () = Midi.Access.outputs a log_output () in
Fut.ok ()
let main () =
let h1 = El.h1 [El.txt' "Web MIDI test"] in
let log_view = El.ol [] in
let log cs = El.append_children log_view [El.li cs] in
let children = [h1; log_view] in
El.set_children (Document.body G.document) children;
test log
let () = ignore (main ())