简体   繁体   English

在网页中发送 MIDI 信息

[英]Sending MIDI messages in a Web page

How can I play individual MIDI notes in a Web page?如何在网页中播放单个 MIDI 音符?

I know of two ways to do it:我知道有两种方法可以做到:

  1. Write an ActiveX control.编写一个 ActiveX 控件。 Then it only works on Windows.那么它只适用于 Windows。 I used to write ActiveX controls a long time ago, but now nobody likes to install them.很久以前我曾经写过 ActiveX 控件,但现在没有人喜欢安装它们。

  2. Write a Java applet.编写一个 Java 小程序。 This is OK if the user already has Java installed, but many users disable applets.如果用户已经安装了 Java,这是可以的,但是许多用户禁用了小程序。 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.我就是这样做的,您可以在 newfweiler.com 上查看结果——如果它恰好适用于您的特定设置。 You'll need at least Java 5, although I suppose I could rewrite it in Java 1.2 if I had to.您至少需要 Java 5,尽管我想如果必须的话我可以用 Java 1.2 重写它。 The "Real Time Sequencer" and "Java Sound Synthesizer" don't work for me; “实时音序器”和“Java 声音合成器”对我不起作用; 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.大多数用户都安装了 Flash,但我查看了 Flash 和 Flex 文档并没有看到与 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.在网页中有多种播放 MIDI 文件的方法,您可以找到“Javascript Pianos”,只要您按下一个键,它就会播放一个单音 MIDI 文件。 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.我正在尝试做的是相当于 javax.sound.midi.Receiver.send(midiMsg, -1) 只使用大多数人通常在机器上安装的东西。

Use Web Audio API to play sounds and .mid-files.使用 Web Audio API 播放声音和 .mid 文件。 See example of MIDI player athttps://surikov.github.io/webaudiofont/examples/midiplayer.html请参阅https://surikov.github.io/webaudiofont/examples/midiplayer.html 中的 MIDI 播放器示例

Use Web MIDI API (Chrome supports it) to listen MIDI keyboard.使用 Web MIDI API(Chrome 支持)来听 MIDI 键盘。 See example at https://surikov.github.io/webaudiofont/examples/midikey.html请参阅https://surikov.github.io/webaudiofont/examples/midikey.html 中的示例

Java is still probably going to be your best bet, even with the few users disabling it. Java 仍然可能是您最好的选择,即使只有少数用户禁用它。

I use NoScript, and I can whitelist a site.我使用 NoScript,并且可以将站点列入白名单。 I would say that most users would probably do the same if you provide compelling content.我会说,如果您提供引人注目的内容,大多数用户可能会这样做。

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. https://jazz-soft.net/demo/VirtualPiano.html有一个在线 MIDI 钢琴的例子,它使用 Web Audio API,不需要任何特殊软件,但是,如果启用了 Web MIDI,它有更多功能。 Code included on the page.页面中包含的代码。

Found the following (translated from Italian).发现以下内容(从意大利语翻译)。 I'd say Flash is the way to go.我会说Flash是要走的路。 If you want to be ghetto you can just get 88 or so piano samples and play them against a timeline.如果你想成为贫民窟,你可以得到 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= 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=

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM