@e04/ft8ts 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -34
- package/dist/cli.js +1747 -703
- package/dist/cli.js.map +1 -1
- package/dist/ft8ts.cjs +1756 -663
- package/dist/ft8ts.cjs.map +1 -1
- package/dist/ft8ts.d.ts +44 -9
- package/dist/ft8ts.mjs +1754 -663
- package/dist/ft8ts.mjs.map +1 -1
- package/package.json +1 -1
- package/src/cli.ts +18 -2
- package/src/ft4/constants.ts +3 -0
- package/src/ft4/decode.ts +977 -0
- package/src/ft4/encode.ts +45 -0
- package/src/ft4/scramble.ts +14 -0
- package/src/ft8/constants.ts +7 -0
- package/src/ft8/decode.ts +547 -298
- package/src/ft8/encode.ts +6 -5
- package/src/index.ts +6 -0
- package/src/util/constants.ts +4 -17
- package/src/util/decode174_91.ts +61 -55
- package/src/util/fft.ts +97 -37
- package/src/util/waveform.ts +97 -21
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { encode174_91 } from "../ft8/encode.js";
|
|
2
|
+
import { pack77 } from "../util/pack_jt77.js";
|
|
3
|
+
import { generateFT4Waveform, type WaveformOptions } from "../util/waveform.js";
|
|
4
|
+
import { GRAYMAP } from "./constants.js";
|
|
5
|
+
import { xorWithScrambler } from "./scramble.js";
|
|
6
|
+
|
|
7
|
+
const COSTAS_A = [0, 1, 3, 2] as const;
|
|
8
|
+
const COSTAS_B = [1, 0, 2, 3] as const;
|
|
9
|
+
const COSTAS_C = [2, 3, 1, 0] as const;
|
|
10
|
+
const COSTAS_D = [3, 2, 0, 1] as const;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Convert FT4 LDPC codeword bits into 103 channel tones.
|
|
14
|
+
* Port of lib/ft4/genft4.f90.
|
|
15
|
+
*/
|
|
16
|
+
export function getTones(codeword: readonly number[]): number[] {
|
|
17
|
+
const dataTones = new Array<number>(87);
|
|
18
|
+
for (let i = 0; i < 87; i++) {
|
|
19
|
+
const b0 = codeword[2 * i] ?? 0;
|
|
20
|
+
const b1 = codeword[2 * i + 1] ?? 0;
|
|
21
|
+
const symbol = b1 + 2 * b0;
|
|
22
|
+
dataTones[i] = GRAYMAP[symbol]!;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const tones = new Array<number>(103);
|
|
26
|
+
tones.splice(0, 4, ...COSTAS_A);
|
|
27
|
+
tones.splice(4, 29, ...dataTones.slice(0, 29));
|
|
28
|
+
tones.splice(33, 4, ...COSTAS_B);
|
|
29
|
+
tones.splice(37, 29, ...dataTones.slice(29, 58));
|
|
30
|
+
tones.splice(66, 4, ...COSTAS_C);
|
|
31
|
+
tones.splice(70, 29, ...dataTones.slice(58, 87));
|
|
32
|
+
tones.splice(99, 4, ...COSTAS_D);
|
|
33
|
+
return tones;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function encodeMessage(msg: string): number[] {
|
|
37
|
+
const bits77 = pack77(msg);
|
|
38
|
+
const scrambled = xorWithScrambler(bits77);
|
|
39
|
+
const codeword = encode174_91(scrambled);
|
|
40
|
+
return getTones(codeword);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function encode(msg: string, options: WaveformOptions = {}): Float32Array {
|
|
44
|
+
return generateFT4Waveform(encodeMessage(msg), options);
|
|
45
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Message scrambling vector (rvec) from WSJT-X.
|
|
2
|
+
const RVEC = [
|
|
3
|
+
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,
|
|
4
|
+
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,
|
|
5
|
+
1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1,
|
|
6
|
+
] as const;
|
|
7
|
+
|
|
8
|
+
export function xorWithScrambler(bits77: readonly number[]): number[] {
|
|
9
|
+
const out = new Array<number>(77);
|
|
10
|
+
for (let i = 0; i < 77; i++) {
|
|
11
|
+
out[i] = ((bits77[i] ?? 0) + RVEC[i]!) & 1;
|
|
12
|
+
}
|
|
13
|
+
return out;
|
|
14
|
+
}
|