如何强制 MIDI 设备报告控制状态? [英] How to force a MIDI device to report control status?
问题描述
我正在使用 python-rtmidi 读取带有滑块和旋钮的 MIDI 设备.
I'm using python-rtmidi to read a MIDI device with sliders and knobs.
每当滑块移动或旋钮转动时,我都会收到 CONTROL_CHANGE 事件(这很好用).
I get CONTROL_CHANGE events whenever a slider moves or a knob is turned (this works fine).
但是如何轮询 MIDI 设备以找出程序启动时滑块和旋钮的初始位置?
But how can I poll the MIDI device to find out the initial position of the sliders and knobs when my program starts?
用户没有移动任何东西,所以没有发送 CONTROL_CHANGE 消息.
The user hasn't moved anything, so no CONTROL_CHANGE messages are sent.
(我没有关于 MIDI 设备的任何文档;它是一个 WORLDE Easycontrol 9";我只是想使用标准的 MIDI 消息.)
(I don't have any documentation for the MIDI device; it's a "WORLDE Easycontrol 9"; I'm just trying to use standard MIDI messages.)
此外 - 虽然我引起了您的注意 - 是否有打开/关闭按钮 LED 的标准命令?我曾尝试向按钮的控制器编号(值 0 和 127)发送 CONTROL_CHANGE 命令,但 LED 仅在手动按下按钮时亮起.
Also - while I have your attention - is there a standard command to turn the button LEDs on/off? I've tried sending CONTROL_CHANGE commands to the button's controller number (values 0 and 127), but the LEDs only light when the buttons are manually pushed.
我现有的代码:
import rtmidi
class Midi:
CONTROL_CHANGE = 0xB0
def __init__(self, port=0):
self.midi_in = rtmidi.MidiIn() # gets BUT DOES NOT OPEN a midi input port
self.midi_out = rtmidi.MidiOut()
try:
self.midi_in.open_port(port)
self.midi_out.open_port(port)
self.running = True
except:
self.running = False # in case there was no such MIDI port
def read(self):
if self.running:
event = self.midi_in.get_message()
if event:
return event[0]
return None
def write(self, message):
if self.running:
self.midi_out.send_message(message)
推荐答案
官方 MIDI 规范没有定义读取控件当前状态的机制.但是,许多设备都有特定于供应商的命令来启动批量参数转储.
The official MIDI specifications do not define a mechanism to read the current status of a control. However, many device have vendor-specific commands to start a bulk parameter dump.
是否可以从计算机更改控件是特定于设备的.
Whether controls can be changed from the computer is device specific.
这篇关于如何强制 MIDI 设备报告控制状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!