liveBook · Manning

Pulse wave

As explained in Learn Haskell by Example

A pulse wave is a periodic waveform that alternates between low and high levels for configurable portions of each period.

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
figure

Compare the shapes of standard periodic waveforms, including the square-wave form used as the 50% duty-cycle pulse wave. section 10.1.2

How Learn Haskell by Example covers it

How deep it goes
Defines duty cycle and generates repeating samples, then stops short of covering array internals.
Examples
Demonstrates square waves, adjustable-duty-cycle oscillators, concatenated tones, and exported WAV audio.
What you can do after
Apply pulse waves in Haskell by implementing duty-cycle control and exporting generated signals with HCodecs.
How it connects
Connects pulse waves with square waves, duty cycle, waveforms, signals, oscillators, and WAV files.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Haskell by Example. The section links point to the parts of the book it draws on.