kgoba / ft8_lib

FT8 library
MIT License
201 stars 67 forks source link

gen_ft8.cpp: add FREQUENCY option #6

Closed drf5n closed 4 years ago

drf5n commented 4 years ago

Allow generation of FT8 files at other frequencies than 1000Hz.

drf5n commented 4 years ago

I was able to create a multi-message .wav file by mixing ft8 messages at different frequencies:

./gen_ft8   "G4CUS SP4FCA +10 "        002.wav 200
./gen_ft8   "LZ1LZ G4UJS IO83 "        003.wav 300
./gen_ft8   "YO6OGJ F4IAG R-09"        004.wav 400
./gen_ft8   "SQ5FBI G3NDC IO91"        005.wav 500
./gen_ft8   "CQ IK4LZH JN54   "        006.wav 600
./gen_ft8   "GM0LIR UA9SIX -09"        007.wav 700
./gen_ft8   "R2EA IZ4OUL R-08"         008.wav 800
./gen_ft8   "CQ MM1AWV IO75   "        009.wav 900
./gen_ft8   "ES5GI DD3SF 73   "        010.wav 1000
./gen_ft8   "CQ EA1ABT IN73   "        011.wav 1100
./gen_ft8   "2M0OGG RA6ABO KN96"       012.wav 1200
./gen_ft8   "CQ IZ3XJM JN55   "        013.wav 1300
./gen_ft8   "VK3EVE SQ3MZM -24"        014.wav 1400
./gen_ft8   "LZ1CWK DC8VA RR73"        015.wav 1500
./gen_ft8   "CQ EA1HTF IN52  "         016.wav 1600
./gen_ft8   "YO7CGS A41ZZ -11"         017.wav 1700
./gen_ft8   "R2ATW IZ0VLL -16"        018.wav 1800
./gen_ft8   "CQ DX Z33Z KN11 "         019.wav 1900

sox -m 0*.wav mixed.wav

But then was only able to decode the first 12:

$ ./decode_ft8 mixed.wav |sort -k 4
92 blocks, 960 bins
N_FFT = 3840
FFT work area = 38688
Max magnitude: -33.7 dB
Decoded 12 messages
000000 185  1.0  197 ~  G4CUS SP4FCA +10
000000 191  1.0  297 ~  LZ1LZ G4UJS IO83
000000 204  1.0  400 ~  YO6OGJ F4IAG R-09
000000 179  1.0  497 ~  SQ5FBI G3NDC IO91
000000 265  1.1  597 ~  CQ IK4LZH JN54
000000 274  1.1  697 ~  GM0LIR UA9SIX -09
000000 180  1.0  797 ~  R2EA IZ4OUL R-08
000000 164  1.0  897 ~  CQ MM1AWV IO75
000000 191  1.0 1000 ~  ES5GI DD3SF +73
000000 248  1.1 1097 ~  CQ EA1ABT IN73
000000 260  1.1 1200 ~  2M0OGG RA6ABO KN96
000000 237  1.1 1300 ~  CQ IZ3XJM JN55
drf5n commented 4 years ago

One thing that is interesting is that it doesn't seem to encode well above 1300 Hz. I tried the mixed file in WSJT-X and it decoded the 1400Hz message, but not the ones from 1500Hz and up.

For instance:

$ ./gen_ft8   "YO7CGS A41ZZ -11"         test.wav 1200 && ./decode_ft8 test.wav
Packed data: f7 1f 9f 02 88 b8 b9 9f aa 08 
FSK tones: 3140652764174270060537064217463025613140652765536277141326373465265653263140652
92 blocks, 960 bins
N_FFT = 3840
FFT work area = 38688
Max magnitude: -8.6 dB
000000  60  1.4 1238 ~               
000000 253  1.1 1200 ~  YO7CGS A41ZZ -11
Decoded 2 messages
$ ./gen_ft8   "YO7CGS A41ZZ -11"         test.wav 1300 && ./decode_ft8 test.wav
Packed data: f7 1f 9f 02 88 b8 b9 9f aa 08 
FSK tones: 3140652764174270060537064217463025613140652765536277141326373465265653263140652
92 blocks, 960 bins
N_FFT = 3840
FFT work area = 38688
Max magnitude: -8.7 dB
000000  61  1.3 1338 ~               
Decoded 1 messages
$ ./gen_ft8   "YO7CGS A41ZZ -11"         test.wav 1400 && ./decode_ft8 test.wav
Packed data: f7 1f 9f 02 88 b8 b9 9f aa 08 
FSK tones: 3140652764174270060537064217463025613140652765536277141326373465265653263140652
92 blocks, 960 bins
N_FFT = 3840
FFT work area = 38688
Max magnitude: -8.7 dB
000000  72  1.4 1434 ~               
Decoded 1 messages
$ ./gen_ft8   "YO7CGS A41ZZ -11"         test.wav 1500 && ./decode_ft8 test.wav
Packed data: f7 1f 9f 02 88 b8 b9 9f aa 08 
FSK tones: 3140652764174270060537064217463025613140652765536277141326373465265653263140652
92 blocks, 960 bins
N_FFT = 3840
FFT work area = 38688
Max magnitude: -9.0 dB
000000  59  2.2 1534 ~               
Decoded 1 messages
kgoba commented 4 years ago

Thanks for your experiments! It's weird indeed that encoding quality seems to suffer above a certain frequency. It's not really near the Nyquist frequency, so it's even weirder. I will look into this at one point.

kgoba commented 4 years ago

Hi David,

I fixed the high frequency encoding. There was a numerical error due to accumulating phase. I also switched gen_ft8 to GFSK shaped waveform generation to comply with WSJT-X. They introduced it some time ago to improve spectral purity. I hadn't paid too much attention to the encoding quality as I was mostly focused on getting the decoding to work. Thanks for spotting it!

drf5n commented 4 years ago

Cool. I pulled the changes and tried some mixed samples up to 5900Hz and it worked great.