wsjtx-lib 1.0.0
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/LICENSE +20 -0
- package/README.md +390 -0
- package/dist/src/index.d.ts +180 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +402 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/types.d.ts +251 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +100 -0
- package/dist/src/types.js.map +1 -0
- package/dist/test/wsjtx.basic.test.d.ts +7 -0
- package/dist/test/wsjtx.basic.test.d.ts.map +1 -0
- package/dist/test/wsjtx.basic.test.js +220 -0
- package/dist/test/wsjtx.basic.test.js.map +1 -0
- package/dist/test/wsjtx.test.d.ts +12 -0
- package/dist/test/wsjtx.test.d.ts.map +1 -0
- package/dist/test/wsjtx.test.js +618 -0
- package/dist/test/wsjtx.test.js.map +1 -0
- package/package.json +88 -0
- package/prebuilds/darwin-arm64/build-info.json +10 -0
- package/prebuilds/darwin-arm64/libfftw3f.3.dylib +0 -0
- package/prebuilds/darwin-arm64/libfftw3f_threads.3.dylib +0 -0
- package/prebuilds/darwin-arm64/libgfortran.5.dylib +0 -0
- package/prebuilds/darwin-arm64/wsjtx_lib_nodejs.node +0 -0
- package/prebuilds/linux-x64/build-info.json +10 -0
- package/prebuilds/linux-x64/libfftw3f.so.3 +0 -0
- package/prebuilds/linux-x64/libfftw3f_threads.so.3 +0 -0
- package/prebuilds/linux-x64/libgcc_s.so.1 +0 -0
- package/prebuilds/linux-x64/libgfortran.so.5 +0 -0
- package/prebuilds/linux-x64/wsjtx_lib_nodejs.node +0 -0
- package/prebuilds/package-info.json +25 -0
- package/prebuilds/win32-x64/build-info.json +14 -0
- package/prebuilds/win32-x64/libfftw3f-3.dll +0 -0
- package/prebuilds/win32-x64/libfftw3f_threads-3.dll +0 -0
- package/prebuilds/win32-x64/libgcc_s_seh-1.dll +0 -0
- package/prebuilds/win32-x64/libgfortran-5.dll +0 -0
- package/prebuilds/win32-x64/libstdc++-6.dll +0 -0
- package/prebuilds/win32-x64/libwinpthread-1.dll +0 -0
- package/prebuilds/win32-x64/wsjtx_lib_nodejs.node +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
GNU GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2025 wsjtx-lib-nodejs
|
|
5
|
+
|
|
6
|
+
This program is free software: you can redistribute it and/or modify
|
|
7
|
+
it under the terms of the GNU General Public License as published by
|
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
(at your option) any later version.
|
|
10
|
+
|
|
11
|
+
This program is distributed in the hope that it will be useful,
|
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
GNU General Public License for more details.
|
|
15
|
+
|
|
16
|
+
You should have received a copy of the GNU General Public License
|
|
17
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
The full text of the GNU General Public License v3 can be found at:
|
|
20
|
+
https://www.gnu.org/licenses/gpl-3.0.txt
|
package/README.md
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
# WSJTX Library for Node.js
|
|
2
|
+
|
|
3
|
+
A high-performance Node.js C++ extension for digital amateur radio protocols, providing TypeScript support and async/await interfaces for WSJTX library functionality.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🚀 **High Performance**: Native C++ implementation with multi-threading support
|
|
8
|
+
- 📡 **Multiple Modes**: Support for FT8, FT4, JT4, JT65, JT9, FST4, Q65, FST4W, and WSPR
|
|
9
|
+
- 🔧 **TypeScript Support**: Full TypeScript definitions and modern ES modules
|
|
10
|
+
- ⚡ **Async/Await**: Promise-based API for non-blocking operations
|
|
11
|
+
- 🎵 **Audio Processing**: Support for both Float32Array and Int16Array audio formats
|
|
12
|
+
- 🌍 **Cross-Platform**: Works on Windows, macOS, and Linux
|
|
13
|
+
- 📊 **WSPR Decoding**: Specialized support for WSPR IQ data processing
|
|
14
|
+
|
|
15
|
+
## Supported Modes
|
|
16
|
+
|
|
17
|
+
| Mode | Encoding | Decoding | Sample Rate | Duration | Bandwidth |
|
|
18
|
+
|------|----------|----------|-------------|----------|-----------|
|
|
19
|
+
| FT8 | ✅ | ✅ | 48 kHz | 12.6s | ~50 Hz |
|
|
20
|
+
| FT4 | ✅ | ✅ | 48 kHz | 6.0s | ~80 Hz |
|
|
21
|
+
| JT4 | ❌ | ✅ | 11.025 kHz | 47.1s | Variable |
|
|
22
|
+
| JT65 | ❌ | ✅ | 11.025 kHz | 46.8s | ~180 Hz |
|
|
23
|
+
| JT9 | ❌ | ✅ | 12 kHz | 49.0s | ~16 Hz |
|
|
24
|
+
| FST4 | ❌ | ✅ | 12 kHz | 60.0s | Variable |
|
|
25
|
+
| Q65 | ❌ | ✅ | 12 kHz | 60.0s | Variable |
|
|
26
|
+
| FST4W| ❌ | ✅ | 12 kHz | 120.0s | Variable |
|
|
27
|
+
| WSPR | ❌ | ✅ | 12 kHz | 110.6s | ~6 Hz |
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
### Prerequisites
|
|
32
|
+
|
|
33
|
+
- Node.js 16+
|
|
34
|
+
- CMake 3.15+
|
|
35
|
+
- C++ compiler with C++17 support
|
|
36
|
+
- FFTW3 library
|
|
37
|
+
- Boost libraries
|
|
38
|
+
- Fortran compiler (gfortran)
|
|
39
|
+
|
|
40
|
+
### macOS
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Install dependencies using Homebrew
|
|
44
|
+
brew install cmake fftw boost gcc
|
|
45
|
+
|
|
46
|
+
# Clone and install
|
|
47
|
+
git clone --recursive https://github.com/boybook/wsjtx_lib_nodejs.git
|
|
48
|
+
cd wsjtx-lib-nodejs
|
|
49
|
+
npm install
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Linux (Ubuntu/Debian)
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Install dependencies
|
|
56
|
+
sudo apt-get update
|
|
57
|
+
sudo apt-get install cmake libfftw3-dev libboost-all-dev gfortran build-essential
|
|
58
|
+
|
|
59
|
+
# Clone and install
|
|
60
|
+
git clone --recursive https://github.com/boybook/wsjtx_lib_nodejs.git
|
|
61
|
+
cd wsjtx-lib-nodejs
|
|
62
|
+
npm install
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Windows
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Install dependencies using vcpkg or manually
|
|
69
|
+
# Ensure CMake, FFTW3, Boost, and MinGW-w64 are available
|
|
70
|
+
|
|
71
|
+
# Clone and install
|
|
72
|
+
git clone --recursive https://github.com/boybook/wsjtx_lib_nodejs.git
|
|
73
|
+
cd wsjtx-lib-nodejs
|
|
74
|
+
npm install
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Quick Start
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { WSJTXLib, WSJTXMode } from 'wsjtx-lib';
|
|
81
|
+
|
|
82
|
+
async function example() {
|
|
83
|
+
// Create library instance
|
|
84
|
+
const lib = new WSJTXLib();
|
|
85
|
+
|
|
86
|
+
// Encode an FT8 message
|
|
87
|
+
const encodeResult = await lib.encode(
|
|
88
|
+
WSJTXMode.FT8,
|
|
89
|
+
'CQ TEST K1ABC FN20',
|
|
90
|
+
1000 // Audio base frequency in Hz (typically 500-3000 Hz)
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
console.log(`Generated ${encodeResult.audioData.length} audio samples`);
|
|
94
|
+
console.log(`Message: "${encodeResult.messageSent}"`);
|
|
95
|
+
|
|
96
|
+
// Decode audio data
|
|
97
|
+
const audioData = new Float32Array(48000 * 13); // 13 seconds at 48kHz
|
|
98
|
+
// ... fill audioData with actual audio samples ...
|
|
99
|
+
|
|
100
|
+
const decodeResult = await lib.decode(
|
|
101
|
+
WSJTXMode.FT8,
|
|
102
|
+
audioData,
|
|
103
|
+
1000 // Same audio base frequency used for encoding
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// Get decoded messages
|
|
107
|
+
const messages = lib.pullMessages();
|
|
108
|
+
messages.forEach(msg => {
|
|
109
|
+
console.log(`Decoded: "${msg.text}" (SNR: ${msg.snr} dB)`);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## API Reference
|
|
115
|
+
|
|
116
|
+
### WSJTXLib Class
|
|
117
|
+
|
|
118
|
+
#### Constructor
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
new WSJTXLib(config?: WSJTXConfig)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Creates a new WSJTX library instance.
|
|
125
|
+
|
|
126
|
+
**Parameters:**
|
|
127
|
+
- `config` (optional): Configuration options
|
|
128
|
+
- `maxThreads`: Maximum number of threads (1-16, default: 4)
|
|
129
|
+
- `debug`: Enable debug logging (default: false)
|
|
130
|
+
|
|
131
|
+
#### Methods
|
|
132
|
+
|
|
133
|
+
##### `decode(mode, audioData, frequency, threads?): Promise<DecodeResult>`
|
|
134
|
+
|
|
135
|
+
Decode digital radio signals from audio data.
|
|
136
|
+
|
|
137
|
+
**Parameters:**
|
|
138
|
+
- `mode`: WSJTXMode enum value
|
|
139
|
+
- `audioData`: Float32Array or Int16Array of audio samples
|
|
140
|
+
- `frequency`: Audio base frequency in Hz (typically 500-3000 Hz for FT8)
|
|
141
|
+
- `threads`: Number of threads to use (optional, default: 4)
|
|
142
|
+
|
|
143
|
+
**Returns:** Promise resolving to DecodeResult with success status
|
|
144
|
+
|
|
145
|
+
##### `encode(mode, message, frequency, threads?): Promise<EncodeResult>`
|
|
146
|
+
|
|
147
|
+
Encode a message into audio waveform for transmission.
|
|
148
|
+
|
|
149
|
+
**Parameters:**
|
|
150
|
+
- `mode`: WSJTXMode enum value
|
|
151
|
+
- `message`: Message text to encode (1-22 characters)
|
|
152
|
+
- `frequency`: Audio base frequency in Hz (typically 500-3000 Hz for FT8)
|
|
153
|
+
- `threads`: Number of threads to use (optional, default: 4)
|
|
154
|
+
|
|
155
|
+
**Returns:** Promise resolving to EncodeResult with audio data and actual message sent
|
|
156
|
+
|
|
157
|
+
##### `decodeWSPR(iqData, options?): Promise<WSPRResult[]>`
|
|
158
|
+
|
|
159
|
+
Decode WSPR signals from IQ data.
|
|
160
|
+
|
|
161
|
+
**Parameters:**
|
|
162
|
+
- `iqData`: Float32Array of interleaved I,Q samples
|
|
163
|
+
- `options`: WSPRDecodeOptions (optional)
|
|
164
|
+
|
|
165
|
+
**Returns:** Promise resolving to array of WSPR decode results
|
|
166
|
+
|
|
167
|
+
##### `pullMessages(): WSJTXMessage[]`
|
|
168
|
+
|
|
169
|
+
Retrieve decoded messages from the internal queue.
|
|
170
|
+
|
|
171
|
+
**Returns:** Array of decoded messages
|
|
172
|
+
|
|
173
|
+
##### Utility Methods
|
|
174
|
+
|
|
175
|
+
- `isEncodingSupported(mode): boolean` - Check if encoding is supported for a mode
|
|
176
|
+
- `isDecodingSupported(mode): boolean` - Check if decoding is supported for a mode
|
|
177
|
+
- `getSampleRate(mode): number` - Get required sample rate for a mode
|
|
178
|
+
- `getTransmissionDuration(mode): number` - Get transmission duration for a mode
|
|
179
|
+
- `getAllModeCapabilities(): ModeCapabilities[]` - Get capabilities for all modes
|
|
180
|
+
|
|
181
|
+
##### Static Methods
|
|
182
|
+
|
|
183
|
+
- `convertAudioFormat(audioData, targetFormat): AudioData` - Convert between Float32Array and Int16Array
|
|
184
|
+
|
|
185
|
+
### Enums and Types
|
|
186
|
+
|
|
187
|
+
#### WSJTXMode
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
enum WSJTXMode {
|
|
191
|
+
FT8 = 0,
|
|
192
|
+
FT4 = 1,
|
|
193
|
+
JT4 = 2,
|
|
194
|
+
JT65 = 3,
|
|
195
|
+
JT9 = 4,
|
|
196
|
+
FST4 = 5,
|
|
197
|
+
Q65 = 6,
|
|
198
|
+
FST4W = 7,
|
|
199
|
+
WSPR = 8
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### WSJTXMessage
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
interface WSJTXMessage {
|
|
207
|
+
text: string; // Decoded message text
|
|
208
|
+
snr: number; // Signal-to-noise ratio in dB
|
|
209
|
+
deltaTime: number; // Time offset in seconds
|
|
210
|
+
deltaFrequency: number; // Frequency offset in Hz
|
|
211
|
+
timestamp: number; // Unix timestamp
|
|
212
|
+
sync: number; // Sync quality metric
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
#### EncodeResult
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
interface EncodeResult {
|
|
220
|
+
audioData: Float32Array; // Generated audio waveform
|
|
221
|
+
messageSent: string; // Actual message encoded
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
#### WSPRResult
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
interface WSPRResult {
|
|
229
|
+
frequency: number; // Signal frequency in Hz
|
|
230
|
+
sync: number; // Sync quality
|
|
231
|
+
snr: number; // Signal-to-noise ratio in dB
|
|
232
|
+
deltaTime: number; // Time offset in seconds
|
|
233
|
+
drift: number; // Frequency drift in Hz/minute
|
|
234
|
+
jitter: number; // Jitter metric
|
|
235
|
+
message: string; // Decoded message
|
|
236
|
+
callsign: string; // Decoded callsign
|
|
237
|
+
locator: string; // Decoded grid locator
|
|
238
|
+
power: string; // Decoded power in dBm
|
|
239
|
+
cycles: number; // Number of decode cycles
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Examples
|
|
244
|
+
|
|
245
|
+
### Basic FT8 Encoding and Decoding
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
import { WSJTXLib, WSJTXMode } from 'wsjtx-lib';
|
|
249
|
+
|
|
250
|
+
const lib = new WSJTXLib();
|
|
251
|
+
|
|
252
|
+
// Encode a message
|
|
253
|
+
const result = await lib.encode(WSJTXMode.FT8, 'CQ DX K1ABC FN20', 1500);
|
|
254
|
+
console.log(`Audio samples: ${result.audioData.length}`);
|
|
255
|
+
|
|
256
|
+
// Decode audio (replace with actual audio data)
|
|
257
|
+
const audioData = new Float32Array(48000 * 13);
|
|
258
|
+
const decodeResult = await lib.decode(WSJTXMode.FT8, audioData, 1500);
|
|
259
|
+
|
|
260
|
+
// Get messages
|
|
261
|
+
const messages = lib.pullMessages();
|
|
262
|
+
console.log(`Found ${messages.length} messages`);
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
> **Important Note**: The `frequency` parameter is the **audio base frequency** (typically 500-3000 Hz), not the RF frequency. For example, if you're operating on 20m FT8 (14.074 MHz RF), you might use 1500 Hz as the audio frequency within your transceiver's passband.
|
|
266
|
+
|
|
267
|
+
### WSPR Decoding
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
import { WSJTXLib } from 'wsjtx-lib';
|
|
271
|
+
|
|
272
|
+
const lib = new WSJTXLib();
|
|
273
|
+
|
|
274
|
+
// IQ data (interleaved I,Q samples)
|
|
275
|
+
const iqData = new Float32Array(2 * 12000 * 120); // 2 minutes
|
|
276
|
+
// ... fill with actual IQ data ...
|
|
277
|
+
|
|
278
|
+
const options = {
|
|
279
|
+
dialFrequency: 14095600, // RF dial frequency for WSPR (this is different from audio frequency)
|
|
280
|
+
callsign: 'K1ABC',
|
|
281
|
+
locator: 'FN20',
|
|
282
|
+
quickMode: false,
|
|
283
|
+
passes: 2
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
const results = await lib.decodeWSPR(iqData, options);
|
|
287
|
+
results.forEach(result => {
|
|
288
|
+
console.log(`${result.callsign} ${result.locator} ${result.power}dBm`);
|
|
289
|
+
});
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Audio Format Conversion
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
import { WSJTXLib } from 'wsjtx-lib';
|
|
296
|
+
|
|
297
|
+
// Convert Float32Array to Int16Array
|
|
298
|
+
const floatData = new Float32Array([0.5, -0.5, 0.25]);
|
|
299
|
+
const intData = WSJTXLib.convertAudioFormat(floatData, 'int16');
|
|
300
|
+
|
|
301
|
+
// Convert back to Float32Array
|
|
302
|
+
const backToFloat = WSJTXLib.convertAudioFormat(intData, 'float32');
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## Error Handling
|
|
306
|
+
|
|
307
|
+
The library throws `WSJTXError` for all operation failures:
|
|
308
|
+
|
|
309
|
+
```typescript
|
|
310
|
+
import { WSJTXError } from 'wsjtx-lib';
|
|
311
|
+
|
|
312
|
+
try {
|
|
313
|
+
await lib.decode(WSJTXMode.FT8, audioData, 1500);
|
|
314
|
+
} catch (error) {
|
|
315
|
+
if (error instanceof WSJTXError) {
|
|
316
|
+
console.error(`WSJTX Error [${error.code}]: ${error.message}`);
|
|
317
|
+
} else {
|
|
318
|
+
console.error('Unexpected error:', error);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Building from Source
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
# Clone with submodules
|
|
327
|
+
git clone --recursive https://github.com/your-repo/wsjtx-lib-nodejs.git
|
|
328
|
+
cd wsjtx-lib-nodejs
|
|
329
|
+
|
|
330
|
+
# Install dependencies
|
|
331
|
+
npm install
|
|
332
|
+
|
|
333
|
+
# Build native module and TypeScript
|
|
334
|
+
npm run build
|
|
335
|
+
|
|
336
|
+
# Run tests
|
|
337
|
+
npm test
|
|
338
|
+
|
|
339
|
+
# Run example
|
|
340
|
+
node examples/basic_usage.js
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## Development
|
|
344
|
+
|
|
345
|
+
### Project Structure
|
|
346
|
+
|
|
347
|
+
```
|
|
348
|
+
wsjtx-lib-nodejs/
|
|
349
|
+
├── src/ # TypeScript source files
|
|
350
|
+
├── native/ # C++ wrapper code
|
|
351
|
+
├── wsjtx_lib/ # Git submodule (wsjtx_lib C library)
|
|
352
|
+
├── test/ # Test files
|
|
353
|
+
├── examples/ # Usage examples
|
|
354
|
+
├── dist/ # Compiled TypeScript output
|
|
355
|
+
└── build/ # CMake build directory
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### Scripts
|
|
359
|
+
|
|
360
|
+
- `npm run build` - Build both native module and TypeScript
|
|
361
|
+
- `npm run build:native` - Build only the native C++ module
|
|
362
|
+
- `npm run build:ts` - Build only TypeScript
|
|
363
|
+
- `npm test` - Run all tests
|
|
364
|
+
- `npm run clean` - Clean build artifacts
|
|
365
|
+
|
|
366
|
+
## Contributing
|
|
367
|
+
|
|
368
|
+
1. Fork the repository
|
|
369
|
+
2. Create a feature branch
|
|
370
|
+
3. Make your changes
|
|
371
|
+
4. Add tests for new functionality
|
|
372
|
+
5. Ensure all tests pass
|
|
373
|
+
6. Submit a pull request
|
|
374
|
+
|
|
375
|
+
## License
|
|
376
|
+
|
|
377
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
378
|
+
|
|
379
|
+
## Acknowledgments
|
|
380
|
+
|
|
381
|
+
- Based on the excellent [wsjtx_lib](https://github.com/original-repo/wsjtx_lib) C library
|
|
382
|
+
- WSJT-X development team for the original algorithms
|
|
383
|
+
- Amateur radio community for protocol specifications
|
|
384
|
+
|
|
385
|
+
## Support
|
|
386
|
+
|
|
387
|
+
- 📧 Email: support@example.com
|
|
388
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/your-repo/wsjtx-lib-nodejs/issues)
|
|
389
|
+
- 📖 Documentation: [Wiki](https://github.com/your-repo/wsjtx-lib-nodejs/wiki)
|
|
390
|
+
- 💬 Discussions: [GitHub Discussions](https://github.com/your-repo/wsjtx-lib-nodejs/discussions)
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WSJTX Digital Radio Protocol Library for Node.js
|
|
3
|
+
*
|
|
4
|
+
* High-level TypeScript wrapper around the native C++ WSJTX library bindings.
|
|
5
|
+
* Provides async/await support, input validation, and convenient utilities
|
|
6
|
+
* for working with digital amateur radio protocols.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { WSJTXLib, WSJTXMode } from 'wsjtx-lib';
|
|
11
|
+
*
|
|
12
|
+
* const lib = new WSJTXLib();
|
|
13
|
+
*
|
|
14
|
+
* // Decode FT8 audio data
|
|
15
|
+
* const audioData = new Float32Array(48000 * 13); // 13 seconds at 48kHz
|
|
16
|
+
* const result = await lib.decode(WSJTXMode.FT8, audioData, 1500);
|
|
17
|
+
*
|
|
18
|
+
* // Get decoded messages
|
|
19
|
+
* const messages = lib.pullMessages();
|
|
20
|
+
* console.log('Decoded messages:', messages);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import { WSJTXMode, DecodeResult, EncodeResult, WSPRResult, WSPRDecodeOptions, WSJTXMessage, AudioData, IQData, WSJTXError, WSJTXConfig, VersionInfo, ModeCapabilities } from './types.js';
|
|
24
|
+
/**
|
|
25
|
+
* Main WSJTX library class providing digital radio protocol processing
|
|
26
|
+
*
|
|
27
|
+
* This class wraps the native C++ implementation and provides a convenient
|
|
28
|
+
* TypeScript/JavaScript interface with proper error handling, validation,
|
|
29
|
+
* and async/await support.
|
|
30
|
+
*/
|
|
31
|
+
export declare class WSJTXLib {
|
|
32
|
+
private native;
|
|
33
|
+
private config;
|
|
34
|
+
/**
|
|
35
|
+
* Create a new WSJTX library instance
|
|
36
|
+
*
|
|
37
|
+
* @param config Optional configuration options
|
|
38
|
+
* @throws {WSJTXError} If the native library fails to initialize
|
|
39
|
+
*/
|
|
40
|
+
constructor(config?: WSJTXConfig);
|
|
41
|
+
/**
|
|
42
|
+
* Decode digital radio signals from audio data
|
|
43
|
+
*
|
|
44
|
+
* This method processes audio samples and attempts to decode digital
|
|
45
|
+
* messages using the specified protocol mode. The operation is performed
|
|
46
|
+
* asynchronously to avoid blocking the Node.js event loop.
|
|
47
|
+
*
|
|
48
|
+
* @param mode The digital mode to use for decoding
|
|
49
|
+
* @param audioData Audio samples (Float32Array or Int16Array)
|
|
50
|
+
* @param frequency Center frequency in Hz
|
|
51
|
+
* @param threads Number of threads to use (1-16, default: 4)
|
|
52
|
+
* @returns Promise that resolves when decoding is complete
|
|
53
|
+
*
|
|
54
|
+
* @throws {WSJTXError} If parameters are invalid or decoding fails
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const audioData = new Float32Array(48000 * 13); // 13 seconds
|
|
59
|
+
* await lib.decode(WSJTXMode.FT8, audioData, 1500);
|
|
60
|
+
* const messages = lib.pullMessages();
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
decode(mode: WSJTXMode, audioData: AudioData, frequency: number, threads?: number): Promise<DecodeResult>;
|
|
64
|
+
/**
|
|
65
|
+
* Encode a message into audio waveform for transmission
|
|
66
|
+
*
|
|
67
|
+
* Generates the audio waveform that represents the specified message
|
|
68
|
+
* using the given digital mode. The resulting audio can be fed to
|
|
69
|
+
* a radio transmitter or audio interface.
|
|
70
|
+
*
|
|
71
|
+
* @param mode The digital mode to use for encoding
|
|
72
|
+
* @param message The message text to encode (mode-specific format)
|
|
73
|
+
* @param frequency Center frequency in Hz
|
|
74
|
+
* @param threads Number of threads to use (1-16, default: 4)
|
|
75
|
+
* @returns Promise that resolves with encoded audio data and actual message sent
|
|
76
|
+
*
|
|
77
|
+
* @throws {WSJTXError} If parameters are invalid or encoding fails
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const result = await lib.encode(WSJTXMode.FT8, 'CQ DX K1ABC FN20', 1500);
|
|
82
|
+
* console.log('Generated audio samples:', result.audioData.length);
|
|
83
|
+
* console.log('Actual message sent:', result.messageSent);
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
encode(mode: WSJTXMode, message: string, frequency: number, threads?: number): Promise<EncodeResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Decode WSPR signals from IQ data
|
|
89
|
+
*
|
|
90
|
+
* WSPR (Weak Signal Propagation Reporter) is a specialized protocol
|
|
91
|
+
* for studying radio propagation. This method takes IQ (complex)
|
|
92
|
+
* samples and attempts to decode WSPR transmissions.
|
|
93
|
+
*
|
|
94
|
+
* @param iqData Interleaved I,Q samples as Float32Array
|
|
95
|
+
* @param options Decoder options (frequency, callsign, etc.)
|
|
96
|
+
* @returns Promise that resolves with array of decoded WSPR results
|
|
97
|
+
*
|
|
98
|
+
* @throws {WSJTXError} If parameters are invalid or decoding fails
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const iqData = new Float32Array(2 * 12000 * 111); // 2 minutes of IQ data
|
|
103
|
+
* const options = {
|
|
104
|
+
* dialFrequency: 14095600, // 20m WSPR frequency
|
|
105
|
+
* callsign: 'K1ABC',
|
|
106
|
+
* locator: 'FN20'
|
|
107
|
+
* };
|
|
108
|
+
* const results = await lib.decodeWSPR(iqData, options);
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
decodeWSPR(iqData: IQData, options?: WSPRDecodeOptions): Promise<WSPRResult[]>;
|
|
112
|
+
/**
|
|
113
|
+
* Retrieve decoded messages from the internal queue
|
|
114
|
+
*
|
|
115
|
+
* Messages are added to an internal queue as they are decoded.
|
|
116
|
+
* This method retrieves and removes all pending messages from the queue.
|
|
117
|
+
*
|
|
118
|
+
* @returns Array of decoded messages
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const messages = lib.pullMessages();
|
|
123
|
+
* messages.forEach(msg => {
|
|
124
|
+
* console.log(`${msg.text} (SNR: ${msg.snr} dB, ΔT: ${msg.deltaTime}s)`);
|
|
125
|
+
* });
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
pullMessages(): WSJTXMessage[];
|
|
129
|
+
/**
|
|
130
|
+
* Check if encoding is supported for a specific mode
|
|
131
|
+
*
|
|
132
|
+
* @param mode The mode to check
|
|
133
|
+
* @returns True if encoding is supported
|
|
134
|
+
*/
|
|
135
|
+
isEncodingSupported(mode: WSJTXMode): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Check if decoding is supported for a specific mode
|
|
138
|
+
*
|
|
139
|
+
* @param mode The mode to check
|
|
140
|
+
* @returns True if decoding is supported
|
|
141
|
+
*/
|
|
142
|
+
isDecodingSupported(mode: WSJTXMode): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Get the required sample rate for a specific mode
|
|
145
|
+
*
|
|
146
|
+
* @param mode The mode to query
|
|
147
|
+
* @returns Sample rate in Hz
|
|
148
|
+
*/
|
|
149
|
+
getSampleRate(mode: WSJTXMode): number;
|
|
150
|
+
/**
|
|
151
|
+
* Get the transmission duration for a specific mode
|
|
152
|
+
*
|
|
153
|
+
* @param mode The mode to query
|
|
154
|
+
* @returns Duration in seconds
|
|
155
|
+
*/
|
|
156
|
+
getTransmissionDuration(mode: WSJTXMode): number;
|
|
157
|
+
/**
|
|
158
|
+
* Get capabilities for all supported modes
|
|
159
|
+
*
|
|
160
|
+
* @returns Array of mode capability information
|
|
161
|
+
*/
|
|
162
|
+
getAllModeCapabilities(): ModeCapabilities[];
|
|
163
|
+
/**
|
|
164
|
+
* Convert audio format between Float32Array and Int16Array
|
|
165
|
+
*
|
|
166
|
+
* @param audioData Input audio data
|
|
167
|
+
* @param targetFormat Target format ('float32' or 'int16')
|
|
168
|
+
* @returns Converted audio data
|
|
169
|
+
*/
|
|
170
|
+
static convertAudioFormat(audioData: AudioData, targetFormat: 'float32' | 'int16'): AudioData;
|
|
171
|
+
private validateMode;
|
|
172
|
+
private validateFrequency;
|
|
173
|
+
private validateThreads;
|
|
174
|
+
private validateMessage;
|
|
175
|
+
private validateAudioData;
|
|
176
|
+
private validateIQData;
|
|
177
|
+
}
|
|
178
|
+
export { WSJTXMode, WSJTXError, };
|
|
179
|
+
export type { DecodeResult, EncodeResult, WSPRResult, WSPRDecodeOptions, WSJTXMessage, AudioData, IQData, WSJTXConfig, VersionInfo, ModeCapabilities };
|
|
180
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EACL,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,MAAM,EACN,UAAU,EACV,WAAW,EACX,WAAW,EACX,gBAAgB,EAIjB,MAAM,YAAY,CAAC;AAoEpB;;;;;;GAMG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,MAAM,CAAc;IAE5B;;;;;OAKG;gBACS,MAAM,GAAE,WAAgB;IAiBpC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,MAAM,CACV,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,MAAoC,GAC5C,OAAO,CAAC,YAAY,CAAC;IA+BxB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,MAAM,CACV,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,MAAoC,GAC5C,OAAO,CAAC,YAAY,CAAC;IA8BxB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,UAAU,CACd,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,UAAU,EAAE,CAAC;IAkCxB;;;;;;;;;;;;;;;OAeG;IACH,YAAY,IAAI,YAAY,EAAE;IAW9B;;;;;OAKG;IACH,mBAAmB,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO;IAI7C;;;;;OAKG;IACH,mBAAmB,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO;IAI7C;;;;;OAKG;IACH,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM;IAItC;;;;;OAKG;IACH,uBAAuB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM;IAIhD;;;;OAIG;IACH,sBAAsB,IAAI,gBAAgB,EAAE;IAY5C;;;;;;OAMG;IACH,MAAM,CAAC,kBAAkB,CACvB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,SAAS,GAAG,OAAO,GAChC,SAAS;IA6BZ,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,cAAc;CAcvB;AAGD,OAAO,EACL,SAAS,EACT,UAAU,GACX,CAAC;AAEF,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,MAAM,EACN,WAAW,EACX,WAAW,EACX,gBAAgB,EACjB,CAAC"}
|