13 WRITING A SONG

You’ve now learned enough about the basics of Tone.js and sound synthesis to write a simple song. Our song is going to be made up of a few instruments: the drums we developed in the previous chapter, the trumpet sampler, two different synth bass parts, and some chords played on another synth.

Getting Organized

Our song will reuse a lot of the code from the previous chapter, but we’ll reorganize it to make it easier to follow how the song is built. The index.html file will be exactly the same as in Chapter 12, but we’ll start from scratch with a new script.js file, which we’ll organize into four logical sections:

Instruments ...

Get JavaScript Crash Course now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.