chapter 3
signals
In the previous lessons we've explored how to create sound is (vibrations in the air) digitally by telling our speakers how to vibrate. We do this by creating an Audio Buffer, which can contain multiple channels (an array/list of values) each responsible for a different. These channels are filled with samples a value from -1 to 1 which represents the speakers position in that moment. The amount of samples, or values, we store for every second of sound buffer is called the Sample Rate, recorded in samples-per-second like 44.1K Hz or 48K Hz.
As we covered in the last lesson, we can load this buffer data from audio files (like mp3, wav or ogg like the bird sounds in this Tone.Player example) and, as we covered in the first lesson, at the lowest level we could create buffers ourselves algorithmically (like this randomized buffer, aka "white noise"). When it comes to electronic music, one of the most useful buffers we can create is a serious of oscillating values, what we call a sine wave. To our ears this sounds like a consistant tone, a musical note, the more extreme the peaks (the maximum and minimum value we're oscillating between) the louder the tone sounds to us, the faster the oscillation (time it takes to go from one peak value to the next) the higher the pitch sounds to us. The formula for this is defined below (refer to the Sine Wave Buffer demo to see it in context).
With this low level access there is no audible sound we can't synthesize. However, while working at this low level allows for all sorts of algorithmic experimentation, if what we want to do is create a simple tone, a sound wave defined by predictable periodic vibrations, then it's much easier to use one of Tone.js's built in Oscillators than create it ourselves from scratch.