Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions midimech.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,23 @@ def main():
try:
core = Core()
core()
except SystemExit:
pass
except SystemExit as e:
if e.code != 0:
print(f"midimech exited with code {e.code}")
except:
print(traceback.format_exc())
del core
pygame.midi.quit()
pygame.display.quit()
try:
del core
except:
pass
try:
pygame.midi.quit()
except:
pass
try:
pygame.display.quit()
except:
pass
os._exit(0)
# pygame.quit()

Expand Down
5 changes: 4 additions & 1 deletion src/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from glm import ivec2, vec2, ivec3, vec3

TITLE = "midimech"
# Window title must not exactly match the "midimech" MIDI loopback device name.
# On some Windows setups, SDL fatally terminates the process when the window
# title matches a MIDI device name (case-insensitive). Exact cause unknown.
TITLE = "midimech app"
# FOCUS = False
NOTES = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]
WHOLETONE = True
Expand Down
9 changes: 9 additions & 0 deletions src/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,15 @@ def note_off(self, data, timestamp, width=None, mpe=None, octave=0, transpose=0,

def cb_midi_in(self, data, timestamp, force_channel=None):
"""LinnStrument MIDI Callback"""
if not hasattr(self, 'board'):
return # not fully initialized yet
try:
self._cb_midi_in(data, timestamp, force_channel)
except Exception as e:
print(f"MIDI callback error: {e}")

def _cb_midi_in(self, data, timestamp, force_channel=None):
"""LinnStrument MIDI Callback (inner)"""
# d4 = None
# if len(data)==4:
# d4 = data[3]
Expand Down