在 Android 上通过 USB 发送 MIDI 消息

发布于 2025-01-01 16:02:00 字数 330 浏览 4 评论 0原文

我想在android上制作一个应用程序,通过USB将MIDI消息发送到计算机,以便能够控制音乐软件,如Cubase、FL、Reason等...

音乐软件中会自动识别硬件MIDI控制器(例如键盘)在 Windows 上。我猜这是因为他们使用通用MIDI协议,可以被音乐软件直接识别。他们不需要自己的司机。

我希望能够使用我的手机/平板电脑作为 MIDI 控制器,而无需在计算机上安装人员(就像使用硬件控制器一样)。

Android 开发者上有一个演示代码,可以通过 USB 控制导弹发射器玩具。如果我使用相同的技术发送遵循 MIDI 协议的消息,它会像那样工作吗?

预先感谢您的帮助

I would like to make an app on android which sends MIDI messages over USB to a computer to be able to control music softwares such as Cubase, FL, Reason, ect...

Hardware MIDI controllers (e.g Keyboards) are automatically recognized in music software on Windows. I guess it's because they use the universal MIDI protocol which is directly recognized by the music software. They don't need their own driver.

I'd like to be able to use my phone/tablet as a midi controller without having to install staff on the computer (like with hardware controllers).

There's a Demo Code on Android Developers to control a Missile Launcher toy through USB. If I send, using the same technique, messages that follow the MIDI protocol will it work just like that ?

Thank you in advance for your help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

孤君无依 2025-01-08 16:02:00

使用 Android 6.0 (API 23),这现在成为可能 - Android 设备可以充当类兼容(无需驱动程序)的 MIDI 设备。

要切换到 USB-MIDI 模式,用户可以从屏幕顶部向下滑动以访问 USB 模式选择屏幕(如下)。

显示 USB 的屏幕截图选择菜单

应用程序可以使用 新的MIDI API。以下是发送 MIDI NoteOn 消息的一些代码:

byte[] buffer = new buffer[3];
buffer[0] = (byte)0x90 + (byte)0x01; // Note On - Channel 1
buffer[1] = (byte)0x3C; // pitch (Note C3)
buffer[2] = (byte)127; // velocity
int offset = 0;
inputPort.send(buffer, offset, numBytes);

要发送其他消息类型,请参阅 MIDI 消息规范。请注意,字节在 Java 中是有符号的,因此这篇文章可能会有所帮助

With Android 6.0 (API 23) this is now possible - Android devices can act as class compliant (no drivers required) MIDI devices.

To switch into USB-MIDI mode users can swipe down from the top of the screen to access the USB mode selection screen (below).

Screenshot showing USB selection menu

An app can send MIDI messages using the new MIDI API. Here's some code to send a MIDI NoteOn message:

byte[] buffer = new buffer[3];
buffer[0] = (byte)0x90 + (byte)0x01; // Note On - Channel 1
buffer[1] = (byte)0x3C; // pitch (Note C3)
buffer[2] = (byte)127; // velocity
int offset = 0;
inputPort.send(buffer, offset, numBytes);

To send other message types consult the MIDI message specification. Note that bytes are signed in Java so this post might be helpful.

感受沵的脚步 2025-01-08 16:02:00

我为 Android 编写了 USB MIDI 驱动程序。
可用于构建您自己的 MIDI 控制器/接收器。

https://github.com/kshoji/USB-MIDI-Driver

另一个 MIDI 驱动程序是“nmj”库.
该库还支持 USB MIDI。此外,它还支持一些网络MIDI协议,通过蓝牙的MIDI和通过ADB的MIDI(调试连接)。

http://www.humatic.de/htools/nmj/

I wrote the USB MIDI Driver for Android.
Useful to build your own MIDI controller / receiver.

https://github.com/kshoji/USB-MIDI-Driver

The another midi driver is 'nmj' library.
This library also supports USB MIDI. Moreover, it supports some network-MIDI protocols, MIDI over bluetooth and MIDI over ADB(debug connection).

http://www.humatic.de/htools/nmj/

一梦等七年七年为一梦 2025-01-08 16:02:00

不,它不能像那样远程工作。

USB MIDI 设备确实使用驱动程序...只是它们通常是“类兼容”的,并且都可以使用操作系统附带的相同库存驱动程序。

为了完成您所建议的操作,您需要通过 USB 模拟设备...并提供适当的 PnP ID 等。这几乎是不可能的。您找到的代码是在主机模式下使用 USB 的,而不是相反。

您会发现通过网络发送 MIDI 并使用众多可用的网络 MIDI 驱动程序之一要容易得多。

No, it doesn't work remotely like that.

USB MIDI devices do use a driver... it's just that they are generally "class compliant", and can all use the same stock driver that comes with the OS.

To do what you are proposing, you will need to emulate a device over USB... complete with the appropriate PnP IDs and what not. This is next to impossible. The code you found was for using USB in host mode, not the other way around.

You will find that it is far easier to send MIDI via network, and use one of the many network MIDI drivers available.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文