What happened
AI that writes web pages can also write pages that make sound. Every modern browser has a built-in sound kit, the Web Audio API: a set of commands a web page uses to make, mix and play sound. So you can type "a slow, calm beat for our study-with-me video, 80 beats a minute", and an AI agent (an AI that takes actions for you, here writing and changing the page's files) builds a page that plays it.
You get a grid of drums, a play button and a speed slider. No music app to install, no sound files to download, no lessons first.
The interesting part isn't that it makes a beat. It's what kind of thing it makes. A sound file is finished: you keep it or ask again. A beat machine is something you can change, one square at a time, and hear the result straight away.
You don't get a song; you get an instrument you can keep changing.
How it works
The beat grid: a light moves along 16 steps and plays every square that is switched on in its column, then loops back to the start.
A beat machine is a grid (musicians call it a step sequencer). Each row is one sound: kick drum, snare, hi-hat, clap. Each column is one moment in time, called a step. A light walks along the columns from left to right, and at each step the machine plays every square that's switched on in that column. At the end it jumps back to the start. That's the loop.
The speed is simple maths
The speed is the tempo, counted in beats per minute (BPM). In our Beat machine project the grid has 16 steps, four to each beat, so the whole grid is four beats long. Four beats make one bar, the unit songs are counted in.
At 80 BPM one beat lasts 60 ÷ 80 = 0.75 seconds. A step is a quarter of that, about 0.19 seconds, and the whole loop is 3 seconds. Push the tempo to 100 and the loop shrinks to 2.4 seconds: the same pattern, more energy.
The drums are made, not recorded
In our project nothing is a recording. The code builds each drum from two plain ingredients, a tone and a hiss:
- Kick: a low tone that drops in pitch very fast, which your ear hears as a thud.
- Hi-hat: a very short burst of hiss (random noise) with a filter that keeps only the high part. The shorter the burst, the tighter it sounds.
- Snare: a longer burst of the same hiss with a short tone underneath.
- Clap: three tiny bursts of hiss about a hundredth of a second apart, so it sounds like several hands at once.
Why it stays in time
A web page's ordinary timer can run late by tens of milliseconds when the computer is busy drawing the screen. Your ear notices that as a sloppy beat. So the code books each sound a moment ahead on the browser's own sound clock, which keeps exact time. You never see this part, but it's why the loop stays tight while the page also runs its lights.
A beat is a grid, a speed and a clock. Everything else is your choices.
Why it matters
Every square is a choice you can hear. Switch the hi-hat off on the first step and, one loop later, you hear the difference. That quick circle of change, listen, decide is how musicians find out what they like, and here you get it without learning an instrument first.
It also means the pattern is yours. You picked the squares, the speed and the sounds, so the beat under your PE warm-up or your friend's birthday clip is one you made.
Why you still check
The AI doesn't know what your class finds funny or what fits your video. Its first beat is usually fine and a bit boring. It also can't hear: it may call a beat "upbeat" with no way of knowing how it sounds.
So you're the ear. Three checks that help:
- Play it; don't trust the description. "Calm and steady" in the chat means nothing until you've heard a few loops.
- Change the tempo while it plays. The beat should follow at once, without stopping or stuttering.
- Ask for one change at a time, so you know which change did what.
Vague asks get vague beats. Clear asks name a sound, a step or a number:
| Vague | Clear |
|---|
| Make it better | Take the hi-hat out of the first bar so the beat starts quietly |
| More energy | Raise the speed to 100 and add a clap on every fourth beat |
| Make it sadder | Switch the melody to the minor scale (a sadder set of notes) and slow it to 70 |
Try it
Open the Beat machine project below and ask for a beat for the next thing your class films. You'll hear a loop within the first few minutes. Then make it yours, one square at a time, and let your ear have the last word.