1Desired gain on the bin grid
Each DFT bin sits at k × fs ÷ N. Bins inside the band get gain 1, the rest get 0. Only bins 0 to N/2 (0 Hz to fs/2) are set here.
2Mirror the negative frequencies
Bins above N/2 are negative frequencies. Copy H[N − k] = H[k] so the inverse DFT gives real coefficients.
3Inverse DFT
Add up one cosine per active bin. The peak lands at n = 0 and the left half wraps round to the right end.
4Rotate to the middle
Shift every coefficient right by floor(N/2) places. The filter now uses only past samples. Every frequency is delayed by the same amount.
5Apply the window
Multiply each coefficient by the window value at the same position. The ends taper toward zero, which reduces ripple and lobes.
6Frequency response
Gain at 1024 frequencies from 0 to fs/2, including the gaps between bins. Hover a plot to read values.
7Save the coefficients
C and Python files save as .txt; rename to .h or .py after saving.