876: MIDI & Music in the Browser
Digest
This podcast provides a comprehensive introduction to the Web Audio and Web MIDI APIs, focusing on their capabilities beyond basic sound playback and MIDI input. The Web MIDI API is explored in detail, explaining MIDI messages (note on/off, velocity, channels), and demonstrating how to receive and interpret MIDI data from a keyboard using JavaScript and the `webmidi.js` library. The podcast then delves into the Web Audio API, showing how to generate sounds using oscillators, control waveforms, and incorporate audio from various sources, including a demo of recreating phone dial tones. The Media Recorder API is also covered, demonstrating browser-based audio recording. The episode concludes with creative project ideas combining these APIs for interactive and expressive web applications, highlighting the potential for building interactive musical instruments, generative music, and real-time collaborative music applications. The podcast addresses browser limitations, such as the need for user interaction before audio playback, and discusses the differences between the Web Audio and Web MIDI APIs.
Outlines

Introduction to Web Audio and Web MIDI APIs & Exploring the Web MIDI API
This section introduces the Web Audio and Web MIDI APIs, detailing their functionalities beyond basic sound playback and MIDI input. It covers MIDI messages (note on/off, velocity, channels), demonstrating how to receive and interpret MIDI data from a keyboard using JavaScript and the `webmidi.js` library.

Utilizing the Web Audio API
This section focuses on the Web Audio API, explaining sound generation using oscillators, waveform control, and audio source integration. A demo of recreating phone dial tones is included.

Media Recorder API and Project Ideas & Browser Limitations and Creative Applications
This section covers the Media Recorder API for browser-based audio recording and presents creative project ideas combining Web Audio, Web MIDI, and other APIs for interactive web applications. It also addresses browser limitations, such as the need for user interaction before audio playback, and explores creative applications of the APIs.
Keywords
Web Audio API
A JavaScript API for manipulating audio in web browsers, enabling sound generation, processing, and integration with other media.
Web MIDI API
A JavaScript API enabling communication between web apps and MIDI devices, allowing sending and receiving MIDI messages for music creation and interactive control.
MIDI (Musical Instrument Digital Interface)
A protocol for digital communication between musical instruments and computers, transmitting data representing musical notes, velocity, and other parameters.
`webmidi.js`
A JavaScript library simplifying Web MIDI API interaction, handling low-level MIDI message parsing.
JavaScript
The programming language used to interact with the Web Audio and Web MIDI APIs.
Audio Synthesis
The process of generating sounds programmatically, often using oscillators and other audio processing techniques.
Interactive Music Applications
Web applications that allow users to create, manipulate, and interact with music in real-time.
Browser-Based Audio Recording
The ability to record audio directly within a web browser using APIs like the Media Recorder API.
Sampling Rate
The number of samples per second when converting analog audio to digital; higher rates improve quality but increase file size.
Media Recorder API
A JavaScript API enabling audio and video recording directly within a web browser.
Q&A
What are the key differences between the Web Audio API and the Web MIDI API?
The Web Audio API handles raw audio data and manipulation, while the Web MIDI API handles MIDI message transmission (control data, not sound). They often work together; MIDI controls the Web Audio API.
How can I use the Web MIDI API to control elements on a webpage?
Receive MIDI messages via the API and map MIDI note values or control change messages to actions or changes in webpage elements (e.g., changing colors, animating objects).
What are some limitations of using the Web MIDI API?
MIDI messages have limited data size (typically 3 bytes), complex data might require multiple messages, and browser support/device compatibility should be considered.
Why is a user interaction (like a click) often required before playing audio in the browser?
To prevent autoplay annoyances, browsers require a user gesture before allowing audio playback to start.
What are some creative applications of the Web Audio and Web MIDI APIs?
Building interactive musical instruments, creating generative music, controlling visual elements with MIDI, developing custom audio effects, and building real-time collaborative music applications.
Show Notes
Wes and Scott talk about the Web Audio and Web MIDI APIs, diving into how they enable powerful music and sound manipulation in the browser. They explore MIDI messaging, synthesizing audio, creative coding with music, and share hands-on projects, tips, and libraries to get started.
Show Notes- 00:00 ">00:00 Welcome to Syntax!
- 01:17 ">01:17 Brought to you by Sentry.io
- 02:04 ">02:04 Fun audio experiments
- 05:32 ">05:32 What is MIDI?
- 14:18 ">14:18 Advanced examples with WEBMIDI.js
- 17:02 ">17:02 Outputting MIDI messages
- 24:40 ">24:40 Exploring the Web Audio API
- 31:20 ">31:20 Audio sampling in the browser
- 37:35 ">37:35 Media Recorder
- 39:21 ">39:21 Fun projects
- 42:08 ">42:08 Sick Picks + Shameless Plugs
- Scott: MX Master 3S
- Wes: Microcontoller
Syntax: X Instagram Tiktok LinkedIn Threads
Wes: X Instagram Tiktok LinkedIn Threads
























