Timing in an online drum machine is calculated from BPM: each sixteenth-note grid step lasts 60 ÷ BPM ÷ 4 seconds.

The BPM reference is a quarter note, not an eighth or sixteenth note. In the Online Drum Machine, every pattern contains 16 equal sixteenth-note steps, so four consecutive steps add up to the quarter-note pulse represented by the selected tempo.

how is the timing calculated when i use online drum machine
How Is Timing Calculated in an Online Drum Machine?

What the timing formula represents

Start with the duration of one quarter note, which is 60 divided by the BPM value. The grid places four sixteenth-note steps inside that quarter note, so the duration of one step is 60 ÷ BPM ÷ 4. A complete pass through the 16-step grid therefore lasts 240 ÷ BPM seconds.

Timing element Meaning Effect on playback
Tempo in BPM Quarter notes per minute Sets the duration of the underlying pulse
Quarter-note beat Four sixteenth-note grid steps Provides the main tempo reference
Sixteenth-note step One grid cell Defines the interval between adjacent possible drum hits
16-step pattern Four quarter-note beats Wraps from step 16 back to step 1

Only enabled cells create sound events. If the kick is active on a step, its start time is calculated from that step; inactive cells pass through without a kick. The same rule applies independently to the snare and hi-hat. This tempo convention matches the quarter-note definition used by the MusicXML sound element.

Calculate the timing for a chosen tempo

Substitute the selected BPM into the step formula. At the default 120 BPM, 60 ÷ 120 ÷ 4 = 0.125 seconds per step, and 16 × 0.125 = 2 seconds for one complete pass through the grid. A higher BPM produces shorter steps and a faster loop; a lower BPM produces longer steps and a slower loop.

You do not need to round the result before using it. For another tempo, enter its whole-number BPM value and apply the same formula. Remember that a note placed on every other sixteenth-note cell is an eighth-note pattern, while a note on every cell represents continuous sixteenth notes. The tool itself uses straight sixteenth-note timing and does not add swing.

Set, play, and verify the timed loop

  1. Open the Online Drum Machine and enter a whole-number tempo from 40 through 240 in the BPM field.
  2. Review the starting pattern if needed. It begins with a four-on-the-floor kick, snare on beats two and four, and closed hi-hat on eighth-note positions; it is only a starting point.
  3. Click cells in the kick, snare, and hi-hat rows to switch individual sixteenth-note steps on or off.
  4. Press Play. The browser creates the audio context only after this user action and begins looping the synthesized pattern.
  5. Follow the moving step outline to see the current position in the 16-step sequence. It identifies the active step, but it is not a latency-calibration display.
  6. Press Stop to release playback resources. Use Clear pattern when you want all 48 cells switched off and a completely silent starting grid.

No sample files are downloaded or uploaded. The kick comes from a short oscillator with a decaying pitch, while the snare and hi-hat use locally generated noise shaped by filters and gain envelopes. For a wider explanation of how the rows and cells form a loop, see 16-step sequencer basics.

How Web Audio keeps the scheduled beat

The browser uses a look-ahead scheduler rather than treating delayed JavaScript callbacks as the musical clock. A lightweight timer checks every 25 milliseconds and places upcoming events as far as 100 milliseconds ahead on the Web Audio API AudioContext timeline. Each sound source then uses its scheduled start time, so a busy timer callback does not directly determine when the hit becomes audible.

Shared timing logic calculates the step number, event timestamp, and active-track snapshot. After step 16, the sequence wraps to step 1 through modulo-16 logic. Because playback consumes those same functions, there is no separate production schedule using a different tempo formula.

You can continue changing pattern cells while playback is running. An edit is read by the upcoming scheduling window, allowing the loop to reflect the new active or inactive cells without restarting the pattern. All timing and synthesis happen in the browser; no network calculation is required.

Change tempo without mixing two schedules

Tempo is not changed live in this focused tool. Editing the BPM value during playback stops the current run and releases its audio context. After entering a valid value, press Play again to start cleanly at step one. This prevents already scheduled events at the old tempo from continuing alongside events calculated at the new tempo.

  1. Enter the new BPM as a whole number between 40 and 240.
  2. If playback was active, allow the tool to stop the current run before applying the new value.
  3. Correct the field if the interface shows a recoverable error.
  4. Press Play and use the moving outline to confirm that the loop has restarted from step one.

The input is strict. Empty fields, decimal fractions, plus or minus signs, exponent notation, unit text, and values outside 40–240 produce a recoverable error rather than an approximate tempo. Correcting the value allows another playback attempt.

Understand the limits of this timing model

The formula determines the intended event schedule, but it is not a guarantee of identical recording or synchronization across every device. The Online Drum Machine is not a digital audio workstation or AudioWorklet engine, and it does not promise sample-identical rendering. Heavy browser throttling, suspended tabs, device changes, high system load, and operating-system audio latency can still affect what you hear.

  • The grid always contains 16 straight sixteenth-note steps; swing and triplets are not supported.
  • Arbitrary time signatures are outside the tool’s scope because the grid is fixed at four quarter-note beats.
  • Velocity, accents, per-track volume, and effects are not available.
  • Recording, export, and MIDI synchronization are not included.
  • Background-tab playback has no guarantee.

The 40–240 BPM range is a deliberate usability and scheduling guard, not a claim about the musical limits of tempo. For production arrangement, rendered stems, exact inter-device synchronization, or latency calibration, transfer the pattern concept to a dedicated music application.

Check the timing when playback seems off

  1. Confirm that the BPM field contains an accepted whole number from 40 through 240.
  2. Watch the moving outline to verify that the visual step position is advancing and wrapping normally.
  3. After changing BPM, press Play again so playback begins from a clean schedule at step one.
  4. Keep the tab active and the audio output stable when judging fine timing, because throttling, hardware changes, and system load can affect the result.
  5. If audio initialization or event scheduling fails, read the recoverable message and make another Play attempt rather than assuming the tool is still playing.

Finally, distinguish scheduled timing from sound character. The synthesized voices are intentionally simple, and their exact tone can vary with browser audio implementation, output hardware, sample rate, and generated noise. That variation may affect how a transient is perceived without changing the underlying BPM calculation. Keep the device volume moderate before pressing Play, particularly with headphones.

Related reading: How Is an Online Metronome's Click Interval Calculated?.