2019-01-21 20:31:54 -05:00
|
|
|
subroutine genft4(msg0,ichk,msgsent,i4tone)
|
2019-01-30 11:20:29 -05:00
|
|
|
|
2019-01-21 20:31:54 -05:00
|
|
|
! Encode an FT4 message
|
|
|
|
! Input:
|
|
|
|
! - msg0 requested message to be transmitted
|
|
|
|
! - ichk if ichk=1, return only msgsent
|
|
|
|
! - msgsent message as it will be decoded
|
|
|
|
! - i4tone array of audio tone values, {0,1,2,3}
|
|
|
|
|
2019-01-30 11:20:29 -05:00
|
|
|
! Frame structure:
|
|
|
|
! s16 + 87symbols + 2 ramp up/down = 105 total channel symbols
|
|
|
|
! r1 + s4 + d29 + s4 + d29 + s4 + d29 + s4 + r1
|
|
|
|
|
|
|
|
! Message duration: TxT = 105*512/12000 = 4.48 s
|
|
|
|
|
|
|
|
! use iso_c_binding, only: c_loc,c_size_t
|
2019-01-27 00:03:54 -05:00
|
|
|
|
2019-01-21 20:31:54 -05:00
|
|
|
use packjt77
|
2019-01-27 00:03:54 -05:00
|
|
|
include 'ft4_params.f90'
|
2019-01-21 20:31:54 -05:00
|
|
|
character*37 msg0
|
|
|
|
character*37 message !Message to be generated
|
|
|
|
character*37 msgsent !Message as it will be received
|
|
|
|
character*77 c77
|
2019-01-27 00:03:54 -05:00
|
|
|
integer*4 i4tone(NN),itmp(ND)
|
|
|
|
integer*1 codeword(2*ND)
|
2019-02-05 20:18:50 -05:00
|
|
|
integer*1 msgbits(77),rvec(77)
|
|
|
|
integer icos4a(4),icos4b(4),icos4c(4),icos4d(4)
|
2019-01-21 20:31:54 -05:00
|
|
|
logical unpk77_success
|
2019-02-05 20:18:50 -05:00
|
|
|
data icos4a/0,1,3,2/
|
|
|
|
data icos4b/1,0,2,3/
|
|
|
|
data icos4c/2,3,1,0/
|
|
|
|
data icos4d/3,2,0,1/
|
|
|
|
data rvec/0,1,0,0,1,0,1,0,0,1,0,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,1,1,0, &
|
|
|
|
1,0,0,1,0,1,1,0,0,0,0,1,0,0,0,1,0,1,0,0,1,1,1,1,0,0,1,0,1, &
|
|
|
|
0,1,0,1,0,1,1,0,1,1,1,1,1,0,0,0,1,0,1/
|
2019-01-21 20:31:54 -05:00
|
|
|
message=msg0
|
|
|
|
|
|
|
|
do i=1, 37
|
|
|
|
if(ichar(message(i:i)).eq.0) then
|
|
|
|
message(i:37)=' '
|
|
|
|
exit
|
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
do i=1,37 !Strip leading blanks
|
|
|
|
if(message(1:1).ne.' ') exit
|
|
|
|
message=message(i+1:)
|
|
|
|
enddo
|
|
|
|
|
|
|
|
i3=-1
|
|
|
|
n3=-1
|
|
|
|
call pack77(message,i3,n3,c77)
|
|
|
|
call unpack77(c77,0,msgsent,unpk77_success) !Unpack to get msgsent
|
|
|
|
|
|
|
|
if(ichk.eq.1) go to 999
|
|
|
|
read(c77,"(77i1)") msgbits
|
2019-02-05 20:18:50 -05:00
|
|
|
msgbits=mod(msgbits+rvec,2)
|
2019-01-27 00:03:54 -05:00
|
|
|
call encode174_91(msgbits,codeword)
|
2019-01-21 20:31:54 -05:00
|
|
|
|
|
|
|
! Grayscale mapping:
|
|
|
|
! bits tone
|
|
|
|
! 00 0
|
|
|
|
! 01 1
|
|
|
|
! 11 2
|
|
|
|
! 10 3
|
|
|
|
|
2019-01-27 00:03:54 -05:00
|
|
|
do i=1,ND
|
2019-01-22 12:01:28 -05:00
|
|
|
is=codeword(2*i)+2*codeword(2*i-1)
|
2019-01-25 17:01:34 -05:00
|
|
|
if(is.le.1) itmp(i)=is
|
|
|
|
if(is.eq.2) itmp(i)=3
|
|
|
|
if(is.eq.3) itmp(i)=2
|
2019-01-21 20:31:54 -05:00
|
|
|
enddo
|
|
|
|
|
2019-02-05 20:18:50 -05:00
|
|
|
i4tone(1:4)=icos4a
|
2019-01-30 11:20:29 -05:00
|
|
|
i4tone(5:33)=itmp(1:29)
|
2019-02-05 20:18:50 -05:00
|
|
|
i4tone(34:37)=icos4b
|
2019-01-30 11:20:29 -05:00
|
|
|
i4tone(38:66)=itmp(30:58)
|
2019-02-05 20:18:50 -05:00
|
|
|
i4tone(67:70)=icos4c
|
2019-01-30 11:20:29 -05:00
|
|
|
i4tone(71:99)=itmp(59:87)
|
2019-02-05 20:18:50 -05:00
|
|
|
i4tone(100:103)=icos4d
|
2019-01-30 11:20:29 -05:00
|
|
|
|
2019-01-21 20:31:54 -05:00
|
|
|
999 return
|
|
|
|
end subroutine genft4
|