#### Table of Contents

#### Introduction

The half band filter is an incredibly efficient filter useful in a number of applications as well as a great starting point for understanding fundamental DSP concepts. Previous posts covered the design of the filter weights and how to optimize the filter structure for computational efficiency. This blog posts simplifies the design of the half band filter weights using a Python function.

Don’t forget to check out the other posts on the half band filter:

#### Half Band Filter Design Function

The design function halfBandDesign.py can be downloaded from the WaveWalkerDSP GitHub page. The function is called by:

`from halfBandDesign import halfBandDesign`

weights = halfBandDesign(filterLength,transitionBand)

where filterLength is the length of the filter and transitionBand is the normalized bandwidth of the transition band.

The parameter filterLength must be an integer greater than 6 such that filterLength+1 is divisible by 4. For example, filterLength can be 7, 11, 15 or 19. This avoids a situation where a zero weight is added to the beginning and end of the filter’s impulse response which is wasted computation. The parameter transitionBand must be greater than 0 and less than 0.5.

The function performs error checking on the input parameters to make sure the weights are generated to maximize efficiency, abstracts the Remez design function call and forces all even index weights to be exactly zero.

#### Example Half Band Filter Design

Figure 1 and Figure 2 give the impulse response and frequency response when halfBandDesign.py is called with filterLength=19 and transitionBand=0.1.

#### Conclusion

The halfBandDesign.py function designs an efficient half band filter. The error checking on the parameters force the weights to be designed with maximum computational efficiency.

Have you seen the other posts on the half band filter?