@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/src/cli.ts CHANGED
@@ -4,6 +4,7 @@ import { resolve } from "node:path";
4
4
  import {
5
5
  type DecodedMessage,
6
6
  type DecodeOptions,
7
+ decodeFT4,
7
8
  decodeFT8,
8
9
  encodeFT8,
9
10
  } from "./index.js";
@@ -21,9 +22,11 @@ Usage:
21
22
  ft8ts encode "<message>" [options]
22
23
 
23
24
  Decode options:
25
+ --mode <ft8|ft4> Mode: ft8 (default) or ft4
24
26
  --low <hz> Lower frequency bound (default: 200)
25
27
  --high <hz> Upper frequency bound (default: 3000)
26
28
  --depth <1|2|3> Decoding depth (default: 2)
29
+ --max-candidates <n> Max candidate signals to decode (default: 300)
27
30
 
28
31
  Encode options:
29
32
  --out <file> Output WAV file (default: output.wav)
@@ -47,15 +50,25 @@ function runDecode(argv: string[]): void {
47
50
 
48
51
  const wavFile = argv[0]!;
49
52
  const options: DecodeOptions = {};
53
+ let mode: "ft8" | "ft4" = "ft8";
50
54
 
51
55
  for (let i = 1; i < argv.length; i++) {
52
56
  const arg = argv[i]!;
53
- if (arg === "--low") {
57
+ if (arg === "--mode") {
58
+ const value = argv[++i];
59
+ if (value === "ft8" || value === "ft4") {
60
+ mode = value;
61
+ } else {
62
+ throw new Error(`Invalid --mode: ${value ?? "(missing)"}. Use ft8 or ft4`);
63
+ }
64
+ } else if (arg === "--low") {
54
65
  options.freqLow = Number(argv[++i]);
55
66
  } else if (arg === "--high") {
56
67
  options.freqHigh = Number(argv[++i]);
57
68
  } else if (arg === "--depth") {
58
69
  options.depth = Number(argv[++i]);
70
+ } else if (arg === "--max-candidates") {
71
+ options.maxCandidates = Number(argv[++i]);
59
72
  } else {
60
73
  throw new Error(`Unknown argument: ${arg}`);
61
74
  }
@@ -70,7 +83,10 @@ function runDecode(argv: string[]): void {
70
83
  );
71
84
 
72
85
  const startTime = performance.now();
73
- const decoded = decodeFT8(samples, { ...options, sampleRate });
86
+ const decoded =
87
+ mode === "ft4"
88
+ ? decodeFT4(samples, { ...options, sampleRate })
89
+ : decodeFT8(samples, { ...options, sampleRate });
74
90
  const elapsed = performance.now() - startTime;
75
91
 
76
92
  console.log(`\nDecoded ${decoded.length} messages in ${(elapsed / 1000).toFixed(2)}s:\n`);
@@ -0,0 +1,3 @@
1
+ /** FT4-specific constants (lib/ft4/ft4_params.f90). */
2
+
3
+ export const GRAYMAP = [0, 1, 3, 2] as const;