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 ...