What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To make a browser control change sound on the next beat, schedule the audio event in advance on the Web Audio API’s audio timeline. Do not start sound from a JavaScript timer or animation callback when the beat arrives: those callbacks can jitter. Keep the audio event’s target time separate from the visual update that shows the beat.

Why JavaScript timers should not start the sound

A browser sequencer has two timing jobs: decide when audio should play, and update the interface so it reflects that event. JavaScript timers are useful for waking a scheduler periodically, but their callbacks are not a reliable audio clock. If a callback runs late and only then starts a sound, the beat can slip.

Web Audio provides a separate timeline. An AudioContext exposes currentTime in seconds on that timeline, and scheduled source-node events use times on the same timeline. The Web Audio specification defines scheduled times relative to the context’s currentTime (W3C Web Audio API 1.1 Working Draft; MDN: BaseAudioContext.currentTime; MDN: AudioScheduledSourceNode.start()).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build a look-ahead scheduler

Rather than asking JavaScript to start a sound exactly when a beat is due, periodically check which beats are approaching and schedule them before their target times. This is the look-ahead pattern in MDN’s step-sequencer tutorial: a timer checks whether notes fall within a scheduling window, then queues those notes on the audio timeline.

#1 Best Overall
Sale
Apple AirPods Pro 3 Wireless Earbuds with Active Noise Cancellation
  • WORLD’S BEST IN-EAR ACTIVE NOISE CANCELLATION — Removes up to 2x more unwanted noise than AirPods Pro 2* so you can stay fully immersed in the moment.*
  • BREAKTHROUGH AUDIO PERFORMANCE — Experience breathtaking, three-dimensional audio with AirPods Pro 3. A new acoustic architecture delivers transformed bass, detailed clarity so you can hear every instrument, and stunningly vivid vocals.
  • HEART RATE SENSING — Built-in heart rate sensing lets you track your heart rate and calories burned for up to 50 different workout types.* With iPhone, you will have access to the Move ring, step count, and the new Workout Buddy,* powered by Apple Intelligence.*
  • LIVE TRANSLATION — Communicate across language barriers using Live Translation,* enabled by Apple Intelligence.*
  • EXTENDED BATTERY LIFE — Get up to 8 hours of listening time with Active Noise Cancellation on a single charge. Or up to 10 hours in Transparency using the Hearing Aid feature.*
  1. Use one context as the timing authority. Read the context’s currentTime for audio scheduling. Do not substitute Date.now(), which follows the system wall clock.
  2. Calculate the beat period. For tempo in beats per minute, seconds per beat is 60 / tempo. Keep the target time of the next beat, rather than deriving each new target from when a timer happens to fire.
  3. Wake the scheduler periodically. On each wake, compare the next beat’s target time with audioContext.currentTime + scheduleAheadTime. Schedule every event whose target is inside that window.
  4. Advance from the planned event time. After scheduling a beat, add one beat period to its target time. This prevents timer delays from becoming the new timing baseline.
  5. Keep event metadata. Store the beat number and target audio time for each scheduled event so the audio and visual layers can refer to the same event.

MDN’s tutorial uses a 25 ms check interval and a 0.1-second scheduling window as example values. They illustrate the technique, not a universal prescription. Choose and validate values for the application and devices you support.

Separate the audio event from the visual beat indicator

When the scheduler finds a beat inside its look-ahead window, it should start or otherwise control the relevant audio node at that beat’s future target time. For example, a source node can be scheduled with start(targetTime). The event is therefore already queued when the beat becomes due; it does not depend on the next UI callback.

Rank #2
JBL Vibe Beam - True Wireless Earbuds - Black
  • JBL Deep Bass Sound: Get the most from your mixes with high-quality audio from secure, reliable earbuds with 8mm drivers featuring JBL Deep Bass Sound
  • Comfortable fit: The ergonomic, stick-closed design of the JBL Vibe Beam fits so comfortably you may forget you're wearing them. The closed design excludes external sounds, enhancing the bass performance
  • Up to 32 (8h + 24h) hours of battery life and speed charging: With 8 hours of battery life in the earbuds and 24 in the case, the JBL Vibe Beam provide all-day audio. When you need more power, you can speed charge an extra two hours in just 10 minutes.
  • Hands-free calls with VoiceAware: When you're making hands-free stereo calls on the go, VoiceAware lets you balance how much of your own voice you hear while talking with others
  • Water and dust resistant: From the beach to the bike trail, the IP54-certified earbuds and IPX2 charging case are water and dust resistant for all-day experiences

The interface should use the event queue to show which beat is due, comparing each event’s target time with the audio context’s current time. MDN’s sequencer tutorial follows this separation by queuing note times for audio and consulting those times while drawing the interface. An animation callback can update the highlight, but it should not be the clock that starts the sound.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Account for tempo changes and context suspension

Tempo changes

At a steady tempo, advance the next target by the current beat period. If the user changes tempo, define how that change affects already queued beats: preserve their scheduled times and apply the new period to later beats, or cancel and rebuild the relevant future schedule. Whichever behavior fits the instrument, keep target times on the audio timeline rather than recalculating them from timer wake-up times.

Rank #3
Sale
Sony WH-CH520 Wireless On-Ear Bluetooth Headphones with Microphone, Blue
  • LONG BATTERY LIFE: With up to 50-hour battery life and quick charging, you’ll have enough power for multi-day road trips and long festival weekends.(USB Type-C Cable included)
  • HIGH QUALITY SOUND: Great sound quality customizable to your music preference with EQ Custom on the Sony | Headphones Connect App.
  • LIGHT & COMFORTABLE: The lightweight build and swivel earcups gently slip on and off, while the adjustable headband, cushion and soft ear pads give you all-day comfort.
  • CRYSTAL CLEAR CALLS: A built-in microphone provides you with hands-free calling. No need to even take your phone from your pocket.
  • MULTIPOINT CONNECTION: Quickly switch between two devices at once.

Suspended audio

An AudioContext’s currentTime stops advancing while the context is suspended. The wall clock may continue, so assuming both clocks stayed aligned can leave the beat counter or queued targets inconsistent. Pause or reconcile the beat state during suspension; after audio resumes, establish a consistent next event from the resumed audio timeline. See MDN’s currentTime reference.

Choose latency behavior for the interaction

The latencyHint option can express the kind of audio behavior an application prefers, but it does not guarantee a fixed end-to-end delay. MDN describes the default interactive hint as suitable when audio responds to user actions or should coincide with visual cues. The browser chooses a low latency it can manage without glitches, potentially using more power. The playback hint trades latency for playback time and lower power use (MDN: AudioContext()).

Rank #4
Sale
BERIBES Bluetooth Headphones Over Ear Wireless HiFi Stereo Headsets 65H 6EQ
  • 65 Hours Playtime: Low power consumption technology applied, BERIBES bluetooth headphones with built-in 500mAh battery can continually play more than 65 hours, standby more than 950 hours after one fully charge. By included 3.5mm audio cable, the wireless headphones over ear can be easily switched to wired mode when powers off. No power shortage problem anymore.
  • Optional 6 Music Modes: Adopted most advanced dual 40mm dynamic sound unit and 6 EQ modes, BERIBES updated headphones wireless bluetooth black were born for audiophiles. Simply switch the headphone between balanced sound, extra powerful bass and mid treble enhancement modes. No matter you prefer rock, Jazz, Rhythm & Blues or classic music, BERIBES has always been committed to providing our customers with good sound quality as the focal point of our engineering.
  • All Day Comfort: Made by premium materials, 0.38lb BERIBES over the ear headphones wireless bluetooth for work are the most lightweight headphones in the market. Adjustable headband makes it easy to fit all sizes heads without pains. Softer and more comfortable memory protein earmuffs protect your ears in long term using.
  • Latest Bluetooth 6.0 and Microphone: Carrying latest Bluetooth 6.0 chip, after booting, 1-3 seconds to quickly pair bluetooth. Beribes bluetooth headphones with microphone has faster and more stable transmitter range up to 33ft. Two smart devices can be connected to Beribes over-ear headphones at the same time, makes you able to pick up a call from your phones when watching movie on your pad without switching.(There are updates for both the old and new Bluetooth versions, but this will not affect the quality of the product or its normal use.)
  • Packaging Component: Package include a Foldable Deep Bass Headphone, 3.5MM Audio Cable, Type-c Charging Cable and User Manual.

Choose based on the interaction’s needs and test on target devices: prioritize responsiveness when immediate control matters, and consider the playback trade-off when sustained playback and power use matter more. Neither hint turns browser timing into a guarantee of identical perceived timing across devices.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use Web Audio directly or a music framework?

For a small sequencer, direct Web Audio makes the scheduling model explicit and gives the team control over its transport and event queue. The trade-off is that the application must implement and maintain those behaviors itself. For more complex interactive audio, MDN recommends considering Tone.js, which provides broader music-application facilities.

Best Value
Apple AirPods 4 Wireless Earbuds
  • REBUILT FOR COMFORT — AirPods 4 have been redesigned for exceptional all-day comfort and greater stability. With a refined contour, shorter stem, and quick-press controls for music or calls.
  • PERSONALIZED SPATIAL AUDIO — Personalized Spatial Audio with dynamic head tracking places sound all around you, creating a theater-like listening experience for music, TV shows, movies, games, and more.*
  • IMPROVED SOUND AND CALL QUALITY — AirPods 4 feature the Apple-designed H2 chip. Voice Isolation improves the quality of phone calls in loud conditions. Using advanced computational audio, it reduces background noise while isolating and clarifying the sound of your voice for whomever you’re speaking to.*
  • MAGICAL EXPERIENCE — Just say “Siri” or “Hey Siri” to play a song, make a call, or check your schedule.* And with Siri Interactions, now you can respond to Siri by simply nodding your head yes or shaking your head no.* Pair AirPods 4 by simply placing them near your device and tapping Connect on your screen.* Easily share a song or show between two sets of AirPods.* An optical in-ear sensor knows to play audio only when you’re wearing AirPods and pauses when you take them off. And you can track down your AirPods and Charging Case with the Find My app.*
  • LONG BATTERY LIFE — Get up to 5 hours of listening time on a single charge. And get up to 30 hours of total listening time using the case.*
Choice Fits when Trade-off
Direct Web Audio The sequencer is small, and the team wants to shape scheduling and transport behavior itself. More timing and music-application behavior must be built and maintained in the application.
Tone.js The application is more complex or would benefit from broader interactive-music features. The application relies on a framework rather than implementing all behavior directly with the browser API.

The choice is about complexity, desired scheduling control, and the value of additional music features—not a promise that one option eliminates timing constraints.

Know what the timing model cannot guarantee

currentTime advances in audio-rendering-block increments while a context runs, and browser privacy settings can reduce its exposed precision. Browser and configuration differences mean you should not promise identical timing behavior everywhere. Validate the scheduling window, visual update behavior, and latency choices with the devices and browsers your application needs to support (MDN: BaseAudioContext.currentTime).

Quick Recap

SaleBestseller No. 3
Sony WH-CH520 Wireless On-Ear Bluetooth Headphones with Microphone, Blue
Sony WH-CH520 Wireless On-Ear Bluetooth Headphones with Microphone, Blue
MULTIPOINT CONNECTION: Quickly switch between two devices at once.
$33.00
Bestseller No. 5

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.