```python from PySide6.QtCore import * from PySide6.QtGui import * from PySide6.QtWidgets import * from rtmidi import MidiIn, MidiOut import sys import random from rtmidi import MidiIn, MidiOut from time import sleep from datetime import datetime now = lambda: datetime.now().timestamp() app = QApplication([]) # Define Widgets class T(QTableWidget): def __init__(self): super().__init__() self.data = {} self.setRows(0) self.setCols(2) self.setHorizontalHeaderLabels(["i","x","y","z"]) self.populate() def setRows(self,nrows): self.nrows = nrows self.setRowCount(nrows) def setCols(self,ncols): self.ncols = ncols self.setColumnCount(ncols) def addcc(self,cc,value): n = now() self.data[cc] = (value,n) self.populate() def populate(self): normalfont = QFont("Arial",14) boldfont = QFont("Arial",14,QFont.Bold) ks = list(sorted(self.data.keys())) self.setRows(len(ks)) t = now() for i,n in enumerate(ks): (v,when) = self.data[n] print(i,n,t,when,t-when) if t - when > 1: color = QColor.fromRgb(0,0,0) brush = QBrush(color) font = boldfont else: color = QColor.fromRgb(255,0,0) brush = QBrush(color) font = normalfont ni = QTableWidgetItem(str(n)) vi = QTableWidgetItem(str(v)) ni.setFont(font) vi.setFont(font) ni.setForeground(color) vi.setForeground(color) self.setItem(i,0,ni) self.setItem(i,1,vi) class MidiMix: def __init__(self,table): midiin = MidiIn() self.midiin = midiin self.table = table in_name_to_number = { midiin.get_port_name(i):i for i in range(midiin.get_port_count()) } in_matches = lambda t: [ x for x in in_name_to_number if t.lower() in x.lower() ] in_matches_idx = lambda t: [ midiin_name_to_number[x] for x in in_matches(t) ] in_ports = in_matches("midi mix") if len(in_ports) > 1: raise Exception("Multiple ports found") if len(in_ports) == 0: raise Exception("No ports found") midiin.set_callback(self.callback) if len(in_ports) > 0: midiin.open_port(in_name_to_number[in_ports[0]]) def callback(self,msg,*xs): msg, ts = msg n, v = msg[1:3] print(n,v) self.table.addcc(n,v) def __del__(self): self.midiin.close_port() # Instantiate Widgets table = T() midimix = MidiMix(table) table.resize(400,800) table.show() # Loader def main(): exit(app.exec()) if __name__ == "__main__": main() ```