How it works
A textbook figure of FIR design by the window method. The target is an ideal band (gain 1 between two edges, 0 elsewhere), drawn as a dashed step over a pale fill. Its ideal impulse response is infinitely long; the filter keeps 17 taps of it, h[−8] to h[8], multiplied by a rectangular or a Hamming window, and the solid line is the magnitude of the resulting response from 0 to π. The stem plot under it shows the 17 taps. The readout gives the overshoot (how far the response rises above 1) and the edge width (the widest 10% to 90% transition): a rectangular window keeps the edges steep but rings by about 9% (the Gibbs phenomenon), a Hamming window removes the ringing and doubles the edge width. When the band is narrower than 17 taps can resolve, the note says how high the response gets.
Use it for
- Teach why a finite filter cannot have a brick-wall response, and what a window trades: ringing against edge width.
- Let learners draw low-pass, band-pass and high-pass targets and watch the taps change shape.
Look elsewhere when
- For designing a production filter, use a design tool with more taps and an equiripple method: this figure fixes the length at 17 and offers two windows.
Usage
import React, { useState } from 'react'
import { FirTemplateBench } from './FirTemplateBench.jsx'
export function FilterLesson() {
const [band, setBand] = useState({ low: 0.25, high: 0.6 })
return (
<FirTemplateBench
value={band}
onChange={(next, { taps, overshoot }) => setBand(next)}
defaultWindowShape="hamming"
labels={{ title: 'A band-pass filter with 17 taps' }}
/>
)
}Props
| Prop | Type | Default | What it does |
|---|---|---|---|
value | { low, high } | — | Controlled target band, its edges as fractions of π (the Nyquist frequency) from 0 to 1, snapped to 0.05 and at least 0.05 apart. A low of 0 makes a low-pass filter, a high of 1 a high-pass. |
defaultValue | { low, high } | { low: 0.25, high: 0.6 } | Starting band when uncontrolled, and what Reset returns to in both modes. |
onChange | (band, result) => void | — | Called with the new band and { reason ('drag', 'draw', 'tap', 'key', 'cancel' or 'reset'), edge ('low', 'high' or null), taps (17 numbers, h[−8] to h[8]), overshoot (a fraction), edgeWidth (a fraction of π, or null) }. |
windowShape | 'rectangular' | 'hamming' | — | Controlled window applied to the 17 taps. |
defaultWindowShape | 'rectangular' | 'hamming' | 'rectangular' | Starting window when uncontrolled, and what Reset returns to. |
onWindowShapeChange | (shape, { reason }) => void | — | Called when the window changes, with reason 'press', 'key' or 'reset'. |
labels | object | — | Replaces any built-in text: title, caption, target, response, taps, window, rectangular, hamming, low, high, overshoot, edgeWidth, hint, narrow ('{peak}') and reset. |
locale | string | 'en' | Language tag for the numbers. |
className | string | — | Extra class on the card, for example to set its width (30rem by default, never wider than its container). |
Accessibility
- The two edges are sliders named Lower edge and Upper edge, with value text such as 0.25π. Arrow keys move an edge by 0.05π, Shift and Page Up or Down by 0.2π, Home and End to the ends of its range; the edges never cross.
- The window is a radio group with one tab stop; arrow keys change it. Reset is a button, marked unavailable while nothing has changed.
- The readout is a polite live region with the overshoot, the edge width and a note. The stem plot is an image whose name lists the 17 taps.
- Dragging uses pointer capture. A press near an edge drags it; elsewhere a sideways drag draws a new band and a tap moves the nearest edge there. The edge strips set touch-action: none; the rest of the plot sets pan-y, so a vertical swipe still scrolls the page. Escape or a cancelled gesture puts the band back.
- Colour is not the only key: the target is dashed and the response solid, the legend names both, and the edges carry their values above the plot.
Motion
Nothing animates: the response, the taps and the readout redraw on every input, and a dragged edge follows the pointer directly. Only hover and press feedback use transitions, and reduced motion turns them off.
Add it to your project
Pro members copy a prompt and their coding agent installs the source, the same way as the free components.
FirTemplateBench.jsxfir-template-bench.csstokens.cssREADME.md
Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.



