A square wave is a periodic waveform that switches between two constant sample levels. Represent it as a Haskell function from a phase value between 0 and 1 to a sample value. section 10.1.2
Define and use a square wave
Use a threshold at the midpoint of each period: sqw :: Wave sqw t | t <= 0.5 = -1 | otherwise = 1 tone sqw 220 5 The tone function repeatedly scans phase values across the period, maps them through sqw, and produces samples for a 220 Hz, five-second signal. section 10.1.2
Figure 10.2 Four standard waveforms
Compare the square wave’s two-level shape with sine, sawtooth, and triangle waveforms. section 10.1.2
