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

You can generate a steady 528 Hz tone with a few lines of browser JavaScript: create an AudioContext, create an OscillatorNode, set its waveform to "sine", set frequency to 528, connect it to audioContext.destination, and start it from a button click. The browser synthesizes the tone; speakers or headphones are only needed to hear it. The complete example below includes Play and Stop controls, prevents duplicate oscillators, and creates a fresh oscillator whenever you play again.

What is a 528 Hz tone in the Web Audio API?

A 528 Hz tone is a periodic sound wave that completes 528 cycles per second. In the Web Audio API, an OscillatorNode is the source that generates this periodic waveform. The W3C specification describes it as an audio source generating a periodic waveform, while the browser handles the real-time sample generation and routing.

The number 528 is a frequency in hertz, not a volume setting or a special browser mode. An oscillator defaults to a 440 Hz frequency, so code must assign 528 explicitly. The default waveform is a sine wave, which produces the plainest single-frequency tone.

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

This implementation makes no health, therapeutic, or other scientific claim about 528 Hz. It simply synthesizes an audible frequency using a standard browser API.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

How do I generate the tone with a complete HTML file?

Save the following as an HTML file and open it in a modern browser. Clicking Play creates the audio context and oscillator; clicking Stop ends the current oscillator. A new oscillator is created on every subsequent Play, because an oscillator that has been stopped cannot be restarted.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>528 Hz tone</title>
</head>
<body>
  <button id="play" type="button">Play 528 Hz</button>
  <button id="stop" type="button" disabled>Stop</button>
  <p id="status" role="status" aria-live="polite">Stopped</p>

  <script>
    let audioContext;
    let oscillator;

    const playButton = document.querySelector("#play");
    const stopButton = document.querySelector("#stop");
    const status = document.querySelector("#status");

    function playTone() {
      // Do not create a second oscillator if one is already playing.
      if (oscillator) return;

      audioContext ??= new AudioContext();

      oscillator = audioContext.createOscillator();
      oscillator.type = "sine";
      oscillator.frequency.setValueAtTime(528, audioContext.currentTime);
      oscillator.connect(audioContext.destination);

      oscillator.onended = () => {
        oscillator = undefined;
        playButton.disabled = false;
        stopButton.disabled = true;
        status.textContent = "Stopped";
      };

      oscillator.start();
      playButton.disabled = true;
      stopButton.disabled = false;
      status.textContent = "Playing 528 Hz sine wave";
    }

    function stopTone() {
      if (!oscillator) return;
      oscillator.stop();
      oscillator.disconnect();
    }

    playButton.addEventListener("click", playTone);
    stopButton.addEventListener("click", stopTone);
  </script>
</body>
</html>

The first Play click initializes the context and connects the oscillator to the destination. The destination is the browser’s selected audio output, such as built-in speakers, an external speaker, or headphones. The Stop handler calls stop() and disconnects the node; the onended callback resets the controls so another Play click can create a new source.

What does each line of the JavaScript do?

Creating the audio context

new AudioContext() creates the graph in which audio nodes run. Keeping the context in audioContext means later plays can reuse the same graph instead of allocating a new context every time. The code creates it inside the button handler, which gives the user an explicit interaction point rather than attempting to make sound while the page loads.

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

Creating a periodic source

audioContext.createOscillator() returns an OscillatorNode. It is a periodic-wave source, so it can produce a constant tone without loading an audio file. The oscillator exists only for its current playback; once it has been stopped, discard it and construct another one.

Selecting a sine waveform

oscillator.type = "sine" chooses the default pure-sine shape explicitly. A sine wave has one fundamental frequency and is the simplest choice when the requirement is a plain 528 Hz tone. Changing the type changes the tone’s timbre even when the frequency remains 528 Hz.

Setting 528 Hz at the correct time

frequency is an AudioParam measured in hertz. The documented default is 440 Hz, so the assignment is essential. setValueAtTime(528, audioContext.currentTime) schedules the value at the context’s current timeline position, avoiding an accidental 440 Hz start.

Routing sound and starting playback

oscillator.connect(audioContext.destination) sends the generated samples to the system output selected by the browser. oscillator.start() begins generation. Without both the connection and the start call, the node will not produce audible output.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Stopping and cleaning up

stop() schedules the oscillator to end. Calling disconnect() removes its connection from the audio graph. The onended callback clears the variable only after the source has ended, which keeps the Play button disabled while the current source is still active and prevents overlapping tones.

How should Play and Stop controls handle repeated use?

Use one oscillator for one playback interval. Guarding playTone() with if (oscillator) return prevents every extra click from layering another tone at the same output. After Stop, the ended source is not reusable; the next Play must execute createOscillator() again.

  1. On Play, check whether an oscillator already exists.
  2. If none exists, reuse or create the AudioContext.
  3. Create a new oscillator, set its waveform and frequency, connect it, and call start().
  4. Disable Play and enable Stop while it is running.
  5. On Stop, call stop() and disconnect the node.
  6. When the node’s onended event fires, clear the reference and restore the button states.

This pattern also handles a source that ends for another reason: the callback returns the interface to the stopped state. If you do not need status text or disabled buttons, the shorter two-function version is sufficient:

let audioContext;
let oscillator;

function playTone() {
  audioContext ??= new AudioContext();
  oscillator = audioContext.createOscillator();
  oscillator.type = "sine";
  oscillator.frequency.setValueAtTime(528, audioContext.currentTime);
  oscillator.connect(audioContext.destination);
  oscillator.start();
}

function stopTone() {
  if (oscillator) {
    oscillator.stop();
    oscillator = undefined;
  }
}

That compact version is useful for a console experiment, but the full page is safer for a user-facing control because it blocks duplicate Play clicks and cleans up the connection.

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

Can a browser block the first sound?

Browsers can apply autoplay and user-activation policies, and those policies are not identical across platforms. Put the first call to playTone() behind a visible Play button rather than trying to start the oscillator during page load. This interaction pattern gives the browser a direct user action to associate with audio creation.

Some environments create an AudioContext in a suspended state until an interaction permits audio. If your page reports that state, call audioContext.resume() from the Play click handler before starting the oscillator:

audioContext ??= new AudioContext();
if (audioContext.state === "suspended") {
  await audioContext.resume();
}

Because resume() is asynchronous, make the handler asynchronous when using this variant:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
async function playTone() {
  if (oscillator) return;
  audioContext ??= new AudioContext();
  if (audioContext.state === "suspended") {
    await audioContext.resume();
  }
  oscillator = audioContext.createOscillator();
  oscillator.type = "sine";
  oscillator.frequency.setValueAtTime(528, audioContext.currentTime);
  oscillator.connect(audioContext.destination);
  oscillator.start();
}

The basic example does not claim that autoplay is universally allowed. Testing the page in the target browser and device remains important, especially when the page is embedded in another document or opened with the device muted.

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

What changes when I use another waveform?

Frequency and waveform are separate settings. Keeping frequency at 528 preserves the nominal oscillation rate, while type changes the harmonic content and therefore the perceived character.

Waveform Code value Typical character When to choose it
Sine "sine" Plain, smooth single-frequency tone Use for the simplest 528 Hz demonstration
Square "square" Sharper, buzzer-like sound with strong harmonics Use when you need an intentionally electronic timbre
Sawtooth "sawtooth" Bright and dense harmonic content Use for a more aggressive, bright tone
Triangle "triangle" Softer than square but richer than sine Use when a mild additional harmonic color is wanted
Custom setPeriodicWave() Defined by a custom periodic wave Use only when you need a specifically designed spectrum

For the requested plain tone, leave the waveform as "sine". A different waveform does not make the result “more 528 Hz”; it only changes the sound you hear around that fundamental frequency.

Where does the tone play?

The destination node follows the output device selected by the operating system and browser. If the system output is built-in speakers, the speakers play it; if wired or wireless headphones are selected, they play it instead. No dedicated tone generator or special physical product is required for synthesis.

  • Check the system volume and the browser tab’s mute state.
  • Confirm that the intended speakers or headphones are the current system output.
  • Use headphones if you want to listen without sending the tone through room speakers.
  • Keep the volume low when testing; a continuous tone can be uncomfortable at high levels.

The API does not choose a particular brand or model of listening equipment. It only routes the oscillator to audioContext.destination.

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

How can I verify that the oscillator is really set to 528 Hz?

Inspect the assignment in your code: oscillator.frequency.setValueAtTime(528, audioContext.currentTime) is the decisive setting. Do not rely on the oscillator’s default, because the documented default is 440 Hz. If you alter the code while experimenting, keep the number in hertz and ensure it is not accidentally quoted as a different value or replaced by a later automation event.

A browser’s output device, volume, or waveform selection changes how the tone sounds but does not change the value assigned to the oscillator’s frequency parameter. A custom waveform can add harmonics, so a spectrum analyzer may show additional components even though the oscillator’s fundamental setting remains 528 Hz.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

What are the most common problems and fixes?

There is no sound

  • Click Play rather than expecting sound on page load; browser activation rules may block automatic playback.
  • Check that the page is not muted and that the system output and volume are correct.
  • Confirm that oscillator.connect(audioContext.destination) appears before start().
  • Open the developer console and fix any JavaScript syntax error that prevents the handler from running.

Play works once but not again

A stopped OscillatorNode cannot be restarted. Create a new oscillator inside every Play operation and clear the old reference after it ends, as the complete example does.

Several tones are sounding at once

Each Play click may be creating another source. Keep the “already playing” guard, disable the Play button while active, or stop and clean up the existing oscillator before creating a replacement.

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

The tone sounds different from a pure sine wave

Check the type property. Square, sawtooth, triangle, and custom periodic waves contain different harmonic content. Set it to "sine" for the plainest tone.

Stop does not restore the controls

Use the node’s onended callback to reset the state after stop() completes. Avoid setting the variable to a new active-looking value before the old node has actually ended.

The page works on one device but not another

Output selection, mute state, browser audio policies, and hardware differ by device. Keep playback user-initiated, test with the intended browser, and provide a visible status message so a user can distinguish “not started” from “started but routed to another output.”

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How can I make the small demo more usable?

The API code is enough to synthesize the sound, but a few interface details make a practical page easier to operate:

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.
  • Use real buttons with accessible names instead of clickable text or a page-load side effect.
  • Disable Play while an oscillator is active and disable Stop while stopped.
  • Expose a status element such as “Playing 528 Hz sine wave” for screen readers and visual confirmation.
  • Keep the frequency value visible if users need to verify what is playing.
  • Offer a clear Stop action and avoid looping an audio file when a generated oscillator is all that is required.
  • Set a conservative initial volume if you later insert a gain node; the minimal example sends the oscillator directly to the destination.

If you add controls later, change one concern at a time: a frequency control changes the frequency AudioParam, while a waveform selector changes type. Do not recreate the whole context for every small adjustment unless your application has a specific reason.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

What does the browser need to run this example?

The page needs a browser implementation of the Web Audio API and JavaScript enabled. It does not need an audio file, a server-side component, a plug-in, or an installed desktop application. Opening the file directly is enough for a basic test; hosting it on a normal web page is useful when you want to share it or integrate it into a larger interface.

Because the source is generated in real time, the browser performs the synthesis locally and sends the result to its selected destination. Network access is not part of the tone-generation path once the page and script are available.

What should I remember about 528 Hz browser synthesis?

The essential implementation is a sine OscillatorNode with its frequency explicitly set to 528, connected to the audio context destination, and controlled with start() and stop(). Keep playback behind a user action, create a fresh oscillator after each stop, and treat speakers or headphones as optional listening outputs rather than requirements for generating the signal.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Frequently Asked Questions

Can I change 528 Hz to another frequency without rebuilding the page?

Yes. Assign another numeric value in hertz to the oscillator’s frequency AudioParam, preferably with setValueAtTime() or another AudioParam scheduling method. The same audio graph can then generate a different pitch, although a source that has already been stopped still needs to be recreated.

Does a 528 Hz oscillator play an audio file from the internet?

No. OscillatorNode synthesizes a periodic waveform locally in the browser. The page only needs an audio file if you intentionally replace the oscillator with a decoded recording or another sampled source.

Why is my 528 Hz tone not exactly the same loudness on every device?

The oscillator sets frequency and waveform, not a universal listening level. Operating-system volume, browser output selection, headphones, speakers, and any gain processing in the page affect perceived loudness.

Can I embed this tone generator in another website?

You can place the controls and script in an ordinary web page or component, provided the host environment allows the script to run. Test the embedded version separately because framing, focus, and browser user-activation policies can affect when audio is permitted to start.

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

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.