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

Playing audio in a loop (Simple)

Now that we can play sounds using an audio buffer, let's take a look at playing them in a loop. In this recipe, we'll create an application with a toggle button which toggles the playback of a choir loop.

Getting ready

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

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, declare the HTML toggle control:
    <div id="appwindow">
        <h2>Playing Audio In A Loop</h2>
        <form>
            <input type="checkbox" id="choir" />
            <label for="choir">Choir Loop</label>
        </form>
    </div>
  4. We'll need the Web Audio ...

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