A triangle wave is the piecewise-linear waveform that rises linearly from −1 to +1, then falls linearly back to −1, repeating each period. Its Fourier spectrum has a specific signature: only odd harmonics, and they decrease as 1/n² — much faster than the square or sawtooth wave's 1/n. That fast roll-off is exactly why triangle waves sound noticeably softer and less buzzy than squares: there's far less high-frequency energy to bother the ear.
The amplitude rule (variable symmetry)
For a triangle wave with symmetry S — the fraction of the period spent on the rising slope — the n-th harmonic's magnitude is |Hn| = 2·|sin(πnS)| / (π² · n² · S · (1−S)). Two key consequences:
- At S = 0.5 (symmetric triangle), sin(πn/2) is zero for every even n, leaving only odd harmonics with the clean 8/(π²n²) coefficient. H1 sits at 8/π² ≈ 0.811, H3 at 8/(9π²) ≈ 0.090 (−19.08 dB), H5 at −27.96 dB, H7 at −33.80 dB — a steep, gentle roll-off.
- Any S ≠ 0.5 breaks the half-wave symmetry, so even harmonics appear. At S = 0.3 the H2 magnitude is already 23% of H1.
- The limits S → 0 (or S → 1) collapse the triangle into a falling (or rising) sawtooth, where the formula converges to 2/(πn) — the well-known sawtooth amplitude envelope with all harmonics present and a slow 1/n decay.
Comparison to square & sine
The toggle overlay puts the textbook analytical shape on the same plot. Three useful comparisons:
- vs Sine — both are smooth (no discontinuities), but a sine has only one harmonic, while a symmetric triangle has the H1, H3, H5… stack. The triangle sounds "almost like" a sine but with a faint buzz from the high-order partials. You can confirm this directly by loading a pure sine tone alongside the triangle to hear the difference.
- vs Square (50% duty) — same odd-only harmonic set but with 1/n vs 1/n² amplitude rule. The square has H3 at −9.54 dB while triangle has it at −19.08 dB. Square sounds harsh; triangle sounds mellow. The square wave generator lets you adjust duty cycle to compare intermediate shapes.
- vs Sawtooth — sawtooth has all harmonics (odd AND even) with 1/n decay. Triangle has only odd with 1/n² decay. Very different timbres; the sawtooth's much denser harmonic series gives it the characteristic buzzy, brassy quality used for string and brass patches in subtractive synthesis.
Why 1/n² instead of 1/n?
The amplitude of a Fourier harmonic for a periodic waveform scales as 1/n raised to (k+1) where k is the order of the lowest-order discontinuity in the waveform. A square wave is discontinuous in its value (k = 0), giving 1/n. A triangle is continuous but its slope is discontinuous (k = 1), giving 1/n². A cubic-spline waveform would give 1/n³, and so on. The smoother the shape, the faster the spectrum falls off — a principle central to both audio synthesis and signal processing theory.
Psychoacoustics: why triangle sounds soft
The perceptual "softness" of the triangle wave has a direct physical basis. Because harmonic energy falls as 1/n², the content above 2–3 kHz is extremely weak. Human hearing is most sensitive between 2–5 kHz (the Fletcher–Munson equal-loudness peak), so waveforms with little high-frequency energy sound quiet and non-fatiguing even at moderate amplitudes. By contrast, the square wave's 1/n rolloff keeps significant energy in the 3–10 kHz range, producing the characteristic "buzzy" quality the ear finds much more alert-and-arousing. Triangle is therefore the preferred oscillator waveform for pad sounds, soft leads, and sub-bass in electronic music production. This generator synthesises the waveform using the Web Audio API's PeriodicWave interface, which lets the browser construct an exact band-limited additive sum of the chosen harmonics without aliasing artifacts.
Why does the triangle look almost like a sine in the comparison overlay?
Because they're spectrally very close. A triangle's H1 contains ~95% of its total energy; everything else is at least 19 dB lower. A sine wave is 100% H1 with everything else literally zero. Visually a 5% perturbation in the waveform shape is hard to spot — the difference is the pointy corners at the peak and trough vs the smooth tops of a sine. Audibly, the triangle's small high-order content adds a subtle reedy quality.
Why does the sawtooth overlay look infinitely sharp while the triangle has ringing?
The dashed-cyan comparison overlays (sine, square, sawtooth) are drawn from their textbook analytical formulas — they have infinite bandwidth and so look mathematically perfect. The green triangle is band-limited to the same harmonic count as the audio engine, so it shows the Gibbs ringing that real digital playback always produces. If you band-limited the comparison overlays the same way, you'd see the sawtooth's vertical drop pick up identical ringing at its discontinuity, and the square's edges round off too. The contrast is intentional — it's "textbook ideal vs what your speaker actually plays".
What happens as I push symmetry to the extremes?
The rising and falling slopes become drastically unequal. At S = 0.1 the wave rises in 10% of the period, then falls slowly over 90% — that's almost a falling sawtooth. The harmonic spectrum fills out: even harmonics emerge, the H1 amplitude shrinks slightly, and the high-order falloff slows from 1/n² toward 1/n. The audible character shifts from soft / pure to brighter / brassier.
Why is the symmetric triangle "perfect" (no even harmonics)?
It has half-wave symmetry: f(t + T/2) = −f(t). Mathematically, this exact symmetry forces every even Fourier coefficient to zero — it's an algebraic identity, not a numerical coincidence. The instant you break that symmetry (S deviating from 0.5), even harmonics pop into existence and grow as the asymmetry grows.
Why does the waveform have rounded peaks instead of sharp corners?
Band-limited reconstruction. The audio engine sums only the first 60 harmonics (or fewer at high fundamentals — capped at Nyquist), so transitions take finite time and the peak corners show small Gibbs-style oscillations. This is what your speaker actually plays — an ideal infinitely-sharp corner is impossible at any finite sample rate.
Is the triangle wave used in real music synthesis?
Yes — extensively. Triangle is the staple "soft lead" or "soft bass" oscillator on virtually every analog synth (Moog, Sequential, Korg, Roland) and most modern digital synths. Its low harmonic content makes it a good starting point for additive synthesis ("triangle plus filter envelope") and FM-style harmonic shaping. Game audio also relies on triangle for "chiptune" lead voices — it's the classic NES pulse-1/triangle channel sound.
Why does the spectrum bar chart show only odd harmonics at S = 50%?
Because the H2, H4, H6 … bars have amplitude exactly zero from the |sin(πn·0.5)| factor in the formula (sin of any integer × π is zero). In the plot they sit at the −80 dB floor (invisible). Drift the symmetry slider just one tick away from 50 and the even bars instantly appear, growing as the symmetry asymmetry deepens.
Can I play a triangle wave at any audible frequency?
The slider caps at 5 kHz to give the 60-harmonic synthesis enough Nyquist headroom (H60 at 5 kHz = 300 kHz; at typical 48 kHz sample rate that's way above 24 kHz Nyquist). The tool reduces the harmonic count automatically as you raise the frequency — by 5 kHz you're effectively hearing just a few harmonics, which is fine: the higher partials are inaudible above ~12-16 kHz anyway.
Is this safe for speakers / ears?
Triangles are gentler than squares but louder than sines. At the default 10% volume they're safe; ramp up gradually. Triangle waves don't carry the brutal high-frequency content that makes squares fatiguing, so longer listening sessions are practical — but the underlying audio hygiene (start low, no extended high-volume listening) still applies.
How does the triangle wave's THD compare to other waveforms?
At S = 50%, the symmetric triangle wave has a theoretical total harmonic distortion of about 12.1% — all contributed by odd harmonics (H3, H5, H7…). A 50%-duty square wave has much higher THD (~48.3%) because of its slower 1/n harmonic falloff. A pure sine has 0% THD by definition. The THD readout in the Spectral Character panel shows the computed value for whatever symmetry and frequency you've set, so you can watch THD rise as you drag symmetry toward the sawtooth extremes.
Can I use this tool for ear training in music theory?
Yes — the comparison overlay is especially useful for ear training. Set a note pitch (e.g., 440 Hz), overlay a square wave, and actively listen for how the H3 and H5 add "bite". Then switch to the sine overlay and notice how the triangle's tiny residual harmonics add a subtle reedy quality a pure sine lacks. Repeating this process at different pitches builds reliable recognition of harmonic timbres, which directly improves your ability to distinguish intervals and overtone series on acoustic instruments. You can also verify what you hear using the
Harmonic Balance Analyzer with a microphone.
Why does the triangle wave appear on vintage oscilloscopes and signal generators as a test waveform?
Triangle waves are a standard linearity test signal in electronics. Because the waveform is piecewise-linear (constant slope), any deviation from a perfectly straight rise or fall is immediately visible as curvature — a direct measure of amplifier non-linearity or slew-rate limiting. The 1/n² harmonic rolloff also means a triangle leaves relatively little spectral clutter above the fundamental, making it easier to isolate distortion products in a frequency-domain measurement. Square waves test bandwidth (edge sharpness); triangle waves test linearity and slew rate.