Skip to content

Commit 399194f

Browse files
committed
midi python example
1 parent b57cd06 commit 399194f

File tree

1 file changed

+26
-0
lines changed
  • crates/processing_pyo3/examples

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from processing import *
2+
import random
3+
4+
def setup():
5+
size(800, 600)
6+
7+
# Refresh midi port list, and connect to first one
8+
midi_refresh_ports()
9+
midi_connect(0)
10+
11+
def draw():
12+
background(220)
13+
14+
fill(255, 0, 100)
15+
stroke(1)
16+
stroke_weight(2)
17+
rect(100, 100, 200, 150)
18+
19+
# pick a random note value, and duration value for that note
20+
# then send the midi command
21+
note = random.randit(57,68)
22+
note_duration = random.randit(25, 250)
23+
midi_play_notes(note, note_duration)
24+
25+
# TODO: this should happen implicitly on module load somehow
26+
run()

0 commit comments

Comments
 (0)