-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.nim
64 lines (45 loc) · 1.16 KB
/
test.nim
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# compile and run> nim c -r test.nim
# Code test.nim
import rtmidic, times , os
var midiin: RtMidiInPtr
var midiout: RtMidiOutPtr
midiin = rtmidi_in_create_default()
midiout = rtmidi_out_create_default()
var device: RtMidiPtr
var portsin = rtmidi_get_port_count (midiin)
var portsout = rtmidi_get_port_count (midiout)
echo portsin
echo portsout
var port: cstring
echo ""
echo "Output ports "
var name: cstring
for i in 0 ..< portsout :
port = rtmidi_get_port_name(midiout, i)
echo port
if i == 0 :
name = port
echo name
echo ""
echo "Input ports"
for i in 0 ..< portsin :
port = rtmidi_get_port_name(midiin, i)
echo port
rtmidi_open_port(midiout, 0, name)
var msg: array[3, cuchar]
var p: ptr cuchar = addr(msg[0])
msg[0] = 144.cuchar
msg[1] = 64.cuchar
msg[2] = 90.cuchar
var rta:cint
var leng : cint
leng = 3
rta = rtmidi_out_send_message(midiout, p , leng)
sleep(1500)
# Note Off: 128, 64, 40
msg[0] = 128.cuchar
msg[1] = 64.cuchar
msg[2] = 40.cuchar
rta = rtmidi_out_send_message(midiout, p, leng)
rtmidi_close_port(midiout)
rtmidi_out_free(midiout)