How to discover midi keyboard in web midi api?

血红的双手。 提交于 2019-12-01 11:26:42

问题


reference: Browsers in 2013 with Web MIDI API?

I'm currently running Chrome 34.0.1847.116 on OS 10.9.2 and experimenting with the Web Midi API. After enabling chrome://flags/#enable-web-midi, I'm able to get a midiAccess object by pasting the following code from http://www.w3.org/TR/webmidi/ into the DevTools console.

var midi = null;  // global MIDIAccess object

function onMIDISuccess( midiAccess ) {
  console.log( "MIDI ready!" );
  midi = midiAccess;  // store in the global (in real usage, would probably keep in an object instance)
}
function onMIDIFailure(msg) {
console.log( "Failed to get MIDI access - " + msg );
}
navigator.requestMIDIAccess().then( onMIDISuccess, onMIDIFailure );

When I query midi.inputs() and midi.outputs(), the returned list contains only IAC Bus devices. My midi keyboard (connected with a Turtle Beach USB midi adapter) does not show up. In trying to diagnose the problem, I've so far found the following:

  • The adapter is visible in OS X's Audio/Midi Setup and the keyboard works correctly with Logic Pro as well as with homebrew CoreMidi code.
  • The web synth example at http://webaudiodemos.appspot.com/monosynth/index.html also fails to find the keyboard and does not make sound when keys are pressed.
  • The web synth example at http://djazz.se/lab/synth/ does make sound when I click on its virtual keys. DevTools shows that it's using an IAC Bus device.

What do I need to do to help Chrome find non-IAC MIDI devices?


回答1:


The answer to the question (linked below) from developer cwilso explains the problem. The browser has to be rebooted to detect new connected devices (even if web-midi is already enabled). Doing caused my adapter to be detected and available as an input device

Detect if a MIDI interface is connected in Web MIDI API



来源:https://stackoverflow.com/questions/23200972/how-to-discover-midi-keyboard-in-web-midi-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!