[英]Rtmidi - Ableton Remote Script - How to send MIDI_CC signals from rtmidi to Ableton Python remote script
[英]Sending MIDI file using Python to MAX MSP or Ableton
我有一个输出 MIDI 文件的 Python 代码,我正在尝试将其自动发送到 Ableton(最好)或 MAX MSP,以便我可以进行进一步处理。 到目前为止,我已经尝试了许多建议的解决方案,但都没有奏效,以下是我所做工作的总结:
udpreceive PORT
object 并将其连接到一个消息框(因此我可以看到可能的 output,此处附有屏幕截图)。并且仅作为测试,我尝试通过运行此 [ source ] 向此端口发送文本:
import socket
msgFromClient = "cccc"
bytesToSend = str.encode(msgFromClient)
serverAddressPort = ("127.0.0.1", 1235)
bufferSize = 1024
# Create a UDP socket at client side
UDPClientSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
# Send to server using created UDP socket
UDPClientSocket.sendto(bytesToSend, serverAddressPort)
这里有两个问题:
"cccc"
作为消息时,出现以下错误:udpreceive: OSC Bad message name string: DataAfterAlignedString: Unreasonably long string
Dropping entire message.
这似乎与 MAX MSP 创建 UDP 服务器和 Python 正在尝试连接到 TCP 服务器的事实有关。
再搜索一些,我发现可能是通过将我的 MIDI 文件转换为 OSC(开放声音控制)格式然后发送它,但当前的解决方案都不起作用。 例如这里建议, pyosc
无法安装,给我以下错误:
(base) C:\Users\arash>pip install pyosc
Collecting pyosc
Using cached pyOSC-0.3.5b-5294.tar.gz (33 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [9 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Users\arash\AppData\Local\Temp\pip-install-8zlix12t\pyosc_252847d8985244e1915a8ba3b8a28de0\setup.py", line 5, in <module>
import OSC
File "C:\Users\arash\AppData\Local\Temp\pip-install-8zlix12t\pyosc_252847d8985244e1915a8ba3b8a28de0\OSC.py", line 735
binary = struct.pack('>ll', 0L, 1L)
^
SyntaxError: invalid syntax
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
# from osc import *
from pythonosc.udp_client import SimpleUDPClient
ip = "127.0.0.1"
port = 1235
client = SimpleUDPClient(ip, port) # Create client
client.send_message("home", "hello")
代码终止时没有错误,但在我的 MAX MSP 控制台中没有任何反应。 我怀疑问题可能出在我必须传递给client.send_message()
的地址(第一个参数)上,因为我不确定它是什么。
同样在 Ableton 中,当我尝试接受来自 Python 的 MIDI 输入(更具体地说是MIDI from PythonMIDI1
)时,连接不成功。
如果您能就这个问题帮助我,我将不胜感激。
[编辑:我的 Max 修补程序中的小错误:我应该使用print
object 而不是message
框来打印 output,但问题仍然存在。]
你试过这个吗? 这是另一个选项-> https://pypi.org/project/osc4py3/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.