@jtarrio/webrtlsdr 2.0.4 → 3.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/README.md +5 -6
- package/dist/errors.d.ts +1 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +0 -1
- package/dist/errors.js.map +1 -1
- package/dist/radio/radio.d.ts +22 -63
- package/dist/radio/radio.d.ts.map +1 -1
- package/dist/radio/radio.js +41 -255
- package/dist/radio/radio.js.map +1 -1
- package/dist/radio/source.d.ts +25 -0
- package/dist/radio/source.d.ts.map +1 -0
- package/dist/radio/source.js +69 -0
- package/dist/radio/source.js.map +1 -0
- package/dist/radio.d.ts +2 -1
- package/dist/radio.d.ts.map +1 -1
- package/dist/radio.js +1 -1
- package/dist/radio.js.map +1 -1
- package/dist/rtlsdr/rtl2832u.d.ts.map +1 -1
- package/dist/rtlsdr/rtl2832u.js.map +1 -1
- package/dist/rtlsdr/rtlcom.d.ts.map +1 -1
- package/dist/rtlsdr/rtlcom.js.map +1 -1
- package/package.json +4 -4
- package/dist/demod/demod-am.d.ts +0 -45
- package/dist/demod/demod-am.d.ts.map +0 -1
- package/dist/demod/demod-am.js +0 -108
- package/dist/demod/demod-am.js.map +0 -1
- package/dist/demod/demod-cw.d.ts +0 -36
- package/dist/demod/demod-cw.d.ts.map +0 -1
- package/dist/demod/demod-cw.js +0 -96
- package/dist/demod/demod-cw.js.map +0 -1
- package/dist/demod/demod-nbfm.d.ts +0 -45
- package/dist/demod/demod-nbfm.d.ts.map +0 -1
- package/dist/demod/demod-nbfm.js +0 -109
- package/dist/demod/demod-nbfm.js.map +0 -1
- package/dist/demod/demod-ssb.d.ts +0 -45
- package/dist/demod/demod-ssb.d.ts.map +0 -1
- package/dist/demod/demod-ssb.js +0 -107
- package/dist/demod/demod-ssb.js.map +0 -1
- package/dist/demod/demod-wbfm.d.ts +0 -95
- package/dist/demod/demod-wbfm.d.ts.map +0 -1
- package/dist/demod/demod-wbfm.js +0 -205
- package/dist/demod/demod-wbfm.js.map +0 -1
- package/dist/demod/demodulator.d.ts +0 -3
- package/dist/demod/demodulator.d.ts.map +0 -1
- package/dist/demod/demodulator.js +0 -28
- package/dist/demod/demodulator.js.map +0 -1
- package/dist/demod/empty-demodulator.d.ts +0 -62
- package/dist/demod/empty-demodulator.d.ts.map +0 -1
- package/dist/demod/empty-demodulator.js +0 -145
- package/dist/demod/empty-demodulator.js.map +0 -1
- package/dist/demod/modes.d.ts +0 -107
- package/dist/demod/modes.d.ts.map +0 -1
- package/dist/demod/modes.js +0 -101
- package/dist/demod/modes.js.map +0 -1
- package/dist/demod/player.d.ts +0 -19
- package/dist/demod/player.d.ts.map +0 -1
- package/dist/demod/player.js +0 -15
- package/dist/demod/player.js.map +0 -1
- package/dist/demod/sample-counter.d.ts +0 -22
- package/dist/demod/sample-counter.d.ts.map +0 -1
- package/dist/demod/sample-counter.js +0 -57
- package/dist/demod/sample-counter.js.map +0 -1
- package/dist/demod/spectrum.d.ts +0 -23
- package/dist/demod/spectrum.d.ts.map +0 -1
- package/dist/demod/spectrum.js +0 -78
- package/dist/demod/spectrum.js.map +0 -1
- package/dist/dsp/buffers.d.ts +0 -72
- package/dist/dsp/buffers.d.ts.map +0 -1
- package/dist/dsp/buffers.js +0 -122
- package/dist/dsp/buffers.js.map +0 -1
- package/dist/dsp/coefficients.d.ts +0 -22
- package/dist/dsp/coefficients.d.ts.map +0 -1
- package/dist/dsp/coefficients.js +0 -77
- package/dist/dsp/coefficients.js.map +0 -1
- package/dist/dsp/converters.d.ts +0 -15
- package/dist/dsp/converters.d.ts.map +0 -1
- package/dist/dsp/converters.js +0 -43
- package/dist/dsp/converters.js.map +0 -1
- package/dist/dsp/demodulators.d.ts +0 -72
- package/dist/dsp/demodulators.d.ts.map +0 -1
- package/dist/dsp/demodulators.js +0 -244
- package/dist/dsp/demodulators.js.map +0 -1
- package/dist/dsp/fft.d.ts +0 -53
- package/dist/dsp/fft.d.ts.map +0 -1
- package/dist/dsp/fft.js +0 -175
- package/dist/dsp/fft.js.map +0 -1
- package/dist/dsp/filters.d.ts +0 -91
- package/dist/dsp/filters.d.ts.map +0 -1
- package/dist/dsp/filters.js +0 -250
- package/dist/dsp/filters.js.map +0 -1
- package/dist/dsp/power.d.ts +0 -2
- package/dist/dsp/power.d.ts.map +0 -1
- package/dist/dsp/power.js +0 -23
- package/dist/dsp/power.js.map +0 -1
- package/dist/dsp/resamplers.d.ts +0 -33
- package/dist/dsp/resamplers.d.ts.map +0 -1
- package/dist/dsp/resamplers.js +0 -91
- package/dist/dsp/resamplers.js.map +0 -1
- package/dist/players/audioplayer.d.ts +0 -25
- package/dist/players/audioplayer.d.ts.map +0 -1
- package/dist/players/audioplayer.js +0 -68
- package/dist/players/audioplayer.js.map +0 -1
- package/dist/radio/msgqueue.d.ts +0 -23
- package/dist/radio/msgqueue.d.ts.map +0 -1
- package/dist/radio/msgqueue.js +0 -52
- package/dist/radio/msgqueue.js.map +0 -1
- package/dist/radio/sample_receiver.d.ts +0 -19
- package/dist/radio/sample_receiver.d.ts.map +0 -1
- package/dist/radio/sample_receiver.js +0 -54
- package/dist/radio/sample_receiver.js.map +0 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Access RTL-SDR devices and receive and demodulate radio signals from your web ap
|
|
|
6
6
|
|
|
7
7
|
This is a library that provides functions to access and operate an RTL-SDR device from a web application, receive radio signals, demodulate them, and play it through the computer's speakers or headphones.
|
|
8
8
|
|
|
9
|
-
It provides
|
|
9
|
+
It provides low-level access to the RTL-SDR stick, and also uses the [Signals library](https://github.com/jtarrio/signals) to provide a full reception/demodulation pipeline.
|
|
10
10
|
|
|
11
11
|
This library powers Radio Receiver, my browser-based SDR application, which you can try at [radio.ea1iti.es](https://radio.ea1iti.es).
|
|
12
12
|
|
|
@@ -31,13 +31,12 @@ See [the `docs` directory](docs/README.md) for the documentation, or check out t
|
|
|
31
31
|
This program is a complete stereo FM radio receiver tuned for 88.5 MHz.
|
|
32
32
|
|
|
33
33
|
```typescript
|
|
34
|
-
import { Demodulator } from "@jtarrio/
|
|
35
|
-
import { getMode } from "@jtarrio/
|
|
36
|
-
import { Radio } from "@jtarrio/webrtlsdr/radio.js";
|
|
37
|
-
import { RTL2832U_Provider } from "@jtarrio/webrtlsdr/rtlsdr.js";
|
|
34
|
+
import { Demodulator } from "@jtarrio/signals/demod/demodulator.js";
|
|
35
|
+
import { getMode } from "@jtarrio/signals/demod/modes.js";
|
|
36
|
+
import { Radio, RtlProvider } from "@jtarrio/webrtlsdr/radio.js";
|
|
38
37
|
|
|
39
38
|
let demodulator = new Demodulator();
|
|
40
|
-
let radio = new Radio(new
|
|
39
|
+
let radio = new Radio(new RtlProvider(), demodulator);
|
|
41
40
|
|
|
42
41
|
radio.setFrequency(88500000);
|
|
43
42
|
demodulator.setVolume(1);
|
package/dist/errors.d.ts
CHANGED
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAcA,qBAAa,UAAW,SAAQ,KAAK;gBAEjC,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,cAAc,EACrB,OAAO,CAAC,EAAE,iBAAiB;gBAEjB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,cAAc;gBACtC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB;IAoBxD,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB;AAED,oBAAY,cAAc;IACxB,YAAY,IAAA;IACZ,gBAAgB,IAAA;IAChB,iBAAiB,IAAA;IACjB,gBAAgB,IAAA;IAChB,UAAU,IAAA;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAcA,qBAAa,UAAW,SAAQ,KAAK;gBAEjC,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,cAAc,EACrB,OAAO,CAAC,EAAE,iBAAiB;gBAEjB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,cAAc;gBACtC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB;IAoBxD,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB;AAED,oBAAY,cAAc;IACxB,YAAY,IAAA;IACZ,gBAAgB,IAAA;IAChB,iBAAiB,IAAA;IACjB,gBAAgB,IAAA;IAChB,UAAU,IAAA;CACX;AAED,KAAK,iBAAiB,GAAG;IACvB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb,CAAC"}
|
package/dist/errors.js
CHANGED
|
@@ -32,6 +32,5 @@ export var RadioErrorType;
|
|
|
32
32
|
RadioErrorType[RadioErrorType["UnsupportedDevice"] = 2] = "UnsupportedDevice";
|
|
33
33
|
RadioErrorType[RadioErrorType["UsbTransferError"] = 3] = "UsbTransferError";
|
|
34
34
|
RadioErrorType[RadioErrorType["TunerError"] = 4] = "TunerError";
|
|
35
|
-
RadioErrorType[RadioErrorType["DemodulationError"] = 5] = "DemodulationError";
|
|
36
35
|
})(RadioErrorType || (RadioErrorType = {}));
|
|
37
36
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,MAAM,OAAO,UAAW,SAAQ,KAAK;IAQnC,YACE,OAAe,EACf,aAAkD,EAClD,OAA2B;QAE3B,KAAK,CACH,OAAO,EACP,OAAO,KAAK,SAAS;YACnB,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,OAAO,aAAa,KAAK,QAAQ;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,MAAM,OAAO,UAAW,SAAQ,KAAK;IAQnC,YACE,OAAe,EACf,aAAkD,EAClD,OAA2B;QAE3B,KAAK,CACH,OAAO,EACP,OAAO,KAAK,SAAS;YACnB,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,OAAO,aAAa,KAAK,QAAQ;gBACnC,CAAC,CAAC,aAAa;gBACf,CAAC,CAAC,SAAS,CACd,CAAC;QACF,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;YACtC,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;YAC1B,IAAI,CAAC,IAAI,GAAG,cAAc,cAAc,CAAC,aAAa,CAAC,EAAE,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,IAAI,CAAkB;CACvB;AAED,MAAM,CAAN,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,mEAAY,CAAA;IACZ,2EAAgB,CAAA;IAChB,6EAAiB,CAAA;IACjB,2EAAgB,CAAA;IAChB,+DAAU,CAAA;AACZ,CAAC,EANW,cAAc,KAAd,cAAc,QAMzB"}
|
package/dist/radio/radio.d.ts
CHANGED
|
@@ -1,97 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
/** State machine to orchestrate the RTL2832, demodulation, and audio playing. */
|
|
2
|
+
import { Radio as BaseRadio, RadioEvent as BaseRadioEvent, RadioEventType as BaseRadioEventType, RadioOptions, SampleBlock } from "@jtarrio/signals/radio.js";
|
|
3
|
+
import { DirectSampling } from "../rtlsdr/rtldevice.js";
|
|
4
|
+
import { RtlParameter, RtlProvider } from "./source.js";
|
|
5
|
+
import { SampleReceiver } from "@jtarrio/signals/radio/sample_receiver.js";
|
|
6
|
+
export { type RadioOptions } from "@jtarrio/signals/radio/radio.js";
|
|
3
7
|
/** The information in a 'radio' event. */
|
|
4
|
-
export type RadioEventType = {
|
|
5
|
-
type: "started";
|
|
6
|
-
} | {
|
|
7
|
-
type: "stopped";
|
|
8
|
-
} | {
|
|
8
|
+
export type RadioEventType = BaseRadioEventType | {
|
|
9
9
|
type: "directSampling";
|
|
10
10
|
active: boolean;
|
|
11
|
-
} | {
|
|
12
|
-
type: "error";
|
|
13
|
-
exception: any;
|
|
14
11
|
};
|
|
15
12
|
/** The type of 'radio' events. */
|
|
16
13
|
export declare class RadioEvent extends CustomEvent<RadioEventType> {
|
|
17
14
|
constructor(e: RadioEventType);
|
|
18
15
|
}
|
|
19
|
-
/**
|
|
20
|
-
export
|
|
16
|
+
/** Provides controls to play, stop, and tune the radio. */
|
|
17
|
+
export declare class Radio extends BaseRadio<RtlParameter> {
|
|
21
18
|
/**
|
|
22
|
-
*
|
|
19
|
+
* Creates an instance of Radio.
|
|
23
20
|
*
|
|
24
|
-
*
|
|
25
|
-
* implies smaller buffers, thus smaller latency. It also increases your
|
|
26
|
-
* CPU requirements, though.
|
|
21
|
+
* Since this constructor sends commands, you should call `ready()` before using the radio.
|
|
27
22
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
23
|
+
* @param rtlProvider a RtlSignalSourceProvider instance.
|
|
24
|
+
* @param sampleReceiver the object that will receive the signals from the RTL source.
|
|
25
|
+
* @param options options for the radio.
|
|
30
26
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
/** Provides controls to play, stop, and tune the radio. */
|
|
34
|
-
export declare class Radio extends EventTarget {
|
|
35
|
-
private rtlProvider;
|
|
36
|
-
private sampleReceiver;
|
|
37
|
-
private options?;
|
|
38
|
-
/** @param sampleReceiver the object that will receive the radio samples. */
|
|
39
|
-
constructor(rtlProvider: RtlDeviceProvider, sampleReceiver: SampleReceiver, options?: RadioOptions | undefined);
|
|
40
|
-
/** Current sample rate. */
|
|
41
|
-
private sampleRate;
|
|
42
|
-
/** Current state. */
|
|
43
|
-
private state;
|
|
44
|
-
/** Channel to send messages to the state machine. */
|
|
45
|
-
private channel;
|
|
46
|
-
/** Frequency correction factor, in PPM. */
|
|
47
|
-
private frequencyCorrection;
|
|
48
|
-
/** RF gain in dB, or null for automatic. */
|
|
49
|
-
private gain;
|
|
50
|
-
/** Currently tuned frequency. */
|
|
51
|
-
private frequency;
|
|
52
|
-
/** Whether direct sampling mode is enabled. */
|
|
53
|
-
private directSamplingMethod;
|
|
54
|
-
/** Whether the bias tee is enabled. */
|
|
55
|
-
private biasTeeEnabled;
|
|
56
|
-
/** Starts playing the radio. */
|
|
57
|
-
start(): void;
|
|
58
|
-
/** Stops playing the radio. */
|
|
59
|
-
stop(): void;
|
|
60
|
-
/** Returns whether the radio is playing (or scanning). */
|
|
61
|
-
isPlaying(): boolean;
|
|
62
|
-
/** Tunes the radio to this frequency. */
|
|
63
|
-
setFrequency(freq: number): void;
|
|
64
|
-
/** Returns the tuned frequency. */
|
|
65
|
-
getFrequency(): number;
|
|
27
|
+
constructor(rtlProvider: RtlProvider, sampleReceiver: SampleReceiver, options?: RadioOptions);
|
|
28
|
+
private directSampling;
|
|
66
29
|
/** Sets the frequency correction factor, in PPM. */
|
|
67
|
-
setFrequencyCorrection(ppm: number): void
|
|
30
|
+
setFrequencyCorrection(ppm: number): Promise<void>;
|
|
68
31
|
/** Returns the current frequency correction factor. */
|
|
69
32
|
getFrequencyCorrection(): number;
|
|
70
33
|
/**
|
|
71
34
|
* Sets the RF gain.
|
|
72
35
|
* @param gain the gain in dB, or null for automatic gain control.
|
|
73
36
|
*/
|
|
74
|
-
setGain(gain: number | null): void
|
|
37
|
+
setGain(gain: number | null): Promise<void>;
|
|
75
38
|
/**
|
|
76
39
|
* Returns the RF gain.
|
|
77
40
|
* @returns the gain in dB, or null for automatic gain control.
|
|
78
41
|
*/
|
|
79
42
|
getGain(): number | null;
|
|
80
43
|
/** Sets the direct sampling method. */
|
|
81
|
-
setDirectSamplingMethod(method: DirectSampling): void
|
|
44
|
+
setDirectSamplingMethod(method: DirectSampling): Promise<void>;
|
|
82
45
|
/** Returns the current direct sampling method. */
|
|
83
46
|
getDirectSamplingMethod(): DirectSampling;
|
|
84
|
-
/** Changes the sample rate. This change only takes effect when the radio is started. */
|
|
85
|
-
setSampleRate(sampleRate: number): void;
|
|
86
|
-
/** Returns the current sample rate. */
|
|
87
|
-
getSampleRate(): number;
|
|
88
47
|
/** Enables or disables the bias tee. */
|
|
89
|
-
enableBiasTee(enable: boolean): void
|
|
48
|
+
enableBiasTee(enable: boolean): Promise<void>;
|
|
90
49
|
/** Returns whether the bias tee is enabled. */
|
|
91
50
|
isBiasTeeEnabled(): boolean;
|
|
92
|
-
|
|
93
|
-
private runLoop;
|
|
51
|
+
onReceiveSamples(block: SampleBlock): void;
|
|
94
52
|
addEventListener(type: "radio", callback: (e: RadioEvent) => void | null, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
53
|
+
addEventListener(type: "radio", callback: (e: BaseRadioEvent) => void | null, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
95
54
|
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
96
55
|
}
|
|
97
56
|
//# sourceMappingURL=radio.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../src/radio/radio.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../src/radio/radio.ts"],"names":[],"mappings":"AAcA,iFAAiF;AAEjF,OAAO,EACL,KAAK,IAAI,SAAS,EAClB,UAAU,IAAI,cAAc,EAC5B,cAAc,IAAI,kBAAkB,EACpC,YAAY,EACZ,WAAW,EACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAE3E,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,0CAA0C;AAC1C,MAAM,MAAM,cAAc,GACtB,kBAAkB,GAClB;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;AAEhD,kCAAkC;AAClC,qBAAa,UAAW,SAAQ,WAAW,CAAC,cAAc,CAAC;gBAC7C,CAAC,EAAE,cAAc;CAG9B;AAED,2DAA2D;AAC3D,qBAAa,KAAM,SAAQ,SAAS,CAAC,YAAY,CAAC;IAChD;;;;;;;;OAQG;gBAED,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,OAAO,CAAC,EAAE,YAAY;IAWxB,OAAO,CAAC,cAAc,CAAU;IAEhC,oDAAoD;IAC9C,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxD,uDAAuD;IACvD,sBAAsB,IAAI,MAAM;IAIhC;;;OAGG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjD;;;OAGG;IACH,OAAO,IAAI,MAAM,GAAG,IAAI;IAIxB,uCAAuC;IACjC,uBAAuB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE,kDAAkD;IAClD,uBAAuB,IAAI,cAAc;IAIzC,wCAAwC;IAClC,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD,+CAA+C;IAC/C,gBAAgB,IAAI,OAAO;IAI3B,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAY1C,gBAAgB,CACd,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,GAAG,IAAI,EACxC,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAAG,SAAS,GACtD,IAAI;IACP,gBAAgB,CACd,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,GAAG,IAAI,EAC5C,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAAG,SAAS,GACtD,IAAI;IACP,gBAAgB,CACd,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,kCAAkC,GAAG,IAAI,EACnD,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAAG,SAAS,GACtD,IAAI;CAYR"}
|
package/dist/radio/radio.js
CHANGED
|
@@ -12,299 +12,85 @@
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
/** State machine to orchestrate the RTL2832, demodulation, and audio playing. */
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { DirectSampling, } from "../rtlsdr/rtldevice.js";
|
|
18
|
-
import { Channel } from "./msgqueue.js";
|
|
15
|
+
import { Radio as BaseRadio, } from "@jtarrio/signals/radio.js";
|
|
16
|
+
import { DirectSampling } from "../rtlsdr/rtldevice.js";
|
|
19
17
|
/** The type of 'radio' events. */
|
|
20
18
|
export class RadioEvent extends CustomEvent {
|
|
21
19
|
constructor(e) {
|
|
22
20
|
super("radio", { detail: e });
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
|
-
/** Current state. */
|
|
26
|
-
var State;
|
|
27
|
-
(function (State) {
|
|
28
|
-
State[State["OFF"] = 0] = "OFF";
|
|
29
|
-
State[State["PLAYING"] = 1] = "PLAYING";
|
|
30
|
-
})(State || (State = {}));
|
|
31
23
|
/** Provides controls to play, stop, and tune the radio. */
|
|
32
|
-
export class Radio extends
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
export class Radio extends BaseRadio {
|
|
25
|
+
/**
|
|
26
|
+
* Creates an instance of Radio.
|
|
27
|
+
*
|
|
28
|
+
* Since this constructor sends commands, you should call `ready()` before using the radio.
|
|
29
|
+
*
|
|
30
|
+
* @param rtlProvider a RtlSignalSourceProvider instance.
|
|
31
|
+
* @param sampleReceiver the object that will receive the signals from the RTL source.
|
|
32
|
+
* @param options options for the radio.
|
|
33
|
+
*/
|
|
37
34
|
constructor(rtlProvider, sampleReceiver, options) {
|
|
38
|
-
super();
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.frequencyCorrection = 0;
|
|
46
|
-
this.gain = null;
|
|
47
|
-
this.frequency = 88500000;
|
|
48
|
-
this.directSamplingMethod = DirectSampling.Off;
|
|
49
|
-
this.biasTeeEnabled = false;
|
|
50
|
-
this.runLoop();
|
|
51
|
-
}
|
|
52
|
-
/** Current sample rate. */
|
|
53
|
-
sampleRate;
|
|
54
|
-
/** Current state. */
|
|
55
|
-
state;
|
|
56
|
-
/** Channel to send messages to the state machine. */
|
|
57
|
-
channel;
|
|
58
|
-
/** Frequency correction factor, in PPM. */
|
|
59
|
-
frequencyCorrection;
|
|
60
|
-
/** RF gain in dB, or null for automatic. */
|
|
61
|
-
gain;
|
|
62
|
-
/** Currently tuned frequency. */
|
|
63
|
-
frequency;
|
|
64
|
-
/** Whether direct sampling mode is enabled. */
|
|
65
|
-
directSamplingMethod;
|
|
66
|
-
/** Whether the bias tee is enabled. */
|
|
67
|
-
biasTeeEnabled;
|
|
68
|
-
/** Starts playing the radio. */
|
|
69
|
-
start() {
|
|
70
|
-
this.channel.send({ type: "start" });
|
|
71
|
-
}
|
|
72
|
-
/** Stops playing the radio. */
|
|
73
|
-
stop() {
|
|
74
|
-
this.channel.send({ type: "stop" });
|
|
75
|
-
}
|
|
76
|
-
/** Returns whether the radio is playing (or scanning). */
|
|
77
|
-
isPlaying() {
|
|
78
|
-
return this.state != State.OFF;
|
|
79
|
-
}
|
|
80
|
-
/** Tunes the radio to this frequency. */
|
|
81
|
-
setFrequency(freq) {
|
|
82
|
-
this.channel.send({ type: "frequency", value: freq });
|
|
83
|
-
}
|
|
84
|
-
/** Returns the tuned frequency. */
|
|
85
|
-
getFrequency() {
|
|
86
|
-
return this.frequency;
|
|
35
|
+
super(rtlProvider, sampleReceiver, options);
|
|
36
|
+
this.directSampling = false;
|
|
37
|
+
this.setFrequencyCorrection(0);
|
|
38
|
+
this.setGain(null);
|
|
39
|
+
this.setFrequency(88500000);
|
|
40
|
+
this.setDirectSamplingMethod(DirectSampling.Off);
|
|
41
|
+
this.enableBiasTee(false);
|
|
87
42
|
}
|
|
43
|
+
directSampling;
|
|
88
44
|
/** Sets the frequency correction factor, in PPM. */
|
|
89
|
-
setFrequencyCorrection(ppm) {
|
|
90
|
-
this.
|
|
45
|
+
async setFrequencyCorrection(ppm) {
|
|
46
|
+
return this.setParameter("frequency_correction", ppm);
|
|
91
47
|
}
|
|
92
48
|
/** Returns the current frequency correction factor. */
|
|
93
49
|
getFrequencyCorrection() {
|
|
94
|
-
return this.
|
|
50
|
+
return this.getParameter("frequency_correction");
|
|
95
51
|
}
|
|
96
52
|
/**
|
|
97
53
|
* Sets the RF gain.
|
|
98
54
|
* @param gain the gain in dB, or null for automatic gain control.
|
|
99
55
|
*/
|
|
100
|
-
setGain(gain) {
|
|
101
|
-
this.
|
|
56
|
+
async setGain(gain) {
|
|
57
|
+
return this.setParameter("gain", gain);
|
|
102
58
|
}
|
|
103
59
|
/**
|
|
104
60
|
* Returns the RF gain.
|
|
105
61
|
* @returns the gain in dB, or null for automatic gain control.
|
|
106
62
|
*/
|
|
107
63
|
getGain() {
|
|
108
|
-
return this.gain;
|
|
64
|
+
return this.getParameter("gain");
|
|
109
65
|
}
|
|
110
66
|
/** Sets the direct sampling method. */
|
|
111
|
-
setDirectSamplingMethod(method) {
|
|
112
|
-
this.
|
|
67
|
+
async setDirectSamplingMethod(method) {
|
|
68
|
+
return this.setParameter("direct_sampling_method", method);
|
|
113
69
|
}
|
|
114
70
|
/** Returns the current direct sampling method. */
|
|
115
71
|
getDirectSamplingMethod() {
|
|
116
|
-
return this.
|
|
117
|
-
}
|
|
118
|
-
/** Changes the sample rate. This change only takes effect when the radio is started. */
|
|
119
|
-
setSampleRate(sampleRate) {
|
|
120
|
-
this.sampleRate = sampleRate;
|
|
121
|
-
}
|
|
122
|
-
/** Returns the current sample rate. */
|
|
123
|
-
getSampleRate() {
|
|
124
|
-
return this.sampleRate;
|
|
72
|
+
return this.getParameter("direct_sampling_method");
|
|
125
73
|
}
|
|
126
74
|
/** Enables or disables the bias tee. */
|
|
127
|
-
enableBiasTee(enable) {
|
|
128
|
-
this.
|
|
75
|
+
async enableBiasTee(enable) {
|
|
76
|
+
return this.setParameter("bias_tee", enable);
|
|
129
77
|
}
|
|
130
78
|
/** Returns whether the bias tee is enabled. */
|
|
131
79
|
isBiasTeeEnabled() {
|
|
132
|
-
return this.
|
|
80
|
+
return this.getParameter("bias_tee");
|
|
133
81
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (msg.type == "frequency")
|
|
144
|
-
this.frequency = msg.value;
|
|
145
|
-
if (msg.type == "frequencyCorrection")
|
|
146
|
-
this.frequencyCorrection = msg.value;
|
|
147
|
-
if (msg.type == "gain")
|
|
148
|
-
this.gain = msg.value;
|
|
149
|
-
if (msg.type == "directSamplingMethod")
|
|
150
|
-
this.directSamplingMethod = msg.value;
|
|
151
|
-
if (msg.type == "biasTeeEnabled")
|
|
152
|
-
this.biasTeeEnabled = msg.value;
|
|
153
|
-
if (msg.type != "start")
|
|
154
|
-
continue;
|
|
155
|
-
rtl = await this.rtlProvider.get();
|
|
156
|
-
await rtl.setSampleRate(this.sampleRate);
|
|
157
|
-
await rtl.setFrequencyCorrection(this.frequencyCorrection);
|
|
158
|
-
await rtl.setGain(this.gain);
|
|
159
|
-
await rtl.setDirectSamplingMethod(this.directSamplingMethod);
|
|
160
|
-
await rtl.setCenterFrequency(this.frequency);
|
|
161
|
-
await rtl.resetBuffer();
|
|
162
|
-
transfers = new Transfers(rtl, this.sampleReceiver, this, this.sampleRate, this.options);
|
|
163
|
-
transfers.startStream();
|
|
164
|
-
this.state = State.PLAYING;
|
|
165
|
-
this.dispatchEvent(new RadioEvent({ type: "started" }));
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
case State.PLAYING: {
|
|
169
|
-
switch (msg.type) {
|
|
170
|
-
case "frequency":
|
|
171
|
-
if (this.frequency != msg.value) {
|
|
172
|
-
this.frequency = msg.value;
|
|
173
|
-
await rtl.setCenterFrequency(this.frequency);
|
|
174
|
-
}
|
|
175
|
-
break;
|
|
176
|
-
case "gain":
|
|
177
|
-
if (this.gain != msg.value) {
|
|
178
|
-
this.gain = msg.value;
|
|
179
|
-
await rtl.setGain(this.gain);
|
|
180
|
-
}
|
|
181
|
-
break;
|
|
182
|
-
case "frequencyCorrection":
|
|
183
|
-
if (this.frequencyCorrection != msg.value) {
|
|
184
|
-
this.frequencyCorrection = msg.value;
|
|
185
|
-
await rtl.setFrequencyCorrection(this.frequencyCorrection);
|
|
186
|
-
}
|
|
187
|
-
break;
|
|
188
|
-
case "directSamplingMethod":
|
|
189
|
-
if (this.directSamplingMethod != msg.value) {
|
|
190
|
-
this.directSamplingMethod = msg.value;
|
|
191
|
-
await rtl.setDirectSamplingMethod(this.directSamplingMethod);
|
|
192
|
-
}
|
|
193
|
-
break;
|
|
194
|
-
case "biasTeeEnabled":
|
|
195
|
-
if (this.biasTeeEnabled != msg.value) {
|
|
196
|
-
this.biasTeeEnabled = msg.value;
|
|
197
|
-
await rtl.enableBiasTee(this.biasTeeEnabled);
|
|
198
|
-
}
|
|
199
|
-
break;
|
|
200
|
-
case "stop":
|
|
201
|
-
await transfers.stopStream();
|
|
202
|
-
await rtl.close();
|
|
203
|
-
this.state = State.OFF;
|
|
204
|
-
this.dispatchEvent(new RadioEvent({ type: "stopped" }));
|
|
205
|
-
break;
|
|
206
|
-
default:
|
|
207
|
-
// do nothing.
|
|
208
|
-
}
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
catch (e) {
|
|
214
|
-
this.dispatchEvent(new RadioEvent({ type: "error", exception: e }));
|
|
215
|
-
}
|
|
216
|
-
}
|
|
82
|
+
onReceiveSamples(block) {
|
|
83
|
+
let directSampling = block.data?.directSampling || false;
|
|
84
|
+
if (directSampling == this.directSampling)
|
|
85
|
+
return;
|
|
86
|
+
this.directSampling = directSampling;
|
|
87
|
+
this.dispatchEvent(new RadioEvent({
|
|
88
|
+
type: "directSampling",
|
|
89
|
+
active: this.directSampling,
|
|
90
|
+
}));
|
|
217
91
|
}
|
|
218
92
|
addEventListener(type, callback, options) {
|
|
219
93
|
super.addEventListener(type, callback, options);
|
|
220
94
|
}
|
|
221
95
|
}
|
|
222
|
-
/**
|
|
223
|
-
* USB transfer controller.
|
|
224
|
-
*
|
|
225
|
-
* Maintains 2 active USB transfers. When a transfer ends, it calls
|
|
226
|
-
* the sample receiver's 'receiveSamples' function and starts a new
|
|
227
|
-
* transfer. In this way, there is always a stream of samples coming in.
|
|
228
|
-
*/
|
|
229
|
-
class Transfers {
|
|
230
|
-
rtl;
|
|
231
|
-
sampleReceiver;
|
|
232
|
-
radio;
|
|
233
|
-
sampleRate;
|
|
234
|
-
/** Receive this many buffers per second by default. */
|
|
235
|
-
static DEFAULT_BUFS_PER_SEC = 20;
|
|
236
|
-
constructor(rtl, sampleReceiver, radio, sampleRate, options) {
|
|
237
|
-
this.rtl = rtl;
|
|
238
|
-
this.sampleReceiver = sampleReceiver;
|
|
239
|
-
this.radio = radio;
|
|
240
|
-
this.sampleRate = sampleRate;
|
|
241
|
-
let buffersPerSecond = options?.buffersPerSecond;
|
|
242
|
-
if (buffersPerSecond === undefined || buffersPerSecond <= 0)
|
|
243
|
-
buffersPerSecond = Transfers.DEFAULT_BUFS_PER_SEC;
|
|
244
|
-
this.samplesPerBuf = 512 * Math.ceil(sampleRate / buffersPerSecond / 512);
|
|
245
|
-
this.buffersWanted = 0;
|
|
246
|
-
this.buffersRunning = 0;
|
|
247
|
-
this.iqConverter = new U8ToFloat32(this.samplesPerBuf);
|
|
248
|
-
this.directSampling = false;
|
|
249
|
-
this.stopCallback = Transfers.nilCallback;
|
|
250
|
-
}
|
|
251
|
-
samplesPerBuf;
|
|
252
|
-
buffersWanted;
|
|
253
|
-
buffersRunning;
|
|
254
|
-
iqConverter;
|
|
255
|
-
directSampling;
|
|
256
|
-
stopCallback;
|
|
257
|
-
static PARALLEL_BUFFERS = 2;
|
|
258
|
-
/** Starts the transfers as a stream. */
|
|
259
|
-
async startStream() {
|
|
260
|
-
this.sampleReceiver.setSampleRate(this.sampleRate);
|
|
261
|
-
await this.rtl.resetBuffer();
|
|
262
|
-
this.buffersWanted = Transfers.PARALLEL_BUFFERS;
|
|
263
|
-
while (this.buffersRunning < this.buffersWanted) {
|
|
264
|
-
++this.buffersRunning;
|
|
265
|
-
this.readStream();
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Stops the transfer stream.
|
|
270
|
-
* @returns a promise that resolves when the stream is stopped.
|
|
271
|
-
*/
|
|
272
|
-
async stopStream() {
|
|
273
|
-
if (this.buffersRunning == 0 && this.buffersWanted == 0)
|
|
274
|
-
return;
|
|
275
|
-
let promise = new Promise((r) => {
|
|
276
|
-
this.stopCallback = r;
|
|
277
|
-
});
|
|
278
|
-
this.buffersWanted = 0;
|
|
279
|
-
return promise;
|
|
280
|
-
}
|
|
281
|
-
/** Runs the transfer stream. */
|
|
282
|
-
async readStream() {
|
|
283
|
-
try {
|
|
284
|
-
while (this.buffersRunning <= this.buffersWanted) {
|
|
285
|
-
const b = await this.rtl.readSamples(this.samplesPerBuf);
|
|
286
|
-
let [I, Q] = this.iqConverter.convert(b.data);
|
|
287
|
-
this.sampleReceiver.receiveSamples(I, Q, b.frequency);
|
|
288
|
-
if (this.directSampling != b.directSampling) {
|
|
289
|
-
this.directSampling = b.directSampling;
|
|
290
|
-
this.radio.dispatchEvent(new RadioEvent({
|
|
291
|
-
type: "directSampling",
|
|
292
|
-
active: this.directSampling,
|
|
293
|
-
}));
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
catch (e) {
|
|
298
|
-
let error = new RadioError("Sample transfer was interrupted. Did you unplug your device?", RadioErrorType.UsbTransferError, { cause: e });
|
|
299
|
-
let event = new RadioEvent({ type: "error", exception: error });
|
|
300
|
-
this.radio.dispatchEvent(event);
|
|
301
|
-
}
|
|
302
|
-
--this.buffersRunning;
|
|
303
|
-
if (this.buffersRunning == 0) {
|
|
304
|
-
this.stopCallback();
|
|
305
|
-
this.stopCallback = Transfers.nilCallback;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
static nilCallback() { }
|
|
309
|
-
}
|
|
310
96
|
//# sourceMappingURL=radio.js.map
|
package/dist/radio/radio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio.js","sourceRoot":"","sources":["../../src/radio/radio.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,iFAAiF;AAEjF,OAAO,
|
|
1
|
+
{"version":3,"file":"radio.js","sourceRoot":"","sources":["../../src/radio/radio.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Signal sources that read from an RTL-SDR device. */
|
|
2
|
+
import { SampleBlock } from "@jtarrio/signals/radio/sample_block.js";
|
|
3
|
+
import { SignalSource, SignalSourceProvider } from "@jtarrio/signals/radio/signal_source.js";
|
|
4
|
+
import { RtlDevice, RtlDeviceProvider } from "../rtlsdr/rtldevice.js";
|
|
5
|
+
/** Names of parameters for the RTL signal source. */
|
|
6
|
+
export type RtlParameter = "frequency_correction" | "gain" | "direct_sampling_method" | "bias_tee";
|
|
7
|
+
/** SignalSource that reads from an RTL-SDR device. */
|
|
8
|
+
export declare class RtlSource implements SignalSource<RtlParameter> {
|
|
9
|
+
private rtl;
|
|
10
|
+
constructor(rtl: RtlDevice);
|
|
11
|
+
private converter;
|
|
12
|
+
setSampleRate(sampleRate: number): Promise<number>;
|
|
13
|
+
setCenterFrequency(freq: number): Promise<number>;
|
|
14
|
+
setParameter<V>(parameter: RtlParameter, value: V): Promise<void | V>;
|
|
15
|
+
startReceiving(): Promise<void>;
|
|
16
|
+
readSamples(length: number): Promise<SampleBlock>;
|
|
17
|
+
close(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/** SignalSourceProvider that creates a source from the device returned by an RtlDeviceProvider. */
|
|
20
|
+
export declare class RtlProvider implements SignalSourceProvider {
|
|
21
|
+
constructor(provider?: RtlDeviceProvider);
|
|
22
|
+
provider: RtlDeviceProvider;
|
|
23
|
+
get(): Promise<SignalSource>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/radio/source.ts"],"names":[],"mappings":"AAcA,uDAAuD;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EACL,YAAY,EACZ,oBAAoB,EACrB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAEL,SAAS,EACT,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAGhC,qDAAqD;AACrD,MAAM,MAAM,YAAY,GACpB,sBAAsB,GACtB,MAAM,GACN,wBAAwB,GACxB,UAAU,CAAC;AAEf,sDAAsD;AACtD,qBAAa,SAAU,YAAW,YAAY,CAAC,YAAY,CAAC;IAC9C,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAIlC,OAAO,CAAC,SAAS,CAAc;IAE/B,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlD,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjD,YAAY,CAAC,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;IAarE,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAWvD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAGvB;AAED,mGAAmG;AACnG,qBAAa,WAAY,YAAW,oBAAoB;gBAC1C,QAAQ,CAAC,EAAE,iBAAiB;IAIxC,QAAQ,EAAE,iBAAiB,CAAC;IAEtB,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC;CAGnC"}
|