From 53db514d4201cb1ba9d0e94e5bd7b82bfee3cff9 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Mon, 8 Jan 2024 08:56:26 -0500 Subject: [PATCH] Enable decoding of MSK144 in jt9[.exe]. Thanks to Alex, VE3NEA! --- CMakeLists.txt | 1 + lib/decode_msk144.f90 | 57 +++++++++++++++++++++++++++++++++++++++++++ lib/jt9.f90 | 14 ++++++++--- lib/jt9a.f90 | 11 +++++++-- 4 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 lib/decode_msk144.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index d3c0f86d6..d38f8be95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -493,6 +493,7 @@ set (wsjt_FSRCS lib/msk144sim.f90 lib/mskrtd.f90 lib/nuttal_window.f90 + lib/decode_msk144.f90 lib/ft4/ft4sim.f90 lib/ft4/ft4sim_mult.f90 lib/ft4/ft4_downsample.f90 diff --git a/lib/decode_msk144.f90 b/lib/decode_msk144.f90 new file mode 100644 index 000000000..17110cf47 --- /dev/null +++ b/lib/decode_msk144.f90 @@ -0,0 +1,57 @@ +subroutine decode_msk144(audio_samples, params, data_dir) + include 'jt9com.f90' + + ! constants + integer, parameter :: SAMPLING_RATE = 12000 + integer, parameter :: BLOCK_SIZE = 7168 + integer, parameter :: STEP_SIZE = BLOCK_SIZE / 2 + integer, parameter :: CALL_LENGTH = 12 + + ! aguments + integer*2 audio_samples(NMAX) + type(params_block) :: params + character(len = 500) :: data_dir + + ! parameters of mskrtd + integer*2 :: buffer(BLOCK_SIZE) + real :: tsec + logical :: bshmsg = .false. ! enables shorthand messages + logical :: btrain = .false. ! turns on training in MSK144 mode + real*8 :: pcoeffs(5) = (/ 0.0, 0.0, 0.0, 0.0, 0.0 /); ! phase equalization + logical :: bswl = .false. + character(len = 80) :: line + character(len = CALL_LENGTH) :: mycall + character(len = CALL_LENGTH) :: hiscall + + ! local variables + integer :: sample_count + integer :: position + integer :: message_count = 0 + + + ! decode in 0.3s blocks + sample_count = params%ntr * SAMPLING_RATE + mycall = transfer(params%mycall, mycall) ! string to char[] + hiscall = transfer(params%hiscall, hiscall) + + do position = 1, sample_count - BLOCK_SIZE + 1, STEP_SIZE + buffer = audio_samples(position : position + BLOCK_SIZE - 1) + tsec = position / REAL(SAMPLING_RATE) + + call mskrtd(buffer, params%nutc, tsec, params%ntol, params%nfqso, params%ndepth, & + mycall, hiscall, bshmsg, btrain, pcoeffs, bswl, data_dir, line) + + if (line(1:1) .ne. char(0)) then + line = line(1:index(line, char(0))-1) + write(*, 1001) line + 1001 format(a80) + message_count = message_count + 1; + end if + end do + + if (.not. params%ndiskdat) then + write(*, 1002) 0, message_count, 0 + 1002 format('', 2i4, i9) + end if + +end subroutine decode_msk144 \ No newline at end of file diff --git a/lib/jt9.f90 b/lib/jt9.f90 index 3621a0a9f..d284f6dd2 100644 --- a/lib/jt9.f90 +++ b/lib/jt9.f90 @@ -27,7 +27,7 @@ program jt9 logical :: read_files = .true., tx9 = .false., display_help = .false., & bLowSidelobes = .false., nexp_decode_set = .false., & have_ntol = .false. - type (option) :: long_options(32) = [ & + type (option) :: long_options(33) = [ & option ('help', .false., 'h', 'Display this help message', ''), & option ('shmem',.true.,'s','Use shared memory for sample data','KEY'), & option ('tr-period', .true., 'p', 'Tx/Rx period, default SECONDS=60', & @@ -64,6 +64,7 @@ program jt9 option ('ft8', .false., '8', 'FT8 mode', ''), & option ('jt9', .false., '9', 'JT9 mode', ''), & option ('qra64', .false., 'q', 'QRA64 mode', ''), & + option ('msk144', .false., 'k', 'MSK144 mode', ''), & option ('QSOprog', .true., 'Q', 'QSO progress (0-5), default PROGRESS=1',& 'QSOprogress'), & option ('sub-mode', .true., 'b', 'Sub mode, default SUBMODE=A', 'A'), & @@ -91,7 +92,7 @@ program jt9 TRperiod=60.d0 do - call getopt('hs:e:a:b:r:m:p:d:f:F:w:t:9876543WYqTL:S:H:c:G:x:g:X:Q:', & + call getopt('hs:e:a:b:r:m:p:d:f:F:w:t:9876543WYqkTL:S:H:c:G:x:g:X:Q:', & long_options,c,optarg,arglen,stat,offset,remain,.true.) if (stat .ne. 0) then exit @@ -129,7 +130,9 @@ program jt9 read (optarg(:arglen), *) fhigh case ('q') mode = 164 - case ('Q') + case ('k') + mode = 144 + case ('Q') read (optarg(:arglen), *) nQSOProg case ('3') mode = 66 @@ -352,7 +355,12 @@ program jt9 call multimode_decoder(shared_data%ss,id2a, & shared_data%params,nfsample) cycle + + ! MSK144 + else if (mode .eq. 144) then + call decode_msk144(shared_data%id2, shared_data%params, data_dir) endif + ! Normal decoding pass call multimode_decoder(shared_data%ss,shared_data%id2, & shared_data%params,nfsample) diff --git a/lib/jt9a.f90 b/lib/jt9a.f90 index f9399f4a0..546ef9246 100644 --- a/lib/jt9a.f90 +++ b/lib/jt9a.f90 @@ -70,8 +70,15 @@ subroutine jt9a() call multimode_decoder(shared_data%ss,id2a,local_params,12000) local_params%nzhsym=50 endif -! Normal decoding pass - call multimode_decoder(shared_data%ss,shared_data%id2,local_params,12000) + + if(local_params%nmode .eq. 144) then + ! MSK144 + call decode_msk144(shared_data%id2, shared_data%params, data_dir) + else + ! Normal decoding pass + call multimode_decoder(shared_data%ss,shared_data%id2,local_params,12000) + endif + call timer('decoder ',1)