I had added bindings earlier for pulling data from the HackRF, and then more recently a binding to liquid-dsp frequency demodulation. But in between the two, filtering will be needed. So, I added a binding for the firdespm_lowpass function from liquid-dsp. This function gives you the coefficients for a Finite Impulse Response (FIR) filter, using the Parks-McClellan algorithm.
I wanted to see something interesting from that before going to bed, so I threw together a scheme procedure to generate and then print out the coefficients:
;; -*- geiser-scheme-implementation: guile -*- ;; Copyright 2020 Christopher Howard ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see <https://www.gnu.org/licenses/>. (define-module (sdr filters) #:export (print-firdespm-lowpass-coefficients)) (use-modules (rnrs bytevectors) (sdr liquid-dsp)) (define (print-firdespm-lowpass-coefficients filter-len cutoff-freq stop-band-atten fract-samp-offset) (let ((output-bv (make-bytevector (* 4 filter-len)))) (firdespm-lowpass filter-len cutoff-freq stop-band-atten fract-samp-offset output-bv) (let lp ((coeff 0)) (when (< coeff filter-len) (display (number->string (bytevector-ieee-single-ref output-bv (* 4 coeff) (native-endianness)))) (display "\n") (lp (1+ coeff))))))
Then I dumped some coefficients to a file:
(with-output-to-file "out.csv" (lambda () (print-firdespm-lowpass-coefficients 201 0.2 60.0 0)))
Plotting out the coefficients, I got this visual:
I don’t really know enough yet to be sure if those are sane results or not, but it looks pretty. I was hoping to pick up a DSP book from the library sometime this week and dive more into the details of FIR filters.