@jtarrio/webrtlsdr 1.1.1 → 2.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/dist/demod/demod-am.d.ts +45 -0
- package/dist/demod/demod-am.d.ts.map +1 -0
- package/dist/demod/{scheme-am.js → demod-am.js} +36 -3
- package/dist/demod/demod-am.js.map +1 -0
- package/dist/demod/demod-cw.d.ts +36 -0
- package/dist/demod/demod-cw.d.ts.map +1 -0
- package/dist/demod/{scheme-cw.js → demod-cw.js} +30 -2
- package/dist/demod/demod-cw.js.map +1 -0
- package/dist/demod/demod-nbfm.d.ts +45 -0
- package/dist/demod/demod-nbfm.d.ts.map +1 -0
- package/dist/demod/{scheme-nbfm.js → demod-nbfm.js} +36 -3
- package/dist/demod/demod-nbfm.js.map +1 -0
- package/dist/demod/demod-ssb.d.ts +45 -0
- package/dist/demod/demod-ssb.d.ts.map +1 -0
- package/dist/demod/{scheme-ssb.js → demod-ssb.js} +36 -4
- package/dist/demod/demod-ssb.js.map +1 -0
- package/dist/demod/demod-wbfm.d.ts +95 -0
- package/dist/demod/demod-wbfm.d.ts.map +1 -0
- package/dist/demod/demod-wbfm.js +205 -0
- package/dist/demod/demod-wbfm.js.map +1 -0
- package/dist/demod/demodulator.d.ts +2 -62
- package/dist/demod/demodulator.d.ts.map +1 -1
- package/dist/demod/demodulator.js +15 -137
- package/dist/demod/demodulator.js.map +1 -1
- package/dist/demod/empty-demodulator.d.ts +62 -0
- package/dist/demod/empty-demodulator.d.ts.map +1 -0
- package/dist/demod/empty-demodulator.js +145 -0
- package/dist/demod/empty-demodulator.js.map +1 -0
- package/dist/demod/modes.d.ts +76 -65
- package/dist/demod/modes.d.ts.map +1 -1
- package/dist/demod/modes.js +59 -99
- package/dist/demod/modes.js.map +1 -1
- package/dist/dsp/buffers.d.ts +1 -1
- package/dist/dsp/buffers.d.ts.map +1 -1
- package/dist/dsp/buffers.js +13 -0
- package/dist/dsp/buffers.js.map +1 -1
- package/dist/dsp/power.d.ts.map +1 -1
- package/dist/dsp/power.js +13 -0
- package/dist/dsp/power.js.map +1 -1
- package/package.json +1 -1
- package/dist/demod/scheme-am.d.ts +0 -32
- package/dist/demod/scheme-am.d.ts.map +0 -1
- package/dist/demod/scheme-am.js.map +0 -1
- package/dist/demod/scheme-cw.d.ts +0 -22
- package/dist/demod/scheme-cw.d.ts.map +0 -1
- package/dist/demod/scheme-cw.js.map +0 -1
- package/dist/demod/scheme-nbfm.d.ts +0 -32
- package/dist/demod/scheme-nbfm.d.ts.map +0 -1
- package/dist/demod/scheme-nbfm.js.map +0 -1
- package/dist/demod/scheme-ssb.d.ts +0 -33
- package/dist/demod/scheme-ssb.d.ts.map +0 -1
- package/dist/demod/scheme-ssb.js.map +0 -1
- package/dist/demod/scheme-wbfm.d.ts +0 -38
- package/dist/demod/scheme-wbfm.d.ts.map +0 -1
- package/dist/demod/scheme-wbfm.js +0 -106
- package/dist/demod/scheme-wbfm.js.map +0 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// Copyright 2024 Jacobo Tarrio Barreiro. All rights reserved.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { getDemod, getMode, modeParameters } from "./modes";
|
|
15
|
+
import { AudioPlayer } from "../players/audioplayer";
|
|
16
|
+
/**
|
|
17
|
+
* A class that takes a stream of radio samples and demodulates
|
|
18
|
+
* it into an audio signal.
|
|
19
|
+
*
|
|
20
|
+
* The demodulator parameters (scheme, bandwidth, etc) are settable
|
|
21
|
+
* on the fly.
|
|
22
|
+
*
|
|
23
|
+
* Whenever a parameter is changed, the demodulator emits a
|
|
24
|
+
* 'demodulator' event containing the new value. This makes it easy
|
|
25
|
+
* to observe the demodulator's state.
|
|
26
|
+
*/
|
|
27
|
+
export class Demodulator extends EventTarget {
|
|
28
|
+
/**
|
|
29
|
+
* @param player The player to use. If undefined, an AudioPlayer will be used.
|
|
30
|
+
*/
|
|
31
|
+
constructor(player) {
|
|
32
|
+
super();
|
|
33
|
+
this.inRate = 1024000;
|
|
34
|
+
this.player = player ? player : new AudioPlayer();
|
|
35
|
+
this.squelchControl = new SquelchControl(this.player.sampleRate);
|
|
36
|
+
this.mode = getMode("WBFM");
|
|
37
|
+
this.demod = this.getScheme(this.mode);
|
|
38
|
+
this.frequencyOffset = 0;
|
|
39
|
+
this.latestStereo = false;
|
|
40
|
+
}
|
|
41
|
+
/** The sample rate. */
|
|
42
|
+
inRate;
|
|
43
|
+
/** The audio output device. */
|
|
44
|
+
player;
|
|
45
|
+
/** Controller that silences the output if the SNR is low. */
|
|
46
|
+
squelchControl;
|
|
47
|
+
/** The modulation parameters as a Mode object. */
|
|
48
|
+
mode;
|
|
49
|
+
/** The demodulator class. */
|
|
50
|
+
demod;
|
|
51
|
+
/** The frequency offset to demodulate from. */
|
|
52
|
+
frequencyOffset;
|
|
53
|
+
/** Whether the latest samples were in stereo. */
|
|
54
|
+
latestStereo;
|
|
55
|
+
/** A frequency change we are expecting. */
|
|
56
|
+
expectingFrequency;
|
|
57
|
+
/** Changes the modulation parameters. */
|
|
58
|
+
setMode(mode) {
|
|
59
|
+
this.demod = this.getScheme(mode, this.demod);
|
|
60
|
+
this.mode = mode;
|
|
61
|
+
}
|
|
62
|
+
/** Returns the current modulation parameters. */
|
|
63
|
+
getMode() {
|
|
64
|
+
return this.mode;
|
|
65
|
+
}
|
|
66
|
+
/** Changes the frequency offset. */
|
|
67
|
+
setFrequencyOffset(offset) {
|
|
68
|
+
this.frequencyOffset = offset;
|
|
69
|
+
}
|
|
70
|
+
/** Returns the current frequency offset. */
|
|
71
|
+
getFrequencyOffset() {
|
|
72
|
+
return this.frequencyOffset;
|
|
73
|
+
}
|
|
74
|
+
/** Waits until samples arrive with the given center frequency and then sets the offset. */
|
|
75
|
+
expectFrequencyAndSetOffset(center, offset) {
|
|
76
|
+
this.expectingFrequency = { center, offset };
|
|
77
|
+
}
|
|
78
|
+
/** Sets the audio volume level, from 0 to 1. */
|
|
79
|
+
setVolume(volume) {
|
|
80
|
+
this.player.setVolume(volume);
|
|
81
|
+
}
|
|
82
|
+
/** Returns the current audio volume level. */
|
|
83
|
+
getVolume() {
|
|
84
|
+
return this.player.getVolume();
|
|
85
|
+
}
|
|
86
|
+
/** Returns an appropriate instance of Scheme for the requested mode. */
|
|
87
|
+
getScheme(mode, demod) {
|
|
88
|
+
if (mode.scheme == demod?.getMode().scheme) {
|
|
89
|
+
demod.setMode(mode);
|
|
90
|
+
return demod;
|
|
91
|
+
}
|
|
92
|
+
return getDemod(this.inRate, this.player.sampleRate, mode);
|
|
93
|
+
}
|
|
94
|
+
/** Changes the sample rate. */
|
|
95
|
+
setSampleRate(sampleRate) {
|
|
96
|
+
this.inRate = sampleRate;
|
|
97
|
+
this.demod = this.getScheme(this.mode, undefined);
|
|
98
|
+
}
|
|
99
|
+
/** Receives radio samples. */
|
|
100
|
+
receiveSamples(I, Q, frequency) {
|
|
101
|
+
if (this.expectingFrequency?.center === frequency) {
|
|
102
|
+
this.frequencyOffset = this.expectingFrequency.offset;
|
|
103
|
+
this.expectingFrequency = undefined;
|
|
104
|
+
}
|
|
105
|
+
let { left, right, stereo, snr } = this.demod.demodulate(I, Q, this.frequencyOffset);
|
|
106
|
+
this.squelchControl.applySquelch(this.mode, left, right, snr);
|
|
107
|
+
this.player.play(left, right);
|
|
108
|
+
if (stereo != this.latestStereo) {
|
|
109
|
+
this.dispatchEvent(new StereoStatusEvent(stereo));
|
|
110
|
+
this.latestStereo = stereo;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
addEventListener(type, callback, options) {
|
|
114
|
+
super.addEventListener(type, callback, options);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export class StereoStatusEvent extends CustomEvent {
|
|
118
|
+
constructor(stereo) {
|
|
119
|
+
super("stereo-status", { detail: stereo, bubbles: true, composed: true });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
class SquelchControl {
|
|
123
|
+
sampleRate;
|
|
124
|
+
constructor(sampleRate) {
|
|
125
|
+
this.sampleRate = sampleRate;
|
|
126
|
+
}
|
|
127
|
+
countdown = 0;
|
|
128
|
+
applySquelch(mode, left, right, snr) {
|
|
129
|
+
const SQUELCH_TAIL = 0.1;
|
|
130
|
+
let params = modeParameters(mode);
|
|
131
|
+
if (!params.hasSquelch())
|
|
132
|
+
return;
|
|
133
|
+
if (params.getSquelch() < snr) {
|
|
134
|
+
this.countdown = SQUELCH_TAIL * this.sampleRate;
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (this.countdown > 0) {
|
|
138
|
+
this.countdown -= left.length;
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
left.fill(0);
|
|
142
|
+
right.fill(0);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=empty-demodulator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty-demodulator.js","sourceRoot":"","sources":["../../src/demod/empty-demodulator.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,OAAO,EAAe,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,S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C,UAAU,EAAE,GAAG,GAAG,EAAE,CAAC;YAC9B,IAAI,CAAC,SAAS,GAAG,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC;YAChD,OAAO;QACT,CAAC;QACD,IAAI,IAAI,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC;YAC9B,OAAO;QACT,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACb,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;CACF"}
|
package/dist/demod/modes.d.ts
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Demodulation schemes consist of three parts: a class that does the demodulation
|
|
3
|
+
* (extends `Demod`), a type for the modulation parameters (extends `Mode`),
|
|
4
|
+
* and a class that provides a uniform interface to configure the modulation
|
|
5
|
+
* (extends `Configurator`).
|
|
6
|
+
*
|
|
7
|
+
* The type for the modulation parameters is an object that must contain a
|
|
8
|
+
* field named `scheme`, which contains the name of the modulation scheme.
|
|
9
|
+
* Other than that, your type may contain anything; however, I recommend that
|
|
10
|
+
* you make it JSON serializable.
|
|
11
|
+
*
|
|
12
|
+
* The configurator class lets you use generic code to configure the mode.
|
|
13
|
+
* It provides methods to tell whether some settings are configurable, and to
|
|
14
|
+
* get and set their values. Those methods take care of clamping the minimum
|
|
15
|
+
* and maximum values and other validation.
|
|
16
|
+
*
|
|
17
|
+
* The demodulator class takes I and Q samples and outputs audio samples.
|
|
18
|
+
* It can be configured using the `setMode()` method, which takes an object
|
|
19
|
+
* with the new modulation parameters.
|
|
20
|
+
*
|
|
21
|
+
* Demodulation schemes can be registered using the `registerDemod()` function,
|
|
22
|
+
* which makes them available via the `getSchemes()`, `getMode()`, and `getDemod()`
|
|
23
|
+
* functions. This also lets the `Demodulator` class use your demodulation scheme.
|
|
24
|
+
*/
|
|
1
25
|
/** Interface for classes that demodulate IQ radio streams. */
|
|
2
|
-
export interface
|
|
26
|
+
export interface Demod<M extends Mode> {
|
|
3
27
|
/** Returns the current mode parameters. */
|
|
4
|
-
getMode():
|
|
5
|
-
/** Changes the mode parameters for the
|
|
6
|
-
setMode(mode:
|
|
28
|
+
getMode(): M;
|
|
29
|
+
/** Changes the mode parameters for the demod. */
|
|
30
|
+
setMode(mode: M): void;
|
|
7
31
|
/**
|
|
8
32
|
* Demodulates the signal.
|
|
9
33
|
* @param samplesI The I components of the samples.
|
|
@@ -25,73 +49,60 @@ export type Demodulated = {
|
|
|
25
49
|
snr: number;
|
|
26
50
|
};
|
|
27
51
|
/** Modulation parameters. */
|
|
28
|
-
export type Mode =
|
|
29
|
-
|
|
30
|
-
{
|
|
31
|
-
scheme: "WBFM";
|
|
32
|
-
stereo: boolean;
|
|
33
|
-
}
|
|
34
|
-
/** Narrowband frequency modulation. */
|
|
35
|
-
| {
|
|
36
|
-
scheme: "NBFM";
|
|
37
|
-
maxF: number;
|
|
38
|
-
squelch: number;
|
|
39
|
-
}
|
|
40
|
-
/** Amplitude modulation. */
|
|
41
|
-
| {
|
|
42
|
-
scheme: "AM";
|
|
43
|
-
bandwidth: number;
|
|
44
|
-
squelch: number;
|
|
45
|
-
}
|
|
46
|
-
/** Upper sideband modulation. */
|
|
47
|
-
| {
|
|
48
|
-
scheme: "USB";
|
|
49
|
-
bandwidth: number;
|
|
50
|
-
squelch: number;
|
|
51
|
-
}
|
|
52
|
-
/** Lower sideband modulation. */
|
|
53
|
-
| {
|
|
54
|
-
scheme: "LSB";
|
|
55
|
-
bandwidth: number;
|
|
56
|
-
squelch: number;
|
|
57
|
-
}
|
|
58
|
-
/** Continuous wave. */
|
|
59
|
-
| {
|
|
60
|
-
scheme: "CW";
|
|
61
|
-
bandwidth: number;
|
|
52
|
+
export type Mode = {
|
|
53
|
+
scheme: string;
|
|
62
54
|
};
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Registers a modulation scheme. If a modulation scheme by that name already exists, it is replaced.
|
|
57
|
+
* @param name the name of the modulation scheme. Must match the content of `scheme` in the mode.
|
|
58
|
+
* @param demod the constructor of the Demod class.
|
|
59
|
+
* @param params the constructor of the Parameters class.
|
|
60
|
+
*/
|
|
61
|
+
export declare function registerDemod<M extends Mode>(name: M["scheme"], demod: DemodConstructor<M>, params: ParametersConstructor<M>): void;
|
|
62
|
+
/** Unregisters a modulation scheme. */
|
|
63
|
+
export declare function unregisterDemod(name: string): void;
|
|
64
|
+
/** Returns the list of registered modulation schemes, in the order in which they were registered. */
|
|
65
|
+
export declare function getSchemes(): Array<string>;
|
|
66
|
+
/** Returns the default mode for the given scheme name. */
|
|
67
|
+
export declare function getMode(scheme: string): Mode;
|
|
68
|
+
/** Returns a Scheme object for the given mode. */
|
|
69
|
+
export declare function getDemod<M extends Mode>(inRate: number, outRate: number, mode: M): Demod<M>;
|
|
69
70
|
/** Returns accessors for the mode's or scheme's parameters. */
|
|
70
|
-
export declare function modeParameters(mode:
|
|
71
|
-
export declare function modeParameters(scheme:
|
|
72
|
-
/** A
|
|
73
|
-
export declare class
|
|
74
|
-
|
|
75
|
-
constructor(
|
|
71
|
+
export declare function modeParameters<M extends Mode>(mode: M): Configurator<M>;
|
|
72
|
+
export declare function modeParameters(scheme: string): Configurator<Mode>;
|
|
73
|
+
/** A base for classes that inspect and modify a mode parameters object. */
|
|
74
|
+
export declare abstract class Configurator<M extends Mode> {
|
|
75
|
+
private base;
|
|
76
|
+
constructor(base: M | string);
|
|
77
|
+
get mode(): M;
|
|
78
|
+
protected set mode(mode: M);
|
|
79
|
+
/** Creates an instance of the mode object for the given scheme with the default parameters. */
|
|
80
|
+
protected abstract create(scheme: string): M;
|
|
81
|
+
/** Returns whether stereo output is settable in this mode. */
|
|
76
82
|
hasStereo(): boolean;
|
|
83
|
+
/** Returns whether stereo output is enabled. */
|
|
77
84
|
getStereo(): boolean;
|
|
78
|
-
|
|
85
|
+
/** Enables or disables stereo output. */
|
|
86
|
+
setStereo(stereo: boolean): Configurator<M>;
|
|
87
|
+
/** Returns whether the bandwidth is settable in this mode. */
|
|
79
88
|
hasBandwidth(): boolean;
|
|
80
|
-
|
|
81
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Returns the bandwidth used by this mode.
|
|
91
|
+
* You should always override this as every mode uses some bandwidth, even if it's not settable.
|
|
92
|
+
*/
|
|
93
|
+
abstract getBandwidth(): number;
|
|
94
|
+
/** Changes the bandwidth used by this mode. */
|
|
95
|
+
setBandwidth(bandwidth: number): Configurator<M>;
|
|
96
|
+
/** Returns whether the squelch level is settable. */
|
|
82
97
|
hasSquelch(): boolean;
|
|
98
|
+
/** Returns the current squelch level. */
|
|
83
99
|
getSquelch(): number;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
/** A class to inspect a scheme's parameters. */
|
|
87
|
-
export declare class SchemeParameters {
|
|
88
|
-
scheme: Scheme;
|
|
89
|
-
constructor(scheme: Scheme);
|
|
90
|
-
hasStereo(): boolean;
|
|
91
|
-
setStereo(stereo: boolean): ModeParameters;
|
|
92
|
-
hasBandwidth(): boolean;
|
|
93
|
-
setBandwidth(bandwidth: number): ModeParameters;
|
|
94
|
-
hasSquelch(): boolean;
|
|
95
|
-
setSquelch(squelch: number): ModeParameters;
|
|
100
|
+
/** Sets the squelch level. */
|
|
101
|
+
setSquelch(squelch: number): Configurator<M>;
|
|
96
102
|
}
|
|
103
|
+
/** The type for a constructor of a Scheme object. */
|
|
104
|
+
type DemodConstructor<M extends Mode> = new (inRate: number, outRate: number, mode: M) => Demod<M>;
|
|
105
|
+
/** The type for a constructor of a Parameters object. */
|
|
106
|
+
type ParametersConstructor<M extends Mode> = new (base: M | string) => Configurator<M>;
|
|
107
|
+
export {};
|
|
97
108
|
//# sourceMappingURL=modes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modes.d.ts","sourceRoot":"","sources":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AI,KACtC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,CAAC,KACJ,KAAK,CAAC,CAAC,CAAC,CAAC;AAEd,yDAAyD;AACzD,KAAK,qBAAqB,CAAC,CAAC,SAAS,IAAI,IAAI,KAC3C,IAAI,EAAE,CAAC,GAAG,MAAM,KACb,YAAY,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/demod/modes.js
CHANGED
|
@@ -11,131 +11,91 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Registers a modulation scheme. If a modulation scheme by that name already exists, it is replaced.
|
|
16
|
+
* @param name the name of the modulation scheme. Must match the content of `scheme` in the mode.
|
|
17
|
+
* @param demod the constructor of the Demod class.
|
|
18
|
+
* @param params the constructor of the Parameters class.
|
|
19
|
+
*/
|
|
20
|
+
export function registerDemod(name, demod, params) {
|
|
21
|
+
registeredDemods.set(name, { demod: demod, params });
|
|
22
|
+
}
|
|
23
|
+
/** Unregisters a modulation scheme. */
|
|
24
|
+
export function unregisterDemod(name) {
|
|
25
|
+
registeredDemods.delete(name);
|
|
26
|
+
}
|
|
27
|
+
/** Returns the list of registered modulation schemes, in the order in which they were registered. */
|
|
15
28
|
export function getSchemes() {
|
|
16
|
-
return [
|
|
29
|
+
return [...registeredDemods.keys()];
|
|
17
30
|
}
|
|
18
|
-
/** Returns the default mode for the given scheme. */
|
|
31
|
+
/** Returns the default mode for the given scheme name. */
|
|
19
32
|
export function getMode(scheme) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
case "USB":
|
|
28
|
-
return { scheme: "USB", bandwidth: 2800, squelch: 0 };
|
|
29
|
-
case "LSB":
|
|
30
|
-
return { scheme: "LSB", bandwidth: 2800, squelch: 0 };
|
|
31
|
-
case "CW":
|
|
32
|
-
return { scheme: "CW", bandwidth: 50 };
|
|
33
|
-
}
|
|
33
|
+
let reg = getRegisteredDemod(scheme);
|
|
34
|
+
return new reg.params(scheme).mode;
|
|
35
|
+
}
|
|
36
|
+
/** Returns a Scheme object for the given mode. */
|
|
37
|
+
export function getDemod(inRate, outRate, mode) {
|
|
38
|
+
let reg = getRegisteredDemod(mode);
|
|
39
|
+
return new reg.demod(inRate, outRate, mode);
|
|
34
40
|
}
|
|
35
41
|
export function modeParameters(mode) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return new ModeParameters(mode);
|
|
42
|
+
let reg = getRegisteredDemod(mode);
|
|
43
|
+
return new reg.params(mode);
|
|
39
44
|
}
|
|
40
|
-
/** A
|
|
41
|
-
export class
|
|
42
|
-
|
|
43
|
-
constructor(
|
|
44
|
-
this.
|
|
45
|
+
/** A base for classes that inspect and modify a mode parameters object. */
|
|
46
|
+
export class Configurator {
|
|
47
|
+
base;
|
|
48
|
+
constructor(base) {
|
|
49
|
+
this.base = base;
|
|
50
|
+
}
|
|
51
|
+
get mode() {
|
|
52
|
+
if (typeof this.base === "string") {
|
|
53
|
+
this.base = this.create(this.base);
|
|
54
|
+
}
|
|
55
|
+
return this.base;
|
|
56
|
+
}
|
|
57
|
+
set mode(mode) {
|
|
58
|
+
this.base = mode;
|
|
45
59
|
}
|
|
60
|
+
/** Returns whether stereo output is settable in this mode. */
|
|
46
61
|
hasStereo() {
|
|
47
|
-
return
|
|
62
|
+
return false;
|
|
48
63
|
}
|
|
64
|
+
/** Returns whether stereo output is enabled. */
|
|
49
65
|
getStereo() {
|
|
50
|
-
return
|
|
66
|
+
return false;
|
|
51
67
|
}
|
|
68
|
+
/** Enables or disables stereo output. */
|
|
52
69
|
setStereo(stereo) {
|
|
53
|
-
if (this.mode.scheme == "WBFM")
|
|
54
|
-
this.mode = { ...this.mode, stereo: stereo };
|
|
55
70
|
return this;
|
|
56
71
|
}
|
|
72
|
+
/** Returns whether the bandwidth is settable in this mode. */
|
|
57
73
|
hasBandwidth() {
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
getBandwidth() {
|
|
61
|
-
switch (this.mode.scheme) {
|
|
62
|
-
case "WBFM":
|
|
63
|
-
return 150000;
|
|
64
|
-
case "NBFM":
|
|
65
|
-
return 2 * this.mode.maxF;
|
|
66
|
-
default:
|
|
67
|
-
return this.mode.bandwidth;
|
|
68
|
-
}
|
|
74
|
+
return false;
|
|
69
75
|
}
|
|
76
|
+
/** Changes the bandwidth used by this mode. */
|
|
70
77
|
setBandwidth(bandwidth) {
|
|
71
|
-
switch (this.mode.scheme) {
|
|
72
|
-
case "WBFM":
|
|
73
|
-
break;
|
|
74
|
-
case "NBFM":
|
|
75
|
-
this.mode = {
|
|
76
|
-
...this.mode,
|
|
77
|
-
maxF: Math.max(125, Math.min(bandwidth / 2, 15000)),
|
|
78
|
-
};
|
|
79
|
-
break;
|
|
80
|
-
case "AM":
|
|
81
|
-
this.mode = {
|
|
82
|
-
...this.mode,
|
|
83
|
-
bandwidth: Math.max(250, Math.min(bandwidth, 30000)),
|
|
84
|
-
};
|
|
85
|
-
break;
|
|
86
|
-
case "USB":
|
|
87
|
-
case "LSB":
|
|
88
|
-
this.mode = {
|
|
89
|
-
...this.mode,
|
|
90
|
-
bandwidth: Math.max(10, Math.min(bandwidth, 15000)),
|
|
91
|
-
};
|
|
92
|
-
break;
|
|
93
|
-
case "CW":
|
|
94
|
-
this.mode = {
|
|
95
|
-
...this.mode,
|
|
96
|
-
bandwidth: Math.max(5, Math.min(bandwidth, 1000)),
|
|
97
|
-
};
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
78
|
return this;
|
|
101
79
|
}
|
|
80
|
+
/** Returns whether the squelch level is settable. */
|
|
102
81
|
hasSquelch() {
|
|
103
|
-
return
|
|
82
|
+
return false;
|
|
104
83
|
}
|
|
84
|
+
/** Returns the current squelch level. */
|
|
105
85
|
getSquelch() {
|
|
106
|
-
|
|
107
|
-
return 0;
|
|
108
|
-
return this.mode.squelch;
|
|
86
|
+
return 0;
|
|
109
87
|
}
|
|
88
|
+
/** Sets the squelch level. */
|
|
110
89
|
setSquelch(squelch) {
|
|
111
|
-
if (this.mode.scheme != "WBFM" && this.mode.scheme != "CW")
|
|
112
|
-
this.mode = { ...this.mode, squelch: Math.max(0, Math.min(squelch, 6)) };
|
|
113
90
|
return this;
|
|
114
91
|
}
|
|
115
92
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
scheme;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return this.scheme == "WBFM";
|
|
124
|
-
}
|
|
125
|
-
setStereo(stereo) {
|
|
126
|
-
return modeParameters(getMode(this.scheme)).setStereo(stereo);
|
|
127
|
-
}
|
|
128
|
-
hasBandwidth() {
|
|
129
|
-
return this.scheme != "WBFM";
|
|
130
|
-
}
|
|
131
|
-
setBandwidth(bandwidth) {
|
|
132
|
-
return modeParameters(getMode(this.scheme)).setBandwidth(bandwidth);
|
|
133
|
-
}
|
|
134
|
-
hasSquelch() {
|
|
135
|
-
return this.scheme != "WBFM" && this.scheme != "CW";
|
|
136
|
-
}
|
|
137
|
-
setSquelch(squelch) {
|
|
138
|
-
return modeParameters(getMode(this.scheme)).setSquelch(squelch);
|
|
139
|
-
}
|
|
93
|
+
var registeredDemods = new Map();
|
|
94
|
+
function getRegisteredDemod(mode) {
|
|
95
|
+
let scheme = typeof mode === "string" ? mode : mode.scheme;
|
|
96
|
+
let reg = registeredDemods.get(scheme);
|
|
97
|
+
if (!reg)
|
|
98
|
+
throw `Scheme "${scheme}" was not registered.`;
|
|
99
|
+
return reg;
|
|
140
100
|
}
|
|
141
101
|
//# sourceMappingURL=modes.js.map
|
package/dist/demod/modes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modes.js","sourceRoot":"","sources":["../../src/demod/modes.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;
|
|
1
|
+
{"version":3,"file":"modes.js","sourceRoot":"","sources":["../../src/demod/modes.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;AA0DjC;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAiB,EACjB,KAA0B,EAC1B,MAAgC;IAEhC,gBAAgB,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;AACvD,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,UAAU;IACxB,OAAO,CAAC,GAAG,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;AACtC,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,OAAO,CAAC,MAAc;IACpC,IAAI,GAAG,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACrC,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;AACrC,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,QAAQ,CACtB,MAAc,EACd,OAAe,EACf,IAAO;IAEP,IAAI,GAAG,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,IAAI,GAAG,CAAC,KAAK,CAA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kBAAkB,CAAC,IAAmB;IAC7C,IAAI,MAAM,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IAC3D,IAAI,GAAG,GAAG,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,CAAC,GAAG;QAAE,MAAM,WAAW,MAAM,uBAAuB,CAAC;IACzD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/dsp/buffers.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A source of pre-allocated arrays of a given size.
|
|
3
3
|
*/
|
|
4
|
-
declare class Buffer<T extends ArrayLike<number>> {
|
|
4
|
+
declare abstract class Buffer<T extends ArrayLike<number>> {
|
|
5
5
|
private make;
|
|
6
6
|
/**
|
|
7
7
|
* @param make A function that returns an array of the given length.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffers.d.ts","sourceRoot":"","sources":["../../src/dsp/buffers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buffers.d.ts","sourceRoot":"","sources":["../../src/dsp/buffers.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,uBAAe,MAAM,CAAC,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC;IAO7C,OAAO,CAAC,IAAI;IANd;;;;OAIG;gBAEO,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC,EACnC,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM;IAMjB,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,OAAO,CAAS;IAExB,6EAA6E;IAC7E,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC;CASvB;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,MAAM,CAAC,UAAU,CAAC;IAC9C;;;OAGG;gBACS,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAG3C;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,MAAM,CAAC,YAAY,CAAC;IACrD;;;OAGG;gBACS,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAG3C;AAED;;GAEG;AACH,qBAAa,QAAQ;IACnB;;;OAGG;gBACS,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAI1C,OAAO,CAAC,OAAO,CAAgB;IAE/B,uFAAuF;IACvF,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC;CAGlD;AAED,UAAU,UAAU,CAAC,CAAC,CAAE,SAAQ,SAAS,CAAC,MAAM,CAAC;IAC/C,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;CAC3C;AAED;;GAEG;AACH,cAAM,UAAU,CAAC,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC;IAC1B,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,CAAC;IAI7B,OAAO,CAAC,QAAQ,CAAS;IAEzB,KAAK,CAAC,IAAI,EAAE,CAAC;IAMb,MAAM,CAAC,IAAI,EAAE,CAAC;IAOd,OAAO,CAAC,MAAM;CAoBf;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,UAAU,CAAC,YAAY,CAAC;gBACjD,IAAI,EAAE,MAAM;CAGzB"}
|
package/dist/dsp/buffers.js
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
// Copyright 2024 Jacobo Tarrio Barreiro. All rights reserved.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
1
14
|
/**
|
|
2
15
|
* A source of pre-allocated arrays of a given size.
|
|
3
16
|
*/
|
package/dist/dsp/buffers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffers.js","sourceRoot":"","sources":["../../src/dsp/buffers.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"buffers.js","sourceRoot":"","sources":["../../src/dsp/buffers.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;;GAEG;AACH,MAAe,MAAM;IAOT;IANV;;;;OAIG;IACH,YACU,IAA2B,EACnC,KAAa,EACb,MAAe;QAFP,SAAI,GAAJ,IAAI,CAAuB;QAInC,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IACnB,CAAC;IAEO,OAAO,CAAW;IAClB,OAAO,CAAS;IAExB,6EAA6E;IAC7E,GAAG,CAAC,MAAc;QAChB,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,O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,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC,EAAE,SAAS,CAAC,CAAC;YACnE,SAAS,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;YACjD,SAAS,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;YACjD,KAAK,IAAI,SAAS,CAAC;QACrB,CAAC;QACD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;IAClC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,UAAwB;IAC7D,YAAY,IAAY;QACtB,KAAK,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAChC,CAAC;CACF"}
|
package/dist/dsp/power.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"power.d.ts","sourceRoot":"","sources":["../../src/dsp/power.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"power.d.ts","sourceRoot":"","sources":["../../src/dsp/power.ts"],"names":[],"mappings":"AAcA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,MAAM,CAQjE"}
|
package/dist/dsp/power.js
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
// Copyright 2024 Jacobo Tarrio Barreiro. All rights reserved.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
1
14
|
export function getPower(I, Q) {
|
|
2
15
|
let power = 0;
|
|
3
16
|
for (let i = 0; i < I.length; ++i) {
|
package/dist/dsp/power.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"power.js","sourceRoot":"","sources":["../../src/dsp/power.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,CAAe,EAAE,CAAe;IACvD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QAClC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAChB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAChB,KAAK,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IAC7B,CAAC;IACD,OAAO,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC;AAC1B,CAAC"}
|
|
1
|
+
{"version":3,"file":"power.js","sourceRoot":"","sources":["../../src/dsp/power.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,UAAU,QAAQ,CAAC,CAAe,EAAE,CAAe;IACvD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QAClC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAChB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAChB,KAAK,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IAC7B,CAAC;IACD,OAAO,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC;AAC1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jtarrio/webrtlsdr",
|
|
3
3
|
"description": "Access RTL-SDR devices and receive and demodulate radio signals from your web application",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"author": "Jacobo Tarrio <jtarrio@gmail.com>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|