【发布时间】:2018-11-27 03:41:39
【问题描述】:
我正在使用 Mido (https://mido.readthedocs.io/en/latest/) 在 Python 中接收 Midi 消息。 我希望能够记录每次有新输入时收到的消息数量。
问题:
如何将所有输入包装在一个列表中?
然后如何将新的输入项附加到列表中?
当该列表不断变化时,我如何计算该列表中的项目数?
class MyThread(threading.Thread):
def run(self):
for msg in inport:
print msg
m = MyThread()
m.start()
这会产生如下输出:
control_change channel=0 control=16 value=1 time=0
control_change channel=0 control=16 value=2 time=0
control_change channel=0 control=16 value=3 time=0
control_change channel=0 control=16 value=4 time=0
control_change channel=0 control=16 value=5 time=0
control_change channel=0 control=16 value=6 time=0
control_change channel=0 control=16 value=7 time=0
【问题讨论】: