MIDI in the Browser... Let's Rock the Web!

Rate this content
Bookmark

If you own an electronic music instrument made in the last 3 decades, it most likely supports the MIDI protocol. What if I told you that it is possible to interact with your keytar or drum machine directly from your beloved browser? You would go crazy, right? Well, prepare to do so…

With built-in support in Chrome, Firefox and Opera, this possibility is now a reality. This talk will introduce the audience to the Web MIDI API and to my own WEBMIDI.js library so you can get rockin' fast.

Web devs, man your synths!

This talk has been presented at JSNation 2022, check out the latest edition of this JavaScript Conference.

FAQ

The Web MIDI API specification was published in 2012, and the first implementation came in 2015 with Chrome version 43.

MIDI is used in various fields beyond music, including controlling stage lighting, pyrotechnics, robotics, and theme park ride controls.

Released in 2020, MIDI 2.0 is an extension of the original MIDI standard. It adds bi-directional communication and other features while remaining compatible with the original MIDI standard.

To get started with the Web MIDI API, you need to check if the browser supports it using the 'requestMIDIAccess' function. If supported, you can then request access to MIDI devices and handle MIDI messages within your web application.

MIDI stands for Musical Instrument Digital Interface. It is a communication protocol that allows electronic musical instruments, computers, and other devices to communicate and synchronize with each other.

While some people may consider MIDI to be outdated technology from the 80s, it is still widely used today in electronic music hardware and software, stage lighting, pyrotechnics, robotics, and more.

The Web MIDI API is a web standard that allows web applications to interact with MIDI hardware, such as synthesizers, drum machines, and other MIDI-compatible devices, directly from a web browser.

As of today, most major browsers support the Web MIDI API except for Apple's Safari, which does not support it due to fingerprinting concerns.

The Web MIDI API allows you to create web applications that can interact with MIDI devices, such as editing reverb pedal settings, building online music education systems, teaching music theory, and creating live coding jam sessions.

WebMidi.js is a JavaScript library designed to make it easier for web developers and musicians to use the Web MIDI API. It provides a user-friendly interface for receiving and sending MIDI messages.

Jean-Philippe Côté
Jean-Philippe Côté
28 min
16 Jun, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

MIDI is a versatile communication protocol that extends beyond music and opens up exciting possibilities. The Web MIDI API allows remote access to synths and sound modules from web browsers, enabling various projects like music education systems and web audio-based instruments. Developers can connect and use MIDI devices easily, and the Web MIDI API provides raw MIDI messages without semantics. The WebMidi.js library simplifies working with the Web MIDI API and offers a user-friendly interface for musicians and web developers. MIDI on the web has generated significant interest, with potential for commercial growth and endless possibilities for web developers.

1. Introduction to MIDI on the Web

Short description:

I'm here to talk to you about MIDI on the web. MIDI is a communication protocol that extends beyond music. It can be used to control various devices and opens up awesome possibilities. MIDI is a lightweight and efficient protocol that has stood the test of time.

Thanks for being here so late after this long, long day in this very, very hot room, but it's going to continue to be hot. I'm saluting people back at home also. I'm glad you're here while over there, so that's nice.

Yeah, my name is Jean-Philippe Cote and I'm here to talk to you about MIDI on the web. Now, okay, because I don't want to ruin this. I have sound, right? Given this is not a music conference some of you may wonder what MIDI actually is or not, I don't know. But to many people, I'm afraid, MIDI is this outdated technology from the 80s. It's this like... It's the reason for awful sounding track ripoffs like this one. That's awesome. You probably all heard things like this before, and just so we're clear, this talk is not going to be about those stupid MIDI standard MIDI files or karaoke files. So let's cross that out right now. You can always keep them for the after party if you want, but this talk is not going to be about that.

The talk is going to be about interacting with MIDI-compatible devices from your web browser. So I'm talking about synthesizers, and drum machines, and wind controllers, and percussions, and even the awesome keytar, my favorite. Even though the acronym stands for Musical Instrument Digital Interface, MIDI does extend way beyond music. The protocol can be used for, to control stage lighting and pyrotechnics, and it can be found in robotics, theme park, ride control, and all sorts of other contraptions and contacts. So, having access to MIDI from the browser really opens up awesome possibilities.

Now, just so we're on the same page, MIDI is a communication protocol. There is no audio involved. No audio is being transferred. The only data that's being transferred is actually just numbers, identifying the notes that are being played or stopped, and how strong they were played. Obviously, the protocol also has messages for pitch bands and program chains and time syncing and so on. But it's a very lightweight and efficient protocol that can be used on devices with really modest processing power. Think Arduinos, for example. You can do MIDI on an Arduino. MIDI has stood the test of time and is embedded in pretty much every single piece of electronic music, hardware and software made in the last 35 years. This is a long way for technology. The core MIDI standard was released in 1983 and it pretty much has remained the same since then. 37 years after that, in 2020, the MIDI 2.0 standard came out and it builds upon the original.

2. Web MIDI API and Software Instruments

Short description:

The Web MIDI API, introduced in 2012, allows remote access to synths and sound modules from web browsers. Most browsers support the API, except Apple. Developers can create various projects using the API, such as webpages for editing pedal settings, music education systems, music theory teaching tools, and web audio-based instruments. Now, let's experience a software instrument using the WebSynths Microtunnel by Mitch Wells.

It doesn't replace it. It's just like it adds a bi-directional communication and a bunch of other stuff. But in our case, the year that's really the most interesting, I guess, is 2012. And the reason why is because this is the publication year of the Web MIDI API. At the time, midi.org touted the Web MIDI API as the most significant advancement of MIDI since MIDI itself. Way to talk about themselves. So, there you go. But really, it was quite a big thing.

All of a sudden, all your synths and sound modules and librarians and patch editors and what have you could all be accessed remotely from the browser. Theoretically. Obviously, the spec came out in 2012, but we had to wait a few more years for the first implementation, and this came in 2015 with Chrome 43. As of today, pretty much all browsers support it, except one notable exception, which is Apple, and, as you probably know, Apple has decided to block or not support a bunch of APIs over fingerprinting concerns. But, hey, pretty much all the other ones, as you can see, support it already. So this is roughly 87% of desktop browser traffic, which is really the target, well, the primary target for this API. Obviously, you can do MIDI on portable devices, but I think still the main target is desktop browsers.

So the question is, here, are you going to be amongst this first wave of developers creating awesome new projects with this API? What can we build with it? Well, you can do like Francois Georgi and build yourself a little webpage to edit your reverb pedal settings. Why not? Or you can go a bit further and build this old music education system that's online, considering the pandemic we just went through, this kind of makes sense now. Or perhaps what you want to teach about is music theory. And this is what the Chromatone project does. Or you're just a crazy team of people and you want to build your own jamming, live coding kind of thing? Well, there you go. This has been done already. Obviously, you can also create the, you can also use the WebMedia API to control your own web audio based instruments. So there are already several in such instruments in existence but not that many. And again, the point here is probably that it could be a great time for you guys to jump in and build those instruments, build those tools for the next wave of online MIDI music.

So, what is the experience of a user wanting to try out one of these software instruments? To demonstrate that, I'm going to use this awesome synth which is called simply WebSynths Microtunnel by Mitch Wells. It's one of the first ones. It's actually pretty good. It's a web audio-based so all the sounds you're going to hear are coming from web audio and I'm just going to control it from my little Akai controller. Now, we've had a few issues with the Wi-Fi. So, I think I'm just going to stick to using my own phone here to be on the safe side.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Install Nothing: App UIs With Native Browser APIs
JSNation 2024JSNation 2024
31 min
Install Nothing: App UIs With Native Browser APIs
This Talk introduces real demos using HTML, CSS, and JavaScript to showcase new or underutilized browser APIs, with ship scores provided for each API. The dialogue element allows for the creation of modals with minimal JavaScript and is supported by 96% of browsers. The web animations API is a simple and well-supported solution for creating animations, while the view transitions API offers easy animation workarounds without CSS. The scroll snap API allows for swipers without JavaScript, providing a smooth scrolling experience.
Domain Driven Design with Vue Applications
Vue.js London 2023Vue.js London 2023
14 min
Domain Driven Design with Vue Applications
Top Content
Welcome to this talk on domain-driven design in Vue.js application. Today we are going to look into domain-driven design, its benefits and how it works with Vue.js domain-driven design versus the MVVM model. Vue.js thrives in domain-driven design, a design approach that models software to match a domain. DDD emphasizes understanding business logic and creating a domain that reflects the language and concepts. Integrating DDD in Vue.js offers benefits such as effective modeling of complex business domains, structured code reflecting domain logic, and easier onboarding and ownership.
Pushing the Limits of Video Encoding in Browsers With WebCodecs
JSNation 2023JSNation 2023
25 min
Pushing the Limits of Video Encoding in Browsers With WebCodecs
Top Content
This Talk explores the challenges and solutions in video encoding with web codecs. It discusses drawing and recording video on the web, capturing and encoding video frames, and introduces the WebCodecs API. The Talk also covers configuring the video encoder, understanding codecs and containers, and the video encoding process with muxing using ffmpeg. The speaker shares their experience in building a video editing tool on the browser and showcases Slantit, a tool for making product videos.
How to Share Code between React Web App and React Native Mobile App in Monorepo
React Summit 2022React Summit 2022
7 min
How to Share Code between React Web App and React Native Mobile App in Monorepo
This presentation focuses on sharing code between React web and React native mobile apps. The speaker demonstrates how to achieve feature parity using a Monorepo with NX. They highlight the importance of sharing non-UI code, such as business logic and state management, through shared libraries. This approach allows the apps to focus on UI code while keeping non-UI code separate. For more details, refer to the speaker's blog post.
Visualising Front-End Performance Bottlenecks
React Summit 2020React Summit 2020
34 min
Visualising Front-End Performance Bottlenecks
React's web-based tools allow for independent learning. Dazzone, a sports streaming service, faces challenges with low memory and CPU targets. Measuring, analyzing, and fixing performance issues is crucial. Virtualization improves rendering efficiency and performance. The application is now much faster with significantly less jank.
WebHID API: Control Everything via USB
JSNation 2022JSNation 2022
23 min
WebHID API: Control Everything via USB
Today's Talk introduces the webHID API, which allows developers to control real devices from the browser via USB. The HID interface, including keyboards, mice, and gamepads, is explored. The Talk covers device enumeration, input reports, feature reports, and output reports. The use of HID in the browser, especially in Chrome, is highlighted. Various demos showcase working with different devices, including a DualShock controller, microphone, gamepad, and Stream Deck drum pad. The Talk concludes with recommendations and resources for further exploration.

Workshops on related topic

Web Accessibility in JavaScript Apps
React Summit 2022React Summit 2022
161 min
Web Accessibility in JavaScript Apps
Workshop
Sandrina Pereira
Sandrina Pereira
Often we see JavaScript damaging the accessibility of a website. In this workshop, you’ll learn how to avoid common mistakes and how to use JS in your favor to actually enhance the accessibility of your web apps!
In this workshop we’ll explore multiple real-world examples with accessibility no-nos, and you'll learn how to make them work for people using a mouse or a keyboard. You’ll also learn how screen readers are used, and I'll show you that there's no reason to be afraid of using one!
Join me and let me show you how accessibility doesn't limit your solutions or skills. On the contrary, it will make them more inclusive!
By the end, you will:- Understand WCAG principles and how they're organized- Know common cases where JavaScript is essential to accessibility- Create inclusive links, buttons and toggleble elements- Use live regions for errors and loading states- Integrate accessibility into your team workflow right away- Realize that creating accessible websites isn’t as hard as it sounds ;)
Build a Universal Reactive Data Library with Starbeam
JSNation 2023JSNation 2023
66 min
Build a Universal Reactive Data Library with Starbeam
WorkshopFree
Yehuda Katz
Yehuda Katz
This session will focus on Starbeam's universal building blocks. We'll use Starbeam to build a data library that works in multiple frameworks.We'll write a library that caches and updates data, and supports relationships, sorting and filtering.Rather than fetching data directly, it will work with asynchronously fetched data, including data fetched after initial render. Data fetched and updated through web sockets will also work well.All of these features will be reactive, of course.Imagine you filter your data by its title, and then you update the title of a record to match the filter: any output relying on the filtered data will update to reflect the updated filter.In 90 minutes, you'll build an awesome reactive data library and learn a powerful new tool for building reactive systems. The best part: the library works in any framework, even though you don't think about (or depend on) any framework when you built it.
Table of contents- Storing a Fetched Record in a Cell- Storing multiple records in a reactive Map- Reactive iteration is normal iteration- Reactive filtering is normal filtering- Fetching more records and updating the Map- Reactive sorting is normal sorting (is this getting a bit repetitive?)- Modelling cache invalidation as data- Bonus: reactive relationships
Build Web3 apps with React
React Summit 2022React Summit 2022
51 min
Build Web3 apps with React
WorkshopFree
Shain Dholakiya
Shain Dholakiya
The workshop is designed to help Web2 developers start building for Web3 using the Hyperverse. The Hyperverse is an open marketplace of community-built, audited, easy to discover smart modules. Our goal - to make it easy for React developers to build Web3 apps without writing a single line of smart contract code. Think “npm for smart contracts.”
Learn more about the Hyperverse here.
We will go over all the blockchain/crypto basics you need to know to start building on the Hyperverse, so you do not need to have any previous knowledge about the Web3 space. You just need to have React experience.
Writing Universal Modules for Deno, Node and the Browser
Node Congress 2022Node Congress 2022
57 min
Writing Universal Modules for Deno, Node and the Browser
Workshop
Luca Casonato
Luca Casonato
This workshop will walk you through writing a module in TypeScript that can be consumed users of Deno, Node and the browsers. I will explain how to set up formatting, linting and testing in Deno, and then how to publish your module to deno.land/x and npm. We’ll start out with a quick introduction to what Deno is.