-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
64 lines (44 loc) · 1.85 KB
/
main.py
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
# /usr/bin/python3
import time
import grid_controller
import grid_view
import grid_model
import looper
import midi_io
import osc_server
import osc_sender
# from pythonosc import udp_client, dispatcher, osc_server
# import osc_interface
def grid_to_midi_mapping(x, y):
return x + y*16
if __name__ == "__main__":
# instantiate Launchpad midi ports
LaunchpadOutput = midi_io.MidiOutput("Launchpad", False)
# AltMidi = midi_io.MidiOutput("Alt-output")
LaunchpadInput = midi_io.MidiInput("Launchpad")
# Instantiate grid model, view, and controller
GridModel = grid_model.Grid(8, 8, 3)
GridView = grid_view.GridView(GridModel, LaunchpadOutput)
GridController = grid_controller.GridController(GridModel, GridView)
# Set the callback for the midi input
LaunchpadInput.set_callback(GridController.midi_to_grid_mapping)
# start osc server
osc_server = osc_server.OSC_Receiver()
# instantiate sooperlooper
LooperOSC_output = osc_sender.OSC_Sender()
SooperLooper = looper.Looper(8, LooperOSC_output, "9981")
osc_server.add_handler("/sloop", SooperLooper.handle_input)
for button in GridModel.grid.keys():
GridModel[button].set_action(LaunchpadOutput.send_messages, [grid_to_midi_mapping(*button), 115])
GridModel[button].set_release(LaunchpadOutput.send_messages, [grid_to_midi_mapping(*button), 0])
for button in GridModel.grid.keys():
GridModel[button].set_action(LaunchpadOutput.send_messages, [grid_to_midi_mapping(*button), 100], mode=1)
GridModel[button].set_release(LaunchpadOutput.send_messages, [grid_to_midi_mapping(*button), 1], mode=1)
while True:
try:
time.sleep(.005)
osc_server.server_thread.join()
except KeyboardInterrupt:
print("exiting")
osc_server.shutdown()
GridView.release_leds()