Design Subroutine for Symmetric FIR Low Pass Digital Filters with Maximally-Flat Pass and Stop Bands

Return to Main Software Page

C
C-----------------------------------------------------------------------
C MAIN PROGRAM: MAXIMALLY FLAT FIR FILTER DESIGN
C AUTHOR:       J. F. KAISER
C               BELL LABORATORIES, MURRAY HILL, NEW JERSEY 07974
C
C INPUT:        BETA IS THE CENTER OF THE TRANSITION REGION,
C                    0 < BETA < 0.5
C               GAMMA IS THE WIDTH OF THE TRANSITION REGION,
C                    0 < GAMMA < MIN( 2*BETA, 1-2*BETA )
C-----------------------------------------------------------------------
C
      DIMENSION A(200), B(200), C(200)
      COMMON IOUTD
C
C SET UP MACHINE CONSTANTS
C
      IND = I1MACH(1)
      IOUTD = I1MACH(2)
C
      LIMIT = 200
      READ (IND,9999) BETA
      READ (IND,9999) GAMMA
9999  FORMAT (E15.7)
      CALL MXFLAT(BETA, GAMMA, NP, A, B, C, LIMIT, IERR)
C
C PRINT RESULTS
C
      IF (IERR.GT.1) WRITE (IOUTD,9998) BETA, GAMMA
9998  FORMAT (10H FOR BETA=, F5.3, 11H AND GAMMA=, F5.3)
      GO TO (10, 20, 30, 40), IERR
  10  CALL PRCOEF(BETA, GAMMA, NP, B, LIMIT)
      STOP
  20  WRITE (IOUTD,9997)
9997  FORMAT (24H BETA NOT IN RANGE 0-0.5)
      STOP
  30  WRITE (IOUTD,9996)
9996  FORMAT (19H GAMMA NOT IN RANGE)
      STOP
  40  WRITE (IOUTD,9995)
9995  FORMAT (30H GAMMA TOO SMALL, MIN IS 0.04+)
      STOP
      END
C
C-----------------------------------------------------------------------
C SUBROUTINE:  PRCOEF
C PRINT THE FILTER COEFFICIENTS
C-----------------------------------------------------------------------
C
      SUBROUTINE PRCOEF(BETA, GAMMA, NP, B, LIMIT)
      DIMENSION B(LIMIT)
      COMMON IOUTD
      WRITE (IOUTD,9999) BETA, GAMMA, NP
9999  FORMAT(10H FOR BETA=, F5.3, 11H AND GAMMA=, F5.3, 13H NO. OF COEFS
     *    , 2H.=, I4)
      DO 10 I=1,NP
        WRITE (IOUTD,9998) I, B(I)
9998    FORMAT (3H B(, I3, 3H) =, F11.8)
  10  CONTINUE
      RETURN
      END
C
C-----------------------------------------------------------------------
C SUBROUTINE:  MXFLAT
C COMPUTE THE COEFFICIENTS OF A MAXIMALLY FLAT FIR LINEAR PHASE FILTER
C WITH ODD NUMBER OF TERMS AND EVEN SYMMETRY IN FILTER COEFFICIENTS
C-----------------------------------------------------------------------
C
      SUBROUTINE MXFLAT(BE,GA,NP,A,B,C,LIMIT,IERR)
C
C INPUT: BE = CENTER OF TRANSITION REGION
C           (BETA), 0
Return to Main Software Page