A triangle wave is a periodic waveform made from two opposing linear slopes. Across one cycle, its value rises from -1 to 1 during the first half, then falls back to -1 during the second. section 10.1.2
Implement one cycle as a Haskell function over a normalized position t:
- Keep values outside the valid range constant at -1; audio generation normally supplies positions between 0 and 1. section 10.1.2
Turning the wave into a tone
A tone function repeatedly maps normalized positions through the triangle wave. Taking each sample index modulo the number of samples in one period sets the frequency; mapping tri over those positions produces the signal.
