在网页中发送 MIDI 消息
如何在网页中播放单独的 MIDI 音符?
我知道有两种方法可以做到这一点:
编写 ActiveX 控件。 那么它只能在 Windows 上运行。 很久以前我就写过ActiveX控件,但是现在没人喜欢安装它们了。
编写一个 Java 小程序。 如果用户已经安装了 Java,那么这是可以的,但许多用户禁用小程序。 我就是这样做的,如果它恰好适用于您的特定设置,您可以在 newfweiler.com 上看到结果。 您至少需要 Java 5,尽管我想如果必须的话我可以用 Java 1.2 重写它。 “实时音序器”和“Java 声音合成器”对我不起作用; 我认为你必须安装波表或其他东西才能使其工作。
大多数用户都安装了 Flash,但我查看了 Flash 和 Flex 文档,没有看到任何与 javax.sound.midi 等效的内容。
在网页中播放 MIDI 文件的方法有多种,您可以找到“Javascript Pianos”,只要您按一个键即可播放单音符 MIDI 文件。 您无法同时演奏多个音符或按住琴键演奏长音符。
我想做的相当于 javax.sound.midi.Receiver.send(midiMsg, -1) ,仅使用大多数人通常安装在计算机上的内容。
How can I play individual MIDI notes in a Web page?
I know of two ways to do it:
Write an ActiveX control. Then it only works on Windows. I used to write ActiveX controls a long time ago, but now nobody likes to install them.
Write a Java applet. This is OK if the user already has Java installed, but many users disable applets. This is the way I did it and you can see the result at newfweiler.com -- if it happens to work on your particular setup. You'll need at least Java 5, although I suppose I could rewrite it in Java 1.2 if I had to. The "Real Time Sequencer" and "Java Sound Synthesizer" don't work for me; I think you have to install wavetables or something to make them work.
Most users have Flash installed, but I looked in the Flash and Flex documentation and did not see anything equivalent to javax.sound.midi.
There are several ways to play a MIDI file in a Web page, and you can find "Javascript Pianos" that play a one-note MIDI file whenever you press a key. You can't play multiple notes at once or hold the key down for a long note.
What I'm trying to do is the equivalent of javax.sound.midi.Receiver.send(midiMsg, -1) using only what most people typically have installed on the machine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 Web Audio API 播放声音和 .mid-文件。 请参阅 https://surikov.github.io/webaudiofont/examples/ 的 MIDI 播放器示例midiplayer.html
使用Web MIDI API(Chrome支持)来监听MIDI键盘。 请参阅示例 https://surikov.github.io/webaudiofont/examples/midikey.html
Use Web Audio API to play sounds and .mid-files. See example of MIDI player at https://surikov.github.io/webaudiofont/examples/midiplayer.html
Use Web MIDI API (Chrome supports it) to listen MIDI keyboard. See example at https://surikov.github.io/webaudiofont/examples/midikey.html
即使少数用户禁用 Java,Java 仍然可能是您的最佳选择。
我使用 NoScript,并且可以将网站列入白名单。 我想说,如果您提供引人注目的内容,大多数用户可能也会这样做。
Java is still probably going to be your best bet, even with the few users disabling it.
I use NoScript, and I can whitelist a site. I would say that most users would probably do the same if you provide compelling content.
找到以下内容(翻译自意大利语)。 我想说Flash是最好的选择。 如果您想成为贫民窟,您只需获取 88 个左右的钢琴样本并根据时间线演奏它们即可。
http://translate.google.com/translate?prev=hp&hl=en&js=n&u=http %3A%2F%2Fflash.html.it%2Fguide%2Flezione%2F2936%2Fmidi-player%2F&sl=it&tl=en&history_state0=
Found the following (translated from Italian). I'd say Flash is the way to go. If you want to be ghetto you can just get 88 or so piano samples and play them against a timeline.
http://translate.google.com/translate?prev=hp&hl=en&js=n&u=http%3A%2F%2Fflash.html.it%2Fguide%2Flezione%2F2936%2Fmidi-player%2F&sl=it&tl=en&history_state0=
有一个在线 MIDI 钢琴的示例 https://jazz-soft.net/demo/VirtualPiano .html
它使用Web Audio API,不需要任何特殊软件,但是,如果启用Web MIDI,它具有更多功能。 页面上包含代码。
There is an example of online MIDI piano at https://jazz-soft.net/demo/VirtualPiano.html
It uses the Web Audio API and does not require any special software, however, if the Web MIDI is enabled, it has more functionality. Code included on the page.