@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
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Mode } from "./modes.js";
|
|
2
|
-
import { Player } from "./player.js";
|
|
3
|
-
import { SampleReceiver } from "../radio.js";
|
|
4
|
-
/**
|
|
5
|
-
* A class that takes a stream of radio samples and demodulates
|
|
6
|
-
* it into an audio signal.
|
|
7
|
-
*
|
|
8
|
-
* The demodulator parameters (scheme, bandwidth, etc) are settable
|
|
9
|
-
* on the fly.
|
|
10
|
-
*
|
|
11
|
-
* Whenever a parameter is changed, the demodulator emits a
|
|
12
|
-
* 'demodulator' event containing the new value. This makes it easy
|
|
13
|
-
* to observe the demodulator's state.
|
|
14
|
-
*/
|
|
15
|
-
export declare class Demodulator extends EventTarget implements SampleReceiver {
|
|
16
|
-
/**
|
|
17
|
-
* @param player The player to use. If undefined, an AudioPlayer will be used.
|
|
18
|
-
*/
|
|
19
|
-
constructor(player?: Player);
|
|
20
|
-
/** The sample rate. */
|
|
21
|
-
private inRate;
|
|
22
|
-
/** The audio output device. */
|
|
23
|
-
private player;
|
|
24
|
-
/** Controller that silences the output if the SNR is low. */
|
|
25
|
-
private squelchControl;
|
|
26
|
-
/** The modulation parameters as a Mode object. */
|
|
27
|
-
private mode;
|
|
28
|
-
/** The demodulator class. */
|
|
29
|
-
private demod;
|
|
30
|
-
/** The frequency offset to demodulate from. */
|
|
31
|
-
private frequencyOffset;
|
|
32
|
-
/** Whether the latest samples were in stereo. */
|
|
33
|
-
private latestStereo;
|
|
34
|
-
/** A frequency change we are expecting. */
|
|
35
|
-
private expectingFrequency?;
|
|
36
|
-
/** Changes the modulation parameters. */
|
|
37
|
-
setMode(mode: Mode): void;
|
|
38
|
-
/** Returns the current modulation parameters. */
|
|
39
|
-
getMode(): Mode;
|
|
40
|
-
/** Changes the frequency offset. */
|
|
41
|
-
setFrequencyOffset(offset: number): void;
|
|
42
|
-
/** Returns the current frequency offset. */
|
|
43
|
-
getFrequencyOffset(): number;
|
|
44
|
-
/** Waits until samples arrive with the given center frequency and then sets the offset. */
|
|
45
|
-
expectFrequencyAndSetOffset(center: number, offset: number): void;
|
|
46
|
-
/** Sets the audio volume level, from 0 to 1. */
|
|
47
|
-
setVolume(volume: number): void;
|
|
48
|
-
/** Returns the current audio volume level. */
|
|
49
|
-
getVolume(): number;
|
|
50
|
-
/** Returns an appropriate instance of Scheme for the requested mode. */
|
|
51
|
-
private getScheme;
|
|
52
|
-
/** Changes the sample rate. */
|
|
53
|
-
setSampleRate(sampleRate: number): void;
|
|
54
|
-
/** Receives radio samples. */
|
|
55
|
-
receiveSamples(I: Float32Array, Q: Float32Array, frequency: number): void;
|
|
56
|
-
addEventListener(type: "stereo-status", callback: (e: StereoStatusEvent) => void | null, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
57
|
-
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
58
|
-
}
|
|
59
|
-
export declare class StereoStatusEvent extends CustomEvent<boolean> {
|
|
60
|
-
constructor(stereo: boolean);
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=empty-demodulator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"empty-demodulator.d.ts","sourceRoot":"","sources":["../../src/demod/empty-demodulator.ts"],"names":[],"mappings":"AAcA,OAAO,EAAS,IAAI,EAAqC,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,qBAAa,WAAY,SAAQ,WAAY,YAAW,cAAc;IACpE;;OAEG;gBACS,MAAM,CAAC,EAAE,MAAM;IAW3B,uBAAuB;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,+BAA+B;IAC/B,OAAO,CAAC,MAAM,CAAS;IACvB,6DAA6D;IAC7D,OAAO,CAAC,cAAc,CAAiB;IACvC,kDAAkD;IAClD,OAAO,CAAC,IAAI,CAAO;IACnB,6BAA6B;IAC7B,OAAO,CAAC,KAAK,CAAa;IAC1B,+CAA+C;IAC/C,OAAO,CAAC,eAAe,CAAS;IAChC,iDAAiD;IACjD,OAAO,CAAC,YAAY,CAAU;IAC9B,2CAA2C;IAC3C,OAAO,CAAC,kBAAkB,CAAC,CAAY;IAEvC,yCAAyC;IACzC,OAAO,CAAC,IAAI,EAAE,IAAI;IAKlB,iDAAiD;IACjD,OAAO,IAAI,IAAI;IAIf,oCAAoC;IACpC,kBAAkB,CAAC,MAAM,EAAE,MAAM;IAIjC,4CAA4C;IAC5C,kBAAkB;IAIlB,2FAA2F;IAC3F,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAI1D,gDAAgD;IAChD,SAAS,CAAC,MAAM,EAAE,MAAM;IAIxB,8CAA8C;IAC9C,SAAS;IAIT,wEAAwE;IACxE,OAAO,CAAC,SAAS;IASjB,+BAA+B;IAC/B,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAKvC,8BAA8B;IAC9B,cAAc,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAmBzE,gBAAgB,CACd,IAAI,EAAE,eAAe,EACrB,QAAQ,EAAE,CAAC,CAAC,EAAE,iBAAiB,KAAK,IAAI,GAAG,IAAI,EAC/C,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;AAED,qBAAa,iBAAkB,SAAQ,WAAW,CAAC,OAAO,CAAC;gBAC7C,MAAM,EAAE,OAAO;CAG5B"}
|
|
@@ -1,145 +0,0 @@
|
|
|
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.js";
|
|
15
|
-
import { AudioPlayer } from "../players/audioplayer.js";
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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;A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AAC,MAAM,CAAC,UAAU,EAAE;YAAE,OAAO;QACjC,IAAI,MAAM,CAAC,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
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
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
|
-
*/
|
|
25
|
-
/** Interface for classes that demodulate IQ radio streams. */
|
|
26
|
-
export interface Demod<M extends Mode> {
|
|
27
|
-
/** Returns the current mode parameters. */
|
|
28
|
-
getMode(): M;
|
|
29
|
-
/** Changes the mode parameters for the demod. */
|
|
30
|
-
setMode(mode: M): void;
|
|
31
|
-
/**
|
|
32
|
-
* Demodulates the signal.
|
|
33
|
-
* @param samplesI The I components of the samples.
|
|
34
|
-
* @param samplesQ The Q components of the samples.
|
|
35
|
-
* @param freqOffset The offset of the signal in the samples.
|
|
36
|
-
* @returns The demodulated audio signal.
|
|
37
|
-
*/
|
|
38
|
-
demodulate(I: Float32Array, Q: Float32Array, freqOffset: number): Demodulated;
|
|
39
|
-
}
|
|
40
|
-
/** Demodulator output. */
|
|
41
|
-
export type Demodulated = {
|
|
42
|
-
/** Left speaker. */
|
|
43
|
-
left: Float32Array;
|
|
44
|
-
/** Right speaker. */
|
|
45
|
-
right: Float32Array;
|
|
46
|
-
/** The signal is in stereo. */
|
|
47
|
-
stereo: boolean;
|
|
48
|
-
/** Estimated signal to noise ratio (in units, not dB). */
|
|
49
|
-
snr: number;
|
|
50
|
-
};
|
|
51
|
-
/** Modulation parameters. */
|
|
52
|
-
export type Mode = {
|
|
53
|
-
scheme: string;
|
|
54
|
-
};
|
|
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 config the constructor of the Configurator class.
|
|
60
|
-
*/
|
|
61
|
-
export declare function registerDemod<M extends Mode>(name: M["scheme"], demod: DemodConstructor<M>, config: ConfigConstructor<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>;
|
|
70
|
-
/** Returns accessors for the mode's or scheme's parameters. */
|
|
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. */
|
|
82
|
-
hasStereo(): boolean;
|
|
83
|
-
/** Returns whether stereo output is enabled. */
|
|
84
|
-
getStereo(): boolean;
|
|
85
|
-
/** Enables or disables stereo output. */
|
|
86
|
-
setStereo(stereo: boolean): Configurator<M>;
|
|
87
|
-
/** Returns whether the bandwidth is settable in this mode. */
|
|
88
|
-
hasBandwidth(): boolean;
|
|
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. */
|
|
97
|
-
hasSquelch(): boolean;
|
|
98
|
-
/** Returns the current squelch level. */
|
|
99
|
-
getSquelch(): number;
|
|
100
|
-
/** Sets the squelch level. */
|
|
101
|
-
setSquelch(squelch: number): Configurator<M>;
|
|
102
|
-
}
|
|
103
|
-
/** The type for a constructor of a Scheme object. */
|
|
104
|
-
export type DemodConstructor<M extends Mode> = new (inRate: number, outRate: number, mode: M) => Demod<M>;
|
|
105
|
-
/** The type for a constructor of a Configurator object. */
|
|
106
|
-
export type ConfigConstructor<M extends Mode> = new (base: M | string) => Configurator<M>;
|
|
107
|
-
//# sourceMappingURL=modes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"modes.d.ts","sourceRoot":"","sources":["../../src/demod/modes.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,8DAA8D;AAC9D,MAAM,WAAW,KAAK,CAAC,CAAC,SAAS,IAAI;IACnC,2CAA2C;IAC3C,OAAO,IAAI,CAAC,CAAC;IACb,iDAAiD;IACjD,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACvB;;;;;;OAMG;IACH,UAAU,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,WAAW,CAAC;CAC/E;AAED,0BAA0B;AAC1B,MAAM,MAAM,WAAW,GAAG;IACxB,oBAAoB;IACpB,IAAI,EAAE,YAAY,CAAC;IACnB,qBAAqB;IACrB,KAAK,EAAE,YAAY,CAAC;IACpB,+BAA+B;IAC/B,MAAM,EAAE,OAAO,CAAC;IAChB,0DAA0D;IAC1D,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,6BAA6B;AAC7B,MAAM,MAAM,IAAI,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,IAAI,EAC1C,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,EACjB,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAC1B,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,QAG7B;AAED,uCAAuC;AACvC,wB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AAO;IAGrB,yCAAyC;IACzC,UAAU,IAAI,MAAM;IAGpB,8BAA8B;IAC9B,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC;CAG7C;AAED,qDAAqD;AACrD,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,IAAI,IAAI,KAC7C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,CAAC,KACJ,KAAK,CAAC,CAAC,CAAC,CAAC;AAEd,2DAA2D;AAC3D,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,IAAI,IAAI,KAC9C,IAAI,EAAE,CAAC,GAAG,MAAM,KACb,YAAY,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/demod/modes.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
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
|
-
/**
|
|
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 config the constructor of the Configurator class.
|
|
19
|
-
*/
|
|
20
|
-
export function registerDemod(name, demod, config) {
|
|
21
|
-
registeredDemods.set(name, { demod: demod, config: config });
|
|
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. */
|
|
28
|
-
export function getSchemes() {
|
|
29
|
-
return [...registeredDemods.keys()];
|
|
30
|
-
}
|
|
31
|
-
/** Returns the default mode for the given scheme name. */
|
|
32
|
-
export function getMode(scheme) {
|
|
33
|
-
let reg = getRegisteredDemod(scheme);
|
|
34
|
-
return new reg.config(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);
|
|
40
|
-
}
|
|
41
|
-
export function modeParameters(mode) {
|
|
42
|
-
let reg = getRegisteredDemod(mode);
|
|
43
|
-
return new reg.config(mode);
|
|
44
|
-
}
|
|
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;
|
|
59
|
-
}
|
|
60
|
-
/** Returns whether stereo output is settable in this mode. */
|
|
61
|
-
hasStereo() {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
/** Returns whether stereo output is enabled. */
|
|
65
|
-
getStereo() {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
/** Enables or disables stereo output. */
|
|
69
|
-
setStereo(stereo) {
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
/** Returns whether the bandwidth is settable in this mode. */
|
|
73
|
-
hasBandwidth() {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
/** Changes the bandwidth used by this mode. */
|
|
77
|
-
setBandwidth(bandwidth) {
|
|
78
|
-
return this;
|
|
79
|
-
}
|
|
80
|
-
/** Returns whether the squelch level is settable. */
|
|
81
|
-
hasSquelch() {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
/** Returns the current squelch level. */
|
|
85
|
-
getSquelch() {
|
|
86
|
-
return 0;
|
|
87
|
-
}
|
|
88
|
-
/** Sets the squelch level. */
|
|
89
|
-
setSquelch(squelch) {
|
|
90
|
-
return this;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
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;
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=modes.js.map
|
package/dist/demod/modes.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,MAA4B;IAE5B,gBAAgB,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,eAAe,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CAAC;IACf,CAAC;IACD,gDAAgD;IAChD,SAAS;QACP,OAAO,KAAK,CAAC;IACf,CAAC;IACD,yCAAyC;IACzC,SAAS,CAAC,MAAe;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,8DAA8D;IAC9D,YAAY;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IAMD,+CAA+C;IAC/C,YAAY,CAAC,SAAiB;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,qDAAqD;IACrD,UAAU;QACR,OAAO,KAAK,CAAC;IACf,CAAC;IACD,yCAAyC;IACzC,UAAU;QACR,OAAO,CAAC,CAAC;IACX,CAAC;IACD,8BAA8B;IAC9B,UAAU,CAAC,OAAe;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAkBD,IAAI,gBAAgB,GAAG,IAAI,GAAG,EAA2B,CAAC;AAE1D,SAAS,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/demod/player.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/** Interface for classes that get audio samples from a Demodulator class. */
|
|
2
|
-
export interface Player {
|
|
3
|
-
/** The sample rate this class expects. The demodulator will call 'play' with samples at this rate. */
|
|
4
|
-
readonly sampleRate: number;
|
|
5
|
-
/**
|
|
6
|
-
* Outputs the given audio samples.
|
|
7
|
-
* @param left The samples for the left speaker.
|
|
8
|
-
* @param right The samples for the right speaker.
|
|
9
|
-
*/
|
|
10
|
-
play(left: Float32Array, right: Float32Array): void;
|
|
11
|
-
/**
|
|
12
|
-
* Sets the output volume.
|
|
13
|
-
* @param volume The volume to set, a number from 0 (silent) to 1 (full volume).
|
|
14
|
-
*/
|
|
15
|
-
setVolume(volume: number): void;
|
|
16
|
-
/** Returns the currently set volume. */
|
|
17
|
-
getVolume(): number;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=player.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"player.d.ts","sourceRoot":"","sources":["../../src/demod/player.ts"],"names":[],"mappings":"AAcA,6EAA6E;AAC7E,MAAM,WAAW,MAAM;IACrB,sGAAsG;IACtG,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAEpD;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC,wCAAwC;IACxC,SAAS,IAAI,MAAM,CAAC;CACrB"}
|
package/dist/demod/player.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=player.js.map
|
package/dist/demod/player.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"player.js","sourceRoot":"","sources":["../../src/demod/player.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,22 +0,0 @@
|
|
|
1
|
-
import { SampleReceiver } from "../radio.js";
|
|
2
|
-
/** A SampleReceiver that counts received samples to send a `sample-click` event periodically. */
|
|
3
|
-
export declare class SampleCounter extends EventTarget implements SampleReceiver {
|
|
4
|
-
private clicksPerSecond?;
|
|
5
|
-
/**
|
|
6
|
-
* @param sampleRate The initial sample rate.
|
|
7
|
-
* @param clicksPerSecond The number of events per second.
|
|
8
|
-
*/
|
|
9
|
-
constructor(clicksPerSecond?: number | undefined);
|
|
10
|
-
private sampleRate;
|
|
11
|
-
private samplesPerClick?;
|
|
12
|
-
private countedSamples;
|
|
13
|
-
private getSamplesPerClick;
|
|
14
|
-
setSampleRate(sampleRate: number): void;
|
|
15
|
-
receiveSamples(I: Float32Array, Q: Float32Array): void;
|
|
16
|
-
addEventListener(type: "sample-click", callback: (e: SampleClickEvent) => void | null, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
17
|
-
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
18
|
-
}
|
|
19
|
-
export declare class SampleClickEvent extends Event {
|
|
20
|
-
constructor();
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=sample-counter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sample-counter.d.ts","sourceRoot":"","sources":["../../src/demod/sample-counter.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,iGAAiG;AACjG,qBAAa,aAAc,SAAQ,WAAY,YAAW,cAAc;IAK1D,OAAO,CAAC,eAAe,CAAC;IAJpC;;;OAGG;gBACiB,eAAe,CAAC,EAAE,MAAM,YAAA;IAO5C,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,eAAe,CAAC,CAAS;IACjC,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,CAAC,kBAAkB;IAM1B,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAKvC,cAAc,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,IAAI;IAWtD,gBAAgB,CACd,IAAI,EAAE,cAAc,EACpB,QAAQ,EAAE,CAAC,CAAC,EAAE,gBAAgB,KAAK,IAAI,GAAG,IAAI,EAC9C,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;AAED,qBAAa,gBAAiB,SAAQ,KAAK;;CAI1C"}
|
|
@@ -1,57 +0,0 @@
|
|
|
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
|
-
/** A SampleReceiver that counts received samples to send a `sample-click` event periodically. */
|
|
15
|
-
export class SampleCounter extends EventTarget {
|
|
16
|
-
clicksPerSecond;
|
|
17
|
-
/**
|
|
18
|
-
* @param sampleRate The initial sample rate.
|
|
19
|
-
* @param clicksPerSecond The number of events per second.
|
|
20
|
-
*/
|
|
21
|
-
constructor(clicksPerSecond) {
|
|
22
|
-
super();
|
|
23
|
-
this.clicksPerSecond = clicksPerSecond;
|
|
24
|
-
this.sampleRate = 1024000;
|
|
25
|
-
this.samplesPerClick = this.getSamplesPerClick();
|
|
26
|
-
this.countedSamples = 0;
|
|
27
|
-
}
|
|
28
|
-
sampleRate;
|
|
29
|
-
samplesPerClick;
|
|
30
|
-
countedSamples;
|
|
31
|
-
getSamplesPerClick() {
|
|
32
|
-
return this.clicksPerSecond === undefined
|
|
33
|
-
? undefined
|
|
34
|
-
: Math.floor(this.sampleRate / this.clicksPerSecond);
|
|
35
|
-
}
|
|
36
|
-
setSampleRate(sampleRate) {
|
|
37
|
-
this.sampleRate = sampleRate;
|
|
38
|
-
this.samplesPerClick = this.getSamplesPerClick();
|
|
39
|
-
}
|
|
40
|
-
receiveSamples(I, Q) {
|
|
41
|
-
this.countedSamples += I.length;
|
|
42
|
-
if (this.samplesPerClick === undefined ||
|
|
43
|
-
this.samplesPerClick > this.countedSamples)
|
|
44
|
-
return;
|
|
45
|
-
this.countedSamples %= this.samplesPerClick;
|
|
46
|
-
this.dispatchEvent(new SampleClickEvent());
|
|
47
|
-
}
|
|
48
|
-
addEventListener(type, callback, options) {
|
|
49
|
-
super.addEventListener(type, callback, options);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
export class SampleClickEvent extends Event {
|
|
53
|
-
constructor() {
|
|
54
|
-
super("sample-click");
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=sample-counter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sample-counter.js","sourceRoot":"","sources":["../../src/demod/sample-counter.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,kEAAkE;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AAgB,CACpB,IAAI,EACJ,QAAqD,EACrD,OAAO,CACR,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC;QACE,KAAK,CAAC,cAAc,CAAC,CAAC;IACxB,CAAC;CACF"}
|
package/dist/demod/spectrum.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { SampleReceiver } from "../radio.js";
|
|
2
|
-
/** A sample receiver that computes the received signal's spectrum. */
|
|
3
|
-
export declare class Spectrum implements SampleReceiver {
|
|
4
|
-
constructor(fftSize?: number);
|
|
5
|
-
private I;
|
|
6
|
-
private Q;
|
|
7
|
-
private lastFrequency;
|
|
8
|
-
private fft;
|
|
9
|
-
private lastOutput;
|
|
10
|
-
private dirty;
|
|
11
|
-
set size(newSize: number);
|
|
12
|
-
get size(): number;
|
|
13
|
-
setSampleRate(_: number): void;
|
|
14
|
-
receiveSamples(I: Float32Array, Q: Float32Array, frequency: number): void;
|
|
15
|
-
frequency(): number | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Populates the given array with the spectrum of the latest received signals.
|
|
18
|
-
* For best results, the array should have at least `size` entries; if it's smaller,
|
|
19
|
-
* it will be filled with whatever fits.
|
|
20
|
-
*/
|
|
21
|
-
getSpectrum(spectrum: Float32Array): void;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=spectrum.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spectrum.d.ts","sourceRoot":"","sources":["../../src/demod/spectrum.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,sEAAsE;AACtE,qBAAa,QAAS,YAAW,cAAc;gBACjC,OAAO,CAAC,EAAE,MAAM;IAc5B,OAAO,CAAC,CAAC,CAAoB;IAC7B,OAAO,CAAC,CAAC,CAAoB;IAC7B,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,UAAU,CAAe;IACjC,OAAO,CAAC,KAAK,CAAU;IAEvB,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM,EAKvB;IAED,IAAI,IAAI,IAPU,MAAM,CASvB;IAED,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAE9B,cAAc,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAOzE,SAAS,IAAI,MAAM,GAAG,SAAS;IAI/B;;;;OAIG;IACH,WAAW,CAAC,QAAQ,EAAE,YAAY;CAanC"}
|