A pulse wave periodically alternates between low and high levels. Its duty cycle controls how much of each period remains low or high; a square wave is the 50% case. section 10.1.2
In a signal-based audio program, pulse waves support these practical choices:
- Represent a waveform as a Haskell function from a time value to a sample. section 10.1.2
- Generate repeating period values for a chosen frequency and duration, then map the waveform across them. section 10.1.2
- Extend the square-wave implementation into a generic oscillator with an adjustable duty cycle. section 10.1.2
Exporting pulse-wave audio
Generate tones from several waveforms, concatenate them, clamp the resulting signal, and use HCodecs to export a WAV file. Changing the duty cycle changes the sound characteristics. section 10.1.2
Figure 10.2 Four standard waveforms
Compare the shapes of standard periodic waveforms, including the square-wave form used as the 50% duty-cycle pulse wave. section 10.1.2
