summaryrefslogtreecommitdiff
path: root/lib/fil4.f90
diff options
context:
space:
mode:
authorIain R. Learmonth <irl@debian.org>2015-10-18 18:51:00 +0100
committerIain R. Learmonth <irl@debian.org>2015-10-18 18:51:00 +0100
commitd63dd8d081a6fcd0715cd13f26df59fb831769d2 (patch)
treeb9c1f6245147a310aac3762630bad389bbb57335 /lib/fil4.f90
parentc720a3d55c5ec832c29cb7ce50b6fb4b70c55b11 (diff)
Imported Upstream version 1.5.0upstream/1.5.0
Diffstat (limited to 'lib/fil4.f90')
-rw-r--r--lib/fil4.f9049
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/fil4.f90 b/lib/fil4.f90
new file mode 100644
index 00000000..4946da2f
--- /dev/null
+++ b/lib/fil4.f90
@@ -0,0 +1,49 @@
+subroutine fil4(id1,n1,id2,n2)
+
+! FIR lowpass filter designed using ScopeFIR
+
+! fsample = 48000 Hz
+! Ntaps = 49
+! fc = 4500 Hz
+! fstop = 6000 Hz
+! Ripple = 1 dB
+! Stop Atten = 40 dB
+! fout = 12000 Hz
+
+ parameter (NTAPS=49)
+ parameter (NDOWN=4) !Downsample ratio
+ integer*2 id1(n1)
+ integer*2 id2(*)
+ real t(NTAPS)
+ data t/NTAPS*0.0/
+
+! Filter coefficients:
+ real w(NTAPS)
+ data w/ &
+ 0.000861074040, 0.010051920210, 0.010161983649, 0.011363155076, &
+ 0.008706594219, 0.002613872664,-0.005202883094,-0.011720748164, &
+ -0.013752163325,-0.009431602741, 0.000539063909, 0.012636767098, &
+ 0.021494659597, 0.021951235065, 0.011564169382,-0.007656470131, &
+ -0.028965787341,-0.042637874109,-0.039203309748,-0.013153301537, &
+ 0.034320769178, 0.094717832646, 0.154224604789, 0.197758325022, &
+ 0.213715139513, 0.197758325022, 0.154224604789, 0.094717832646, &
+ 0.034320769178,-0.013153301537,-0.039203309748,-0.042637874109, &
+ -0.028965787341,-0.007656470131, 0.011564169382, 0.021951235065, &
+ 0.021494659597, 0.012636767098, 0.000539063909,-0.009431602741, &
+ -0.013752163325,-0.011720748164,-0.005202883094, 0.002613872664, &
+ 0.008706594219, 0.011363155076, 0.010161983649, 0.010051920210, &
+ 0.000861074040/
+ save w,t
+
+ n2=n1/NDOWN
+ if(n2*NDOWN.ne.n1) stop 'Error in fil4'
+ k=1-NDOWN
+ do i=1,n2
+ k=k+NDOWN
+ t(1:NTAPS-NDOWN)=t(1+NDOWN:NTAPS) !Shift old data down in array t
+ t(1+NTAPS-NDOWN:NTAPS)=id1(k:k+NDOWN-1) !Insert new data at end of t
+ id2(i)=nint(dot_product(w,t))
+ enddo
+
+ return
+end subroutine fil4