Reputation: 39836
[If there is a better place to ask this question, please let me know!]
Note: I'm on a Mac.
I have successfully connected a MIDI keyboard with my browser (Chrome), using the Web MIDI API.
I am wondering if I can also hook up applications (like Ableton Live), so that, when Ableton outputs MIDI messages, these messages can be received by the browser?
Options I see:
I would prefer option 2, so that this would also work when no physical MIDI device is present, but I would also be happy to learn if option 1 could work!
Thanks for any input on this!
Upvotes: 8
Views: 3787
Reputation: 1463
In order to send midi events from Ableton into the Web MIDI API on OSX you need to do the following:
1) Run the built-in OSX app called 'Audio MIDI Setup'. Select 'MIDI Studio'. Double Click 'IAC Driver'. Then check the 'Device is Online' checkbox.
2) Go to Ableton -> Preferences -> MIDI. At the bottom for 'Input: IAC Driver (Bus 1)' enable 'Track' and 'Remote'. For 'Output: IAC Driver (Bus 1)' enable 'Track'.
3) Now in the the Ableton midi track you want to send notes from, Select 'IAC Driver' as the midi output.
4) Now 'IAC Driver (Bus 1)' should appear as a Midi Input via the Web MIDI API.
This process is described here: https://www.youtube.com/watch?v=MkWZ4rtRybQ
Upvotes: 5
Reputation: 203304
I found the documentation for the Web MIDI API a bit confusing, so I tried webmidi
instead (it's built on top of the Web MIDI API, so everything it does should be implementable using the "raw" API as well).
To receive MIDI messages, this works for me:
WebMidi.enable(function(err) {
if (err) throw err;
console.log("WebMidi enabled!");
WebMidi.getInputByName('IAC Driver Bus 1').addListener('noteon', 'all', function(e) {
console.log('note on', e);
});
});
In Ableton, "Midi To" needs to point to the IAC device (if it doesn't show up, you may need to open the MIDI preferences and enable it as an output device):
Caveat: I found that this only works for MIDI tracks that don't have any instruments attached to them (see this page).
EDIT: I assume that the device is named similarly on your Mac, otherwise here's the code I used to enumerate input and output devices:
WebMidi.enable(function(err) {
if (err) throw err;
WebMidi.inputs.forEach(input => {
console.log('- id :', input.id);
console.log('- name:', input.name);
console.log('- manu:', input.manufacturer);
console.log('- conn:', input.connection);
console.log('---');
});
console.log('outputs:', WebMidi.outputs);
WebMidi.outputs.forEach(output => {
console.log('- id :', output.id);
console.log('- name:', output.name);
console.log('- manu:', output.manufacturer);
console.log('- conn:', output.connection);
console.log('---');
});
});
Upvotes: 7