diff --git a/padeditor/device.py b/padeditor/device.py index 6da4708..ba3884f 100644 --- a/padeditor/device.py +++ b/padeditor/device.py @@ -103,8 +103,9 @@ class Link: self.midiout.open_port(index) def close(self) -> None: - self.midiout.close_port() - self.midiin.close_port() + for port in (self.midiout, self.midiin): + port.close_port() + port.delete() def read(self, address: int, size: int, memory: int = MEM_PRESET) -> bytes: reply = transact(self.midiout, self.midiin, read_request(address, size, memory), expect=CMD_READ) @@ -145,7 +146,7 @@ def _port_names(kind: str) -> list[str]: try: return list(probe.get_ports()) finally: - del probe + probe.delete() def read_port_names() -> list[str]: @@ -309,6 +310,7 @@ def _listen_cc(rtmidi, port_name: str, listen: float) -> list[tuple[int, int, in found.append((data[0] & 0x0F, data[1], data[2])) finally: midiin.close_port() + midiin.delete() return found