A tone is generated by repeating waveform samples at a chosen frequency until a requested duration is filled. Different waveforms change the sound’s timbre. section 10.1.2
Build a tone from these practical pieces:
- Represent a waveform as a function from a position between 0 and 1 to a sample value. section 10.1.2
- Compute the samples in one period from the frequency, then repeat their positions across the requested duration. section 10.1.2
- Use sine, square, sawtooth, or triangle waveforms to produce different signal shapes. section 10.1.2
- Clamp signal values before converting them to audio samples and writing a WAV file. section 10.1.2
Exporting four tones
Generate four five-second tones at 220 Hz by mapping `tone` over the sine, triangle, sawtooth, and square waves, concatenating the signals, and passing them to `writeWav`. section 10.1.2
Figure 10.2 Four standard waveforms
Compare the four standard waveform shapes to see how changing the signal function changes the generated tone. section 10.1.2
Abruptly stopping a tone can create an audible click because the waveform is cut off; contouring the signal, especially its ending, addresses this problem. section 10.2
Multiple tones become music when events specify each tone’s pitch, duration, and start time alongside periods of silence. section 10.3 section 10.3.1



