-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmidiinput.py
More file actions
38 lines (24 loc) · 860 Bytes
/
midiinput.py
File metadata and controls
38 lines (24 loc) · 860 Bytes
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
from rx.subjects import Subject
from rx.concurrency import PyGameScheduler
import pygame
from pygame import midi as pygame_midi
from midis2events import midis2events
#scheduler = PyGameScheduler()
#midi_events = Subject()
#midi_events.observe_on(scheduler).subscribe(on_next, on_error=on_error)
pygame.init()
pygame.font.init()
pygame_midi.init()
print("Found {} midi devices".format(pygame_midi.get_count()))
for i in range(pygame_midi.get_count()):
print("#{}: {}".format(i, pygame_midi.get_device_info(i)))
midi_input_id = pygame_midi.get_default_input_id()
midi_input = pygame_midi.Input(midi_input_id)
print("Using input #{}".format(midi_input_id))
while True:
if not midi_input.poll():
continue
events = midis2events(midi_input.read(40), midi_input_id)
for event in events:
print(event)
#scheduler.run()