2020-06-27 09:53:11 -04:00
|
|
|
subroutine gen_fst240wave(itone,nsym,nsps,nwave,fsample,hmod,f0, &
|
2020-06-19 15:02:05 -04:00
|
|
|
icmplx,cwave,wave)
|
2020-06-16 13:59:22 -04:00
|
|
|
|
2020-06-23 15:08:56 -04:00
|
|
|
parameter(NTAB=65536)
|
2020-06-16 13:59:22 -04:00
|
|
|
real wave(nwave)
|
2020-06-23 15:08:56 -04:00
|
|
|
complex cwave(nwave),ctab(0:NTAB-1)
|
2020-06-16 13:59:22 -04:00
|
|
|
real, allocatable, save :: pulse(:)
|
|
|
|
real, allocatable :: dphi(:)
|
2020-06-17 11:44:29 -04:00
|
|
|
integer hmod
|
2020-06-16 13:59:22 -04:00
|
|
|
integer itone(nsym)
|
|
|
|
logical first
|
|
|
|
data first/.true./
|
2020-06-19 17:49:26 -04:00
|
|
|
data nsps0/-99/
|
2020-06-23 15:08:56 -04:00
|
|
|
save first,twopi,dt,tsym,nsps0,ctab
|
|
|
|
|
|
|
|
if(first) then
|
|
|
|
twopi=8.0*atan(1.0)
|
|
|
|
do i=0,NTAB-1
|
|
|
|
phi=i*twopi/NTAB
|
|
|
|
ctab(i)=cmplx(cos(phi),sin(phi))
|
|
|
|
enddo
|
|
|
|
endif
|
2020-06-16 13:59:22 -04:00
|
|
|
|
2020-06-19 17:49:26 -04:00
|
|
|
if(first.or.nsps.ne.nsps0) then
|
2020-06-19 19:17:05 -04:00
|
|
|
if(allocated(pulse)) deallocate(pulse)
|
|
|
|
allocate(pulse(1:3*nsps))
|
2020-06-16 13:59:22 -04:00
|
|
|
dt=1.0/fsample
|
|
|
|
tsym=nsps/fsample
|
|
|
|
! Compute the smoothed frequency-deviation pulse
|
|
|
|
do i=1,3*nsps
|
|
|
|
tt=(i-1.5*nsps)/real(nsps)
|
|
|
|
pulse(i)=gfsk_pulse(2.0,tt)
|
|
|
|
enddo
|
|
|
|
first=.false.
|
2020-06-19 17:49:26 -04:00
|
|
|
nsps0=nsps
|
2020-06-16 13:59:22 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
! Compute the smoothed frequency waveform.
|
|
|
|
! Length = (nsym+2)*nsps samples, zero-padded
|
|
|
|
allocate( dphi(0:(nsym+2)*nsps-1) )
|
|
|
|
dphi_peak=twopi*hmod/real(nsps)
|
|
|
|
dphi=0.0
|
|
|
|
do j=1,nsym
|
|
|
|
ib=(j-1)*nsps
|
|
|
|
ie=ib+3*nsps-1
|
|
|
|
dphi(ib:ie) = dphi(ib:ie) + dphi_peak*pulse(1:3*nsps)*itone(j)
|
|
|
|
enddo
|
|
|
|
|
|
|
|
! Calculate and insert the audio waveform
|
|
|
|
phi=0.0
|
2020-06-19 19:17:05 -04:00
|
|
|
dphi = dphi + twopi*(f0-1.5*hmod/tsym)*dt !Shift frequency up by f0
|
2020-06-19 17:49:26 -04:00
|
|
|
if(icmplx.eq.0) wave=0.
|
2020-06-16 13:59:22 -04:00
|
|
|
if(icmplx.eq.1) cwave=0.
|
|
|
|
k=0
|
|
|
|
do j=0,(nsym+2)*nsps-1
|
|
|
|
k=k+1
|
2020-06-23 15:08:56 -04:00
|
|
|
i=phi*float(NTAB)/twopi
|
|
|
|
i=iand(i,NTAB-1)
|
2020-06-16 13:59:22 -04:00
|
|
|
if(icmplx.eq.0) then
|
2020-06-23 15:08:56 -04:00
|
|
|
wave(k)=real(ctab(i))
|
2020-06-16 13:59:22 -04:00
|
|
|
else
|
2020-06-23 15:08:56 -04:00
|
|
|
cwave(k)=ctab(i)
|
2020-06-16 13:59:22 -04:00
|
|
|
endif
|
2020-06-23 15:08:56 -04:00
|
|
|
phi=phi+dphi(j)
|
|
|
|
if(phi.gt.twopi) phi=phi-twopi
|
2020-06-16 13:59:22 -04:00
|
|
|
enddo
|
|
|
|
|
|
|
|
! Compute the ramp-up and ramp-down symbols
|
2020-06-27 16:24:11 -04:00
|
|
|
kshift=nsps
|
2020-06-16 13:59:22 -04:00
|
|
|
if(icmplx.eq.0) then
|
2020-06-27 09:53:11 -04:00
|
|
|
wave(1:nsps)=0.0
|
|
|
|
wave(nsps+1:nsps+nsps/4)=wave(nsps+1:nsps+nsps/4) * &
|
|
|
|
(1.0-cos(twopi*(/(i,i=0,nsps/4-1)/)/real(nsps/2)))/2.0
|
2020-06-29 16:06:11 -04:00
|
|
|
k1=nsym*nsps+3*nsps/4+1
|
2020-06-27 09:53:11 -04:00
|
|
|
wave((nsym+1)*nsps+1:)=0.0
|
2020-06-29 16:06:11 -04:00
|
|
|
wave(k1:k1+nsps/4)=wave(k1:k1+nsps/4) * &
|
|
|
|
(1.0+cos(twopi*(/(i,i=0,nsps/4)/)/real(nsps/2)))/2.0
|
2020-06-24 16:15:20 -04:00
|
|
|
wave=cshift(wave,kshift)
|
2020-06-16 13:59:22 -04:00
|
|
|
else
|
2020-06-27 09:53:11 -04:00
|
|
|
cwave(1:nsps)=0.0
|
|
|
|
cwave(nsps+1:nsps+nsps/4)=cwave(nsps+1:nsps+nsps/4) * &
|
|
|
|
(1.0-cos(twopi*(/(i,i=0,nsps/4-1)/)/real(nsps/2)))/2.0
|
2020-06-29 16:06:11 -04:00
|
|
|
k1=nsym*nsps+3*nsps/4+1
|
2020-06-27 09:53:11 -04:00
|
|
|
cwave((nsym+1)*nsps+1:)=0.0
|
2020-06-29 16:06:11 -04:00
|
|
|
cwave(k1:k1+nsps/4)=cwave(k1:k1+nsps/4) * &
|
|
|
|
(1.0+cos(twopi*(/(i,i=0,nsps/4)/)/real(nsps/2)))/2.0
|
2020-06-24 16:15:20 -04:00
|
|
|
cwave=cshift(cwave,kshift)
|
2020-06-16 13:59:22 -04:00
|
|
|
endif
|
2020-06-27 16:24:11 -04:00
|
|
|
|
|
|
|
! do i=1,nwave
|
|
|
|
! write(71,3071) i,i/48000.0,wave(i)
|
|
|
|
!3071 format(i10,2f15.9)
|
|
|
|
! enddo
|
|
|
|
wave(nsps*nsym:)=0. !Kill a stray spike ??
|
|
|
|
|
2020-06-16 13:59:22 -04:00
|
|
|
return
|
2020-06-27 09:53:11 -04:00
|
|
|
end subroutine gen_fst240wave
|