diff options
Diffstat (limited to 'map65/libm65/gen_q65_cwave.f90')
| -rw-r--r-- | map65/libm65/gen_q65_cwave.f90 | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/map65/libm65/gen_q65_cwave.f90 b/map65/libm65/gen_q65_cwave.f90 index 474e291f..2f5c1262 100644 --- a/map65/libm65/gen_q65_cwave.f90 +++ b/map65/libm65/gen_q65_cwave.f90 @@ -2,28 +2,28 @@ module gen_q65_cwave_mod implicit none contains -subroutine gen_q65_cwave(msg,ntxfreq,ntone_spacing,msgsent,cwave,nwave) +subroutine gen_q65_cwave(msg,ntxfreq,ntone_spacing,fsample,msgsent,cwave,nwave) use packjt use q65_encoding use iso_fortran_env, only: real64 - integer, parameter :: NMAX = 60*96000 - !-------------------------------------------------------------------- ! Arguments (with correct intent and explicit types) !-------------------------------------------------------------------- + ! fsample is the actual sample rate in Hz + real(real64), intent(in) :: fsample character*24, intent(in) :: msg integer, intent(in) :: ntxfreq integer, intent(in) :: ntone_spacing character*24, intent(out) :: msgsent - complex, intent(out) :: cwave(NMAX) + complex, intent(out) :: cwave(:) integer, intent(out) :: nwave !-------------------------------------------------------------------- ! Local character variables !-------------------------------------------------------------------- - character*37 :: msg37 + character*37 :: msg37,msgsent37 !-------------------------------------------------------------------- ! Explicit declarations for all formerly implicit variables @@ -37,6 +37,7 @@ subroutine gen_q65_cwave(msg,ntxfreq,ntone_spacing,msgsent,cwave,nwave) ! Explicit locals integer :: codeword(65), itone(85) integer :: icos7(0:6) + logical :: success data icos7 /2,5,6,0,4,1,3/ data twopi /6.283185307179586476d0/ @@ -45,31 +46,36 @@ subroutine gen_q65_cwave(msg,ntxfreq,ntone_spacing,msgsent,cwave,nwave) !-------------------------------------------------------------------- ! Begin logic (unchanged from legacy) !-------------------------------------------------------------------- - msgsent = msg msg37 = '' msg37(1:24) = msg - call get_q65_tones(msg37, codeword, itone) + call get_q65_tones(msg37, codeword, itone, msgsent37, success) + msgsent = msgsent37(1:len(msgsent)) + if(.not.success) then + cwave=0 + nwave=0 + return + endif ! Constants nsym = 85 - tsym = 7200.d0 / 12000.d0 - dt = 1.d0 / 96000.d0 + tsym = 7200.d0 / 12000.d0 ! symbol duration (unchanged) + dt = 1.d0 / fsample ! sample interval f0 = ntxfreq - dfgen = ntone_spacing * 12000.d0 / 7200.d0 + dfgen = ntone_spacing * 12000.d0 / 7200.d0 ! tone spacing in Hz (unchanged) phi = 0.d0 dphi = twopi * dt * f0 - nwave = 85 * 7200 * 96000.d0 / 12000.d0 + ! total samples for the 85-symbol Q65-60A waveform + nwave = int( nsym * tsym * fsample + 0.5d0 ) t = 0.d0 j0 = 0 do i = 1, nwave t = t + dt - j = t/tsym + 1 - if (j > 85) exit + j = min(nsym, int(t/tsym) + 1) if (j /= j0) then f = f0 + itone(j) * dfgen |
