MIDI Web API?

Has anyone accessed the MIDI (Musical Instrument Device Interface) API through SNAP? I created a basic Javascript function (image below) to turn on an oscillator through the MIDI Web API and was encouraged to find that it did, in fact, work.

Has anyone made use of this API (https://www.w3.org/TR/webmidi/)?

image

Not that I know of. Build a library! That'd be great. Music with real instrument timbres!

umm... that's exactly how Snap's audio and notes blocks work...

In that case, is it technically feasible to extend the Set Instrument command to include MIDI instruments like "Piano," "Electric Guitar," etc. rather than just "Sine," "Square Wave," etc.? (I'm assuming that if this were straightforward, it would have already been implemented?)

image

Your example, contrary to what's written on your block and linked to in the webmide reference, is not MIDI, but accessing the general web audio features (e.g. oscillator) that are standard and supported by all browsers. MIDI, otoh, is currently not supported by most browsers (https://developer.mozilla.org/en-US/docs/Web/API/MIDIAccess#Browser_compatibility).

Therefore we'd have to synthesize different instruments ourselves using web audio. This is actually fun and there are a bunch of Snap! projects - one of my favorite workshops, actually - to synthesize a plucked string instrument using the Karplus-Strong algorithm. But there are many issues with synthesizing your own instruments, mostly it's laggy. But better instrument support is high up on my own wish list. It's just not as easy as saying "MIDI!" :slight_smile:

Thanks for the clarification.

We implemented a sound visualization tool, SoundScope (https://maketolearn.org/tools/soundscope/), using the Tone.js framework.

Would it be feasible to provide support for Tone.js (https://tonejs.github.io/) in Snap?

Wow, SoundScope is fantastic! I think it should be absolutely feasible to link both tools, that would be pretty awesome!

We would be interested in doing that. Rich Nguyen is leading the SoundScope development team:

Once the two of you are in communication, you can work out the best approach for proceeding.

Thanks @glenbull for the introduction!
Hi @jens, it's nice to meet you. I'm glad that you find some potential in SoundScope. We've been working on it last summer, and I'm excited to see how we can possibly link it with Snap!

Following up, is it feasible to provide access to the Tone.js framework within Snap? (https://webaudio.github.io/web-audio-api/)

"Tone.js is a framework for creating interactive music in the browser. It provides advanced scheduling capabilities, synths and effects, and intuitive musical abstractions built on top of the Web Audio API."

I think Jens is busy preparing a new release in next few days...
expecting_Snap v5_4_0

Jens,

Following up, would it be possible to include support for the Tone.js framework (https://tonejs.github.io/) in "Snap!" ?

  • Glen

Hi Glen,
I'd love to, but I'm afraid I'm currently entangled in awful paperwork so it's not even sure I can keep my promise of releasing what's already done for v5.4 "in the next few days". Let's look at this closer when the dust of year-end reporting settles! :slight_smile: