Skip to content

Commit 63bb85c

Browse files
committed
update midi_simpletest.py from Limor
1 parent 41b021b commit 63bb85c

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

examples/midi_simpletest.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
22
# SPDX-License-Identifier: MIT
3-
43
# simple_test
54
import time
65
import random
@@ -11,23 +10,22 @@
1110
from adafruit_midi.note_on import NoteOn
1211
from adafruit_midi.pitch_bend import PitchBend
1312

14-
midi = adafruit_midi.MIDI(midi_out=usb_midi.ports[1], out_channel=0)
15-
13+
print(usb_midi.ports)
14+
midi = adafruit_midi.MIDI(
15+
midi_in=usb_midi.ports[0], in_channel=0, midi_out=usb_midi.ports[1], out_channel=0
16+
)
1617
print("Midi test")
17-
1818
# Convert channel numbers at the presentation layer to the ones musicians use
1919
print("Default output channel:", midi.out_channel + 1)
20-
print(
21-
"Listening on input channel:",
22-
midi.in_channel + 1 if midi.in_channel is not None else None,
23-
)
24-
20+
print("Listening on input channel:", midi.in_channel + 1)
2521
while True:
2622
midi.send(NoteOn(44, 120)) # G sharp 2nd octave
2723
time.sleep(0.25)
2824
a_pitch_bend = PitchBend(random.randint(0, 16383))
2925
midi.send(a_pitch_bend)
30-
time.sleep(0.25)
3126
# note how a list of messages can be used
3227
midi.send([NoteOff("G#2", 120), ControlChange(3, 44)])
3328
time.sleep(0.5)
29+
msg = midi.receive()
30+
if msg is not None:
31+
print("Received:", msg, "at", time.monotonic())

0 commit comments

Comments
 (0)