liveBook · Manning

Sawtooth wave

As explained in Learn Haskell by Example

A sawtooth wave is a periodic waveform formed by a linear slope followed by a discontinuous reset.

A sawtooth wave is a repeating linear slope: for an input t from 0 to 1, its sample value is (2 * t) - 1. Inputs outside that interval are held constant. section 10.1.2

Generate a sawtooth tone

Represent the waveform as `type Wave = Double -> Sample`, then generate a 220 Hz tone for five seconds with `tone saw 220 5`. The tone function repeatedly maps normalized period positions through `saw`, using modulo arithmetic to restart each period.

How Learn Haskell by Example covers it

How deep it goes
Explains the ramp formula, boundary behavior, normalized sampling, and tone construction, but not waveform synthesis internals.
Examples
Uses a Haskell `saw` function, a 220 Hz five-second tone, and exported waveform audio.
What you can do after
Build it from scratch as a normalized waveform and use it to produce sampled tones.
How it connects
Connects waveforms to functions, sampling, frequency, period, tones, and audio signals.

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.