summaryrefslogtreecommitdiff
path: root/lib/sumsim.f90
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2020-05-11 22:17:58 +0200
committerChristoph Berg <myon@debian.org>2020-05-11 22:17:58 +0200
commit32a41b1abe1a4aab0892c9c2051be6ba5b379f1e (patch)
treec6e107c1ee4d70610e43a7912e57c720334a08c7 /lib/sumsim.f90
parent08299e8b2bf50ba90daf570f57def529dd29d6e7 (diff)
New upstream version 2.2.0~rc1+repackupstream/2.2.0_rc1+repack
Diffstat (limited to 'lib/sumsim.f90')
-rw-r--r--lib/sumsim.f9041
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/sumsim.f90 b/lib/sumsim.f90
new file mode 100644
index 00000000..e05f8d4d
--- /dev/null
+++ b/lib/sumsim.f90
@@ -0,0 +1,41 @@
+program sumsim
+
+! Sum a number of *.wav files so that multiple signals are present
+
+ use wavhdr
+ parameter (NMAX=60*12000)
+ type(hdr) h !Header for the .wav file
+ integer*2 iwave(NMAX) !i*2 data
+ real wave(NMAX) !r*4 data
+ character*80 fname
+
+ nargs=iargc()
+ if(nargs.lt.1) then
+ print*,'Usage: sumsim file1 [file2, ...]'
+ go to 999
+ endif
+ wave=0.
+
+ do ifile=1,nargs
+ call getarg(ifile,fname)
+ open(10,file=trim(fname),status='old',access='stream')
+ read(10) h
+ npts=h%ndata/2
+ nfsample=h%nsamrate
+ read(10) iwave(1:npts)
+ n=len(trim(fname))
+ wave(1:npts)=wave(1:npts)+iwave(1:npts)
+ rms=sqrt(dot_product(wave(1:npts),wave(1:npts))/npts)
+ write(*,1000) ifile,npts,float(npts)/nfsample,rms,fname(n-14:n)
+1000 format(i3,i8,f6.1,f10.3,2x,a15)
+ close(10)
+ enddo
+
+ fac=1.0/sqrt(float(nargs))
+ iwave(1:npts)=nint(fac*wave(1:npts))
+
+ open(12,file='000000_0000.wav',access='stream',status='unknown')
+ write(12) h,iwave(1:npts)
+ close(12)
+
+999 end program sumsim