我需要在运行Raspbian的Raspberry Pi 3上使用虚拟MIDI线缆(或端口)连接两个MIDI程序,就像在Windows上使用loopMIDI一样。 (https://www.tobias-erichsen.de/software/loopmidi.html)
我知道必须有一种方法可以在PI上使用alsa或其他常见系统创建虚拟端口,我只是无法找到特定的信息/指令。
答案 0 :(得分:0)
您可以使用Jack。安装后,在终端中启动Jack:
jack_control start
Python示例(需要JACKClient):
import jack
midiInBuffer = []
midiOutBuffer = []
client = jack.Client('jack')
midi_in = client.midi_inports.register('midi_in)
midi_out = client.midi_outports.register('midi_out')
@client.set_process_callback
def process(frames):
midi_out.clear_buffer()
if (len(midiOutBuffer)):
for msg in midiOutBuffer:
midi_out.write_midi_event(0, msg)
print('MIDI sent = ', msg)
midiOutBuffer.clear()
for offset, data in midi_in.incoming_midi_events():
msg = struct.unpack('3B', data)
midiInBuffer.append(msg)
print('MIDI rcvd = ', msg)
client.activate()
print(client.midi_inports)
print(client.midi_outports)
# forward all incoming messages from midi_in to midi_out
while True:
for msg in midiInBuffer
midiOutBuffer.append(msg)
print('MIDI fwd = ', msg)
midiInBuffer.clear()
现在使用jack:midi_out端口将MIDI消息从一个MIDI程序发送到另一个MIDI消息,并从jack:midi_in端口读取另一个MIDI程序中的MIDI消息。