47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
"""Send a SysEx ping to FL Studio and check if it arrives."""
|
|
import mido
|
|
import json
|
|
import sys
|
|
import time
|
|
|
|
print("=== FL Studio MCP — Send Ping Test ===")
|
|
|
|
# List ports
|
|
print(f"Inputs: {mido.get_input_names()}")
|
|
print(f"Outputs: {mido.get_output_names()}")
|
|
|
|
# Open FL_MCP 1 output
|
|
out = mido.open_output("FL_MCP 1")
|
|
print("Opened FL_MCP 1 output")
|
|
|
|
# Encode ping command
|
|
payload = json.dumps({"cmd": "ping", "params": {"ts": 1}}).encode("utf-8")
|
|
nibbles = []
|
|
for b in payload:
|
|
nibbles.append((b >> 4) & 0x0F)
|
|
nibbles.append(b & 0x0F)
|
|
|
|
# mido adds F0/F7 automatically, we provide [SYSEX_ID + nibble data]
|
|
msg = mido.Message("sysex", data=bytes([0x7D] + nibbles))
|
|
hex_str = " ".join(f"{b:02X}" for b in msg.bytes())
|
|
print(f"Sending SysEx ({len(msg.bytes())} bytes): {hex_str}")
|
|
out.send(msg)
|
|
print("Sent! Check FL Studio script console for: [FL-MCP] Ping received")
|
|
|
|
# Also try a play command
|
|
time.sleep(0.5)
|
|
payload2 = json.dumps({"cmd": "start_playback", "params": {}}).encode("utf-8")
|
|
nibbles2 = []
|
|
for b in payload2:
|
|
nibbles2.append((b >> 4) & 0x0F)
|
|
nibbles2.append(b & 0x0F)
|
|
msg2 = mido.Message("sysex", data=bytes([0x7D] + nibbles2))
|
|
hex_str2 = " ".join(f"{b:02X}" for b in msg2.bytes())
|
|
print(f"\nSending PLAY SysEx ({len(msg2.bytes())} bytes): {hex_str2}")
|
|
out.send(msg2)
|
|
print("Sent! FL Studio should start playing if controller is loaded.")
|
|
|
|
time.sleep(0.5)
|
|
out.close()
|
|
print("\nDone. Check FL Studio console and transport state.")
|