-
Notifications
You must be signed in to change notification settings - Fork 30
/
midi-usb-host.mu4
44 lines (30 loc) · 1.17 KB
/
midi-usb-host.mu4
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
36
37
38
39
40
41
42
43
44
| This file is part of muforth: https://muforth.dev/
|
| Copyright 2002-2024 David Frech. (Read the LICENSE for details.)
loading MIDI over USB (host)
| Host-side code to drive the simple MIDI code in
| target/S08/midi-usb-core.mu4.
hex
| : usb ( bmRequest bRequest wValue wIndex wLength 'buffer)
| Since we're using wValue and wIndex to pass an array of four bytes, we
| need an easy way to assemble the two word values - little-endian! -
| from two bytes.
: >setup ( b0 b1 b2 b3 - wValue wIndex)
lohi> push lohi> pop ;
| Commands:
| 0-4f Bye - exit this code and return to chat loop
| 50 Send - send 3 chars over serial port
| 51 Recv - currently UNIMPLEMENTED
( Control writes)
: midi.Bye 40 0 0 0 0 0 usb ;
( Always send 3 bytes!)
: midi.Send ( b0 b1 b2) 0 >setup 2push
40 50 2pop 0 0 usb ;
( Control reads)
: midi.Recv ( len) push
0c0 51 0 0 pop pad usb ;
: midi.Hello ( start the MIDI firmware on the connected device)
@send-midi u.SetPC u.Run ;
| Initially just send byte three times. We'll use it as velocity for
| the PWM. Just to test out the send/recv.
: v ( vel) dup dup midi.Send ;