Time for action – adding the audio sequencer

Let's add the audio sequencer to the game panel. We will go into the GamePanel object and add an instance of AudioSequencer to it:

function GamePanel(audioManager)
    var sequencer = new AudioSequencer();

Next let's write the public setOptions() method, which is called from the startGame() method of PianoHeroApp. It takes three parameters; the song name, playback rate, and whether to play the game or the song in practice mode:

    this.setOptions = function(songName, rate, playGame)
        practiceMode = !playGame;
        return this;

The first thing we do is set the events() property of the audio sequencer to the data for the song to play. We get the song data ...

Get HTML5 Web Application Development By Example Beginner's guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.