A simple low-pass filter
Go back to the main gmeteor page.gmeteor

A simple low-pass filter

Frequency response:

Input specification:

;; This example shows how to design a simple low-pass filter.  To run
;; this example, type `gmeteor example-1.scm' at the command-line
;; prompt.

;; The semicolon `;' introduces a comment, which lasts until the end
;; of the line.

;; we first give a title to the filter.  The title appears on the
;; output file in verbose mode.
(title "A simple filter")

;; set verbose mode on.  Note that in Scheme, `#t' denotes the TRUE
;; value.  FALSE is denoted by #f.
(verbose #t)

;; our filter has cosine (i.e., even) symmetry, and its length is 10
(cosine-symmetry)
(filter-length 10)

;; we want a sampling frequency of 60 Hz.
(sampling-frequency 60)

;; Now we specify the frequency reponse.  The passband is from 0 to 10
;; Hz, and the frequency response should be 1 in this band.  From now
;; on, we denote the frequency response by H(f), where `f' is the
;; frequency.

(limit-= (band 0 10) 1)

;; The expression `(band A B)' builds a band.  As we shall see in more
;; advanced examples, in gmeteor you can specify H(f) for particular
;; values of f, not just bands.  The expression `limit-=' establishes
;; an equality constraint: we state that H(f) should be equal to 1.
;; In gmeteor, you can also specify inequality constraints, but we do
;; not discuss this case in this first example.

;; The stopband is from 20 to 30 Hz.  H(f) should be 0 in the
;; stopband.
(limit-= (band 20 30) 0)

;; We now specify an output file and a plot file.  The output file
;; contains the filter coefficients, and possibly additional
;; information in verbose mode.  The plot file contains H(f) in a
;; simple X-Y format that can be viewed using gnuplot or any other
;; plotting program.
(output-file "example-1.coef")
(plot-file "example-1.plot")

;; By default, gmeteor prints the filter coefficients to standard
;; output, and does not produce a plot file.

;; We now tell gmeteor to design the filter and compute the output.
;; If you forget the (go) command, gmeteor does not compute anything.
(go)

;; You can now run this example file and look at the output.


This page maintained by: Matteo Frigo. Last updated: Sun Jan 6 06:31:03 2013 .

SourceForge Logo