How to Make a Rhythm Game
A rhythm game is a contract that the note arrives exactly on the beat. Here is how to write beat maps, set timing windows, and keep that contract on real devices.

Key takeaways
- Drive everything from the audio clock, never from frame timing. Notes are positioned by where the song is, not by how many frames passed.
- Timing windows of roughly ±40 to ±150 milliseconds for Perfect down to Good are a reasonable start; tune by feel.
- Phones and Bluetooth headphones add delay you cannot remove. A calibration screen that measures it is essential.
To make a rhythm game you need a song, a beat map that lists when each note should be hit, a note highway that shows notes approaching a hit line in sync with the music, and judging that compares each tap to its note with millisecond timing windows. The hard part is not the code, it is time: keeping visuals locked to the audio and accounting for the delay that phones and headphones add. This guide covers both the design and that honest technical reality.
Beat maps: the level files
A beat map (or chart) is the list of notes for one song at one difficulty. Store notes by beat, not by milliseconds, and convert using the song’s tempo:
- Song header: audio file, BPM (beats per minute), offset (milliseconds from the start of the file to the first beat), and the time signature if it matters.
- Each note: beat position (like 16.5 for the “and” after beat 16), lane (or direction), and type: tap, hold (with an end beat), or swipe.
- Conversion: time in ms = offset + beat × (60,000 ÷ BPM). At 120 BPM a beat is 500 ms; an eighth note is 250 ms.
- Tempo changes: a list of BPM changes at given beats, if the song has them. Songs with a steady tempo are much easier for a first game.
Storing beats makes charting musical: you place notes on quarter, eighth and sixteenth subdivisions, and if you discover the offset was 20 ms off, you fix one number instead of every note.
Charting that feels musical
- Follow an instrument. Easy charts follow the kick drum or the main beat; harder ones follow the melody or the drums in detail. Players feel when notes match something they hear.
- Density by difficulty: Easy around one note per beat at most, Normal adds eighth notes, Hard adds sixteenth-note runs and holds.
- Patterns, not noise: repeat a pattern when the music repeats. Players learn and anticipate, which is the joy of the genre.
- Rest when the song rests. A quiet verse should be quiet on the highway too.
Timing windows
When the player taps, find the nearest unhit note in that lane and measure the difference between the tap time and the note time. Then judge it:
- Perfect: within about ±40 to ±50 ms.
- Great: within about ±80 to ±100 ms.
- Good: within about ±130 to ±150 ms.
- Miss: a note that passes the Good window without a tap. A tap far from any note is ignored or counted as a small penalty, depending on how strict you want to be.
These are starting points in the range many rhythm games use, not rules. Casual games use wider windows; games for experts use tighter ones. Track whether players are early or late on average and show it after a song (“you tend to hit 30 ms late”); it helps players and it helps you spot a calibration problem.
Scoring
Give judgment-based points (Perfect 300, Great 200, Good 100), a combo counter that breaks on a Miss, and a modest combo multiplier. Grade at the end by accuracy percentage rather than raw score, so songs with different note counts compare fairly. If you add a scoreboard per song, the leaderboards guide covers keeping it fair.
The audio clock is the only clock
The classic beginner bug: notes are moved a fixed amount every frame, and after a minute they drift out of sync because frames are not perfectly regular. The fix is to never trust frame counts. Each frame, ask the audio system how far into the song it is (in the browser, the Web Audio API’s `AudioContext.currentTime`, adjusted by when playback started) and place every note from that number: a note’s distance from the hit line is (note time − song time) × scroll speed.
- Start audio with a tap. Browsers block audio until the user interacts with the page, so the song must start from a Play button, not on page load.
- Decode before starting. Load and decode the whole song first, then start, so playback does not stutter.
- Timestamp input precisely. Use the input event’s timestamp, converted to song time, rather than the time the frame processes it.
Latency: the honest part
Between the moment a sound is scheduled and the moment it reaches the player’s ear, there is delay. Between the moment a finger hits glass and the moment the game sees it, there is more. On a desktop with wired headphones the total is small. On phones it is larger, and with Bluetooth headphones audio can arrive a couple of hundred milliseconds late, which is longer than your Good window. You cannot remove this delay from a web page. You can measure it and compensate:
- 01Audio offset calibration: play a steady click and ask the player to tap along for 8 to 16 beats. The average difference between taps and clicks is their offset; shift judging by it.
- 02Visual offset calibration: a flash on the beat, tap along, to align visuals separately if needed.
- 03Save per device, and show the calibration screen on first launch with a friendly explanation.
- 04Recommend wired headphones or the speaker for best results, without making it a requirement.
Be honest with yourself about the platform: a browser rhythm game can be a lot of fun and properly playable with calibration, but competitive players with high-end rhythm game hardware will notice differences from native games. Design for casual to intermediate players and you will be fine.
Music: rights before charts
You cannot use commercial songs without a license, and rhythm games depend on songs. Your options: music you or a friend made, tracks with a license that clearly allows use in games, or generated music. Startbase can generate music up to two minutes long for your game in the same chat, which is a good length for a rhythm stage; describe tempo and mood and ask for a steady BPM so charting stays simple. The game music guide covers licenses and loops in more depth, and AI-generated sound for games explains what generation does well.
The brief to paste
A four-lane rhythm game for phones and desktop. Notes fall toward a hit line near the bottom; tap the lane (or press D, F, J, K) as each note crosses it. Notes are stored by beat in a chart file with the song’s BPM and offset; time in ms = offset + beat × 60000 ÷ BPM. Position every note from the audio clock each frame, never from frame counts. Song starts from a Play button. Judging windows: Perfect ±45 ms, Great ±90 ms, Good ±135 ms, otherwise Miss; show early or late for non-Perfect hits. Combo counter, accuracy percentage and a letter grade at the end, plus average early or late. First-launch calibration: tap along to 12 clicks, save the offset on the device, and a setting to redo it. Generate one upbeat electronic track at a steady 120 BPM, about 2 minutes, and chart it at Easy and Normal. Include a developer charting mode that records taps quantized to eighth notes.
Rhythm game pitfalls
- Wrong offset. If every Perfect feels early, the chart offset is wrong. Fix it in the chart, not in the windows.
- Hit sounds that lag. A tap sound played on input arrives late on high-latency devices and confuses timing. Make hit sounds optional.
- Charts that ignore the music. Random notes on the beat are boring; notes that follow an instrument are fun.
- Starting too hard. Your first song should be easy enough that a new player full-combos it on their second try.
Test the preview on a real phone with both the speaker and headphones before sharing. For a simpler game built around timing a single tap, the endless runner guide shares the same instant-feedback loop, and our guide to making a game without coding covers art and publishing. A rhythm game also needs a strong game feel pass on every hit.
Frequently asked questions
What timing windows should a rhythm game use?
A common starting point is around ±45 ms for Perfect, ±90 ms for Great and ±135 ms for Good, then adjusting by feel. Casual games are more generous, expert games stricter.
Why does my rhythm game drift out of sync?
Usually because notes move by frame count instead of by the audio’s playback time. Position notes from the audio clock every frame and they stay locked to the music.
Do rhythm games work with Bluetooth headphones?
They can, with calibration. Bluetooth audio often arrives a couple of hundred milliseconds late, so the game should measure the delay with a tap-along test and shift its judging by that amount.
Can I use popular songs in my rhythm game?
Not without a license. Use your own music, tracks licensed for games, or generated music.

