Music / CS All levels ●○○ Beginner ★ Free

Rhythm Sequencer

Make some noise. A 16-step drum machine running entirely in your browser with synthesized audio.

Tempo: 120 BPM
Simulation running

The Mathematics of Music

Music is fundamentally mathematical: pitch is frequency (A4 = 440 Hz), octaves are frequency doublings, and consonant intervals are simple ratios (perfect fifth = 3:2, perfect fourth = 4:3). Rhythm divides time into regular beats grouped into measures, creating the temporal structure that makes music feel organised and danceable.

Digital Audio Synthesis

This sequencer uses the Web Audio API to generate sound in real time. Each instrument is synthesised from basic waveforms: sine (pure tone), square (hollow, retro), sawtooth (bright, buzzy), and triangle (mellow). Drums use noise bursts shaped by envelopes (Attack-Decay-Sustain-Release), giving each percussive hit its characteristic shape and timbre.

Step Sequencing and Drum Machines

The grid represents time (columns = steps) and instruments (rows). Each cell is either on or off. As the playhead moves left to right, active cells trigger sounds. This paradigm was pioneered by the Roland TR-808 (1980) and TR-909 (1983), which defined the sound of hip-hop, techno, and electronic music and remain hugely influential today.

Rhythm, Tempo, and Time Signatures

Tempo (BPM) controls playback speed. 4/4 time (four beats per measure) is the most common time signature in pop and rock music. 3/4 gives a waltz feel; 6/8 creates a compound groove. Polyrhythms layer different time signatures simultaneously, creating complex interlocking patterns used in African drumming, jazz, and progressive rock.

Experiments to Try

  • Create a basic 4/4 rock beat: kick on beats 1 and 3, snare on 2 and 4, hi-hat on all eighth notes
  • Try a boom-bap hip-hop pattern with syncopated kick placement
  • Create polyrhythms with different cycle lengths for each instrument
  • Adjust tempo from 60 BPM (slow, ambient) to 200 BPM (fast, drum and bass)
  • Add synth accents to create melodic interest alongside the percussion

Rhythm & Time Signatures

A time signature (e.g., 4/4, 3/4, 7/8) specifies how many beats are in each measure and what note value counts as one beat. A beat is the basic unit of musical time; tempo (BPM beats per minute) sets its speed. At 120 BPM, one beat lasts 0.5 s. The sequencer’s step grid divides each measure into sub-divisions, creating the rhythmic backbone of music.

Polyrhythms

A polyrhythm is the simultaneous use of two or more conflicting rhythms. The most common 3-against-2 overlays three equal beats over two, creating a rocking cross-rhythm. 4-against-3 (the hemiola) appears in Chopin waltzes. African and Indian classical music feature highly complex polyrhythms. The sequencer lets you hear these patterns clearly by assigning different rhythms to separate voices.

Sound Synthesis

Percussion sounds are synthesized using the Web Audio API. A kick drum uses a brief sinusoidal burst with exponential frequency sweep; a snare combines filtered noise with a short sine transient. Fourier synthesis is the basis for all additive synthesis: any periodic waveform can be expressed as a sum of sinusoids, f(t) = Σ Ansin(2πnƒt). The timbre of an instrument is determined by its harmonic amplitudes An.

Musical Acoustics

Pitch is determined by fundamental frequency (Hz). The standard tuning A4 = 440 Hz; each octave doubles the frequency. Musical intervals correspond to simple frequency ratios: an octave is 2:1; a perfect fifth is 3:2; a perfect fourth is 4:3. Equal temperament divides the octave into 12 equal semitones, each a factor of 21/12 ≈ 1.0595 above the previous, allowing transposition to any key.

Key Equations

ConceptFormulaNotes
Beat durationT = 60/BPM (s)At 120 BPM: T = 0.5 s
Semitone ratior = 21/12 ≈ 1.0595Equal temperament; 12 semitones = 1 octave
Note frequencyfn = 440 ⋅ 2(n−69)/12n = MIDI note number; A4 = 440 Hz at n=69
Octave relationshipfn+12 = 2fnOne octave up doubles frequency
Fourier seriesf(t) = A0 + Σ Ancos(nωt) + Bnsin(nωt)Harmonic decomposition of any periodic sound
Polyrhythm LCMPeriod = LCM(m, n) / BPMm:n polyrhythm repeats after LCM(m,n) beats

Curriculum Relevance

LevelTopicRelevance
GCSE MusicRhythm, metre, notationTime signatures, note values, beat divisions
A-Level Music / PhysicsAcoustics & wavesFrequency, harmonics, timbre, standing waves
IB MusicWorld music & rhythmAfrican, Indian polyrhythm traditions; additive rhythm
UndergraduateMusic technology / DSPSignal processing, Fourier transforms, synthesis algorithms
PostgraduateMusic cognition / MIRBeat tracking algorithms, onset detection, tempo induction

🔒 Unlock All 32 Simulations

Get unlimited access to all 32 simulations — including the Rhythm Sequencer, Fourier Epicycles, String Wave and more with MySimulator Premium.

Upgrade to Premium

Discussion and comments (Premium)

Premium members can discuss use-cases and ask questions inside this page.

Video tutorial (Premium)

A short guided walkthrough is available for premium users.

Unlock Tutorial ->

Downloadable worksheet (Premium)

Printable worksheet with tasks and reflection questions.

Unlock Worksheet ->

Share this simulation

Send this page to students or colleagues.

Related simulations

Continue with similar experiments.