O'Reilly logo

HTML5 Web Application Development By Example Beginner's guide by J.M. Gustafson

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

Creating an audio sequencer

Before we can play the game, we need some way to play songs on the piano by playing back notes in a certain order, at the correct time, and at the correct speed. We will create an object called AudioSequencer that takes an array of musical event objects and turns them into music.

To implement our audio sequencer we need to define a format for our music events. We will roughly follow the MIDI format, but much more simplified. MIDI is the standard to record and play back music events. Each event contains information about how and when to play notes, or turn notes off.

Our event object will contain three fields:

  • deltaTime: The amount of time to wait before executing the event.
  • event: This is an integer event code that determines ...

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