4

Support for the Web MIDI API has been added to Chrome Canary since early 2013.

Why then, when I type requestMIDIAccess in the JavaScript console and hit enter, do I get "ReferenceError: requestMIDIAccess is not defined"?

According to official documentation, it should be a defined function.

What gives?

Joncom
  • 1,985
  • 1
  • 18
  • 29

2 Answers2

8

The Web MIDI API is available by default only in Chrome versions 43 and newer.

In earlier versions it is not enabled by default, but can be enabled as an experimental feature flag. In Chrome, load the special URL chrome://flags and search within the page for "Enable Web MIDI API".

The options on the flags page require the browser to be restarted before they will take effect. The features hidden behind these flags are in an experimental state and are subject to change at any time, so the API in older versions may differ from what is available in Chrome 43.

Note also that the requestMIDIAccess function is a method of window.navigator, not directly of window. Therefore you need to call it as navigator.requestMIDIAccess.

Martin Atkins
  • 62,420
  • 8
  • 120
  • 138
  • I found and enabled the feature (see http://puu.sh/6ZiDe.png), then restarted Chrome Canary, and the problem still persists. Any idea why? – Joncom Feb 17 '14 at 05:19
  • I added another paragraph to my answer that I think may answer your followup question. – Martin Atkins Feb 17 '14 at 05:27
  • 1
    Also worth noting: **As of Chromium 43 (current dev channel), the MIDI API will be enabled by default.** With the current release cycle, that makes the API safe to use for a great deal of the web starting June 2015, when it's enabled by default in the stable channel. – Chiru Apr 06 '15 at 05:15
  • There is also a Web MIDI API polyfill available for older versions of Chrome, as well as for other browsers: https://github.com/cwilso/WebMIDIAPIShim – dinopmi Jan 05 '16 at 15:54
0

Also note that after you plug-in a new MIDI device, you may need to quit and restart Chrome. It does not seem to handle dynamic adjustment of the device list.

sheffler
  • 452
  • 1
  • 4
  • 12