O'Reilly logo

Instant Audio Processing with Web Audio by Chris Khoo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Setting the volume (Simple)

Now that we've wrapped our heads around playing audio, it's time to look at controlling the sound volume. In this recipe, we'll build an audio player with real-time volume controls. We'll use a piano sound loop instead of the choir loop this time around to keep things fresh.

Getting ready

The complete source code for this recipe is available in the code bundle at recipes/Recipe4_1a.

How to do it...

  1. Start with a clean copy of the base framework template. The template bundle is located at tools/RecipeFramework in the code bundle.
  2. Open index.html with a text editor.
  3. In the HTML section, we'll add the piano loop toggle and the volume control widget:
    <div id="appwindow"> <h2>Setting The Volume</h2> <form> <input type="checkbox" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required