@jtarrio/webrtlsdr 2.0.5 → 3.0.1

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.
Files changed (110) hide show
  1. package/README.md +5 -6
  2. package/dist/errors.d.ts +1 -2
  3. package/dist/errors.d.ts.map +1 -1
  4. package/dist/errors.js +0 -1
  5. package/dist/errors.js.map +1 -1
  6. package/dist/radio/radio.d.ts +22 -63
  7. package/dist/radio/radio.d.ts.map +1 -1
  8. package/dist/radio/radio.js +41 -255
  9. package/dist/radio/radio.js.map +1 -1
  10. package/dist/radio/source.d.ts +25 -0
  11. package/dist/radio/source.d.ts.map +1 -0
  12. package/dist/radio/source.js +69 -0
  13. package/dist/radio/source.js.map +1 -0
  14. package/dist/radio.d.ts +2 -1
  15. package/dist/radio.d.ts.map +1 -1
  16. package/dist/radio.js +1 -1
  17. package/dist/radio.js.map +1 -1
  18. package/dist/rtlsdr/rtl2832u.d.ts.map +1 -1
  19. package/dist/rtlsdr/rtl2832u.js.map +1 -1
  20. package/dist/rtlsdr/rtlcom.d.ts.map +1 -1
  21. package/dist/rtlsdr/rtlcom.js.map +1 -1
  22. package/package.json +4 -4
  23. package/dist/demod/demod-am.d.ts +0 -54
  24. package/dist/demod/demod-am.d.ts.map +0 -1
  25. package/dist/demod/demod-am.js +0 -113
  26. package/dist/demod/demod-am.js.map +0 -1
  27. package/dist/demod/demod-cw.d.ts +0 -48
  28. package/dist/demod/demod-cw.d.ts.map +0 -1
  29. package/dist/demod/demod-cw.js +0 -101
  30. package/dist/demod/demod-cw.js.map +0 -1
  31. package/dist/demod/demod-nbfm.d.ts +0 -54
  32. package/dist/demod/demod-nbfm.d.ts.map +0 -1
  33. package/dist/demod/demod-nbfm.js +0 -114
  34. package/dist/demod/demod-nbfm.js.map +0 -1
  35. package/dist/demod/demod-ssb.d.ts +0 -55
  36. package/dist/demod/demod-ssb.d.ts.map +0 -1
  37. package/dist/demod/demod-ssb.js +0 -112
  38. package/dist/demod/demod-ssb.js.map +0 -1
  39. package/dist/demod/demod-wbfm.d.ts +0 -113
  40. package/dist/demod/demod-wbfm.d.ts.map +0 -1
  41. package/dist/demod/demod-wbfm.js +0 -212
  42. package/dist/demod/demod-wbfm.js.map +0 -1
  43. package/dist/demod/demodulator.d.ts +0 -3
  44. package/dist/demod/demodulator.d.ts.map +0 -1
  45. package/dist/demod/demodulator.js +0 -28
  46. package/dist/demod/demodulator.js.map +0 -1
  47. package/dist/demod/empty-demodulator.d.ts +0 -82
  48. package/dist/demod/empty-demodulator.d.ts.map +0 -1
  49. package/dist/demod/empty-demodulator.js +0 -149
  50. package/dist/demod/empty-demodulator.js.map +0 -1
  51. package/dist/demod/modes.d.ts +0 -107
  52. package/dist/demod/modes.d.ts.map +0 -1
  53. package/dist/demod/modes.js +0 -101
  54. package/dist/demod/modes.js.map +0 -1
  55. package/dist/demod/player.d.ts +0 -19
  56. package/dist/demod/player.d.ts.map +0 -1
  57. package/dist/demod/player.js +0 -15
  58. package/dist/demod/player.js.map +0 -1
  59. package/dist/demod/sample-counter.d.ts +0 -22
  60. package/dist/demod/sample-counter.d.ts.map +0 -1
  61. package/dist/demod/sample-counter.js +0 -57
  62. package/dist/demod/sample-counter.js.map +0 -1
  63. package/dist/demod/spectrum.d.ts +0 -23
  64. package/dist/demod/spectrum.d.ts.map +0 -1
  65. package/dist/demod/spectrum.js +0 -78
  66. package/dist/demod/spectrum.js.map +0 -1
  67. package/dist/dsp/buffers.d.ts +0 -72
  68. package/dist/dsp/buffers.d.ts.map +0 -1
  69. package/dist/dsp/buffers.js +0 -122
  70. package/dist/dsp/buffers.js.map +0 -1
  71. package/dist/dsp/coefficients.d.ts +0 -22
  72. package/dist/dsp/coefficients.d.ts.map +0 -1
  73. package/dist/dsp/coefficients.js +0 -77
  74. package/dist/dsp/coefficients.js.map +0 -1
  75. package/dist/dsp/converters.d.ts +0 -15
  76. package/dist/dsp/converters.d.ts.map +0 -1
  77. package/dist/dsp/converters.js +0 -43
  78. package/dist/dsp/converters.js.map +0 -1
  79. package/dist/dsp/demodulators.d.ts +0 -73
  80. package/dist/dsp/demodulators.d.ts.map +0 -1
  81. package/dist/dsp/demodulators.js +0 -244
  82. package/dist/dsp/demodulators.js.map +0 -1
  83. package/dist/dsp/fft.d.ts +0 -53
  84. package/dist/dsp/fft.d.ts.map +0 -1
  85. package/dist/dsp/fft.js +0 -175
  86. package/dist/dsp/fft.js.map +0 -1
  87. package/dist/dsp/filters.d.ts +0 -91
  88. package/dist/dsp/filters.d.ts.map +0 -1
  89. package/dist/dsp/filters.js +0 -250
  90. package/dist/dsp/filters.js.map +0 -1
  91. package/dist/dsp/power.d.ts +0 -2
  92. package/dist/dsp/power.d.ts.map +0 -1
  93. package/dist/dsp/power.js +0 -23
  94. package/dist/dsp/power.js.map +0 -1
  95. package/dist/dsp/resamplers.d.ts +0 -33
  96. package/dist/dsp/resamplers.d.ts.map +0 -1
  97. package/dist/dsp/resamplers.js +0 -91
  98. package/dist/dsp/resamplers.js.map +0 -1
  99. package/dist/players/audioplayer.d.ts +0 -25
  100. package/dist/players/audioplayer.d.ts.map +0 -1
  101. package/dist/players/audioplayer.js +0 -68
  102. package/dist/players/audioplayer.js.map +0 -1
  103. package/dist/radio/msgqueue.d.ts +0 -23
  104. package/dist/radio/msgqueue.d.ts.map +0 -1
  105. package/dist/radio/msgqueue.js +0 -52
  106. package/dist/radio/msgqueue.js.map +0 -1
  107. package/dist/radio/sample_receiver.d.ts +0 -19
  108. package/dist/radio/sample_receiver.d.ts.map +0 -1
  109. package/dist/radio/sample_receiver.js +0 -54
  110. package/dist/radio/sample_receiver.js.map +0 -1
@@ -1,212 +0,0 @@
1
- // Copyright 2026 Jacobo Tarrio Barreiro. All rights reserved.
2
- // Copyright 2013 Google Inc. All rights reserved.
3
- //
4
- // Licensed under the Apache License, Version 2.0 (the "License");
5
- // you may not use this file except in compliance with the License.
6
- // You may obtain a copy of the License at
7
- //
8
- // http://www.apache.org/licenses/LICENSE-2.0
9
- //
10
- // Unless required by applicable law or agreed to in writing, software
11
- // distributed under the License is distributed on an "AS IS" BASIS,
12
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- // See the License for the specific language governing permissions and
14
- // limitations under the License.
15
- import { makeLowPassKernel } from "../dsp/coefficients.js";
16
- import { FMDemodulator, StereoSeparator } from "../dsp/demodulators.js";
17
- import { FrequencyShifter, Deemphasizer, FIRFilter } from "../dsp/filters.js";
18
- import { getPower } from "../dsp/power.js";
19
- import { ComplexDownsampler, RealDownsampler } from "../dsp/resamplers.js";
20
- import { Configurator } from "./modes.js";
21
- /** A demodulator for wideband FM signals. */
22
- export class DemodWBFM {
23
- mode;
24
- /**
25
- * @param inRate The sample rate of the input samples.
26
- * @param outRate The sample rate of the output samples.
27
- * @param mode The mode to use initially.
28
- * @param options Options for the demodulator.
29
- */
30
- constructor(inRate, outRate, mode, options) {
31
- this.mode = mode;
32
- let interRate = Math.min(inRate, 336000);
33
- this.stage1 = new DemodWBFMStage1(inRate, interRate, mode, options);
34
- this.stage2 = new DemodWBFMStage2(interRate, outRate, mode, options);
35
- }
36
- stage1;
37
- stage2;
38
- getMode() {
39
- return this.mode;
40
- }
41
- setMode(mode) {
42
- this.mode = mode;
43
- this.stage1.setMode(mode);
44
- this.stage2.setMode(mode);
45
- }
46
- /**
47
- * Demodulates the signal.
48
- * @param samplesI The I components of the samples.
49
- * @param samplesQ The Q components of the samples.
50
- * @param freqOffset The offset of the signal in the samples.
51
- * @returns The demodulated audio signal.
52
- */
53
- demodulate(samplesI, samplesQ, freqOffset) {
54
- let o1 = this.stage1.demodulate(samplesI, samplesQ, freqOffset);
55
- let o2 = this.stage2.demodulate(o1.left);
56
- o2.snr = o1.snr;
57
- return o2;
58
- }
59
- }
60
- /**
61
- * First stage demodulator for wideband FM signals.
62
- * Returns the raw demodulated FM signal, with stereo pilot, difference signal and RDS, if they exist.
63
- * The output is duplicated in the left and right channels.
64
- */
65
- export class DemodWBFMStage1 {
66
- outRate;
67
- mode;
68
- /**
69
- * @param inRate The sample rate of the input samples.
70
- * @param outRate The sample rate of the output audio.
71
- * @param mode The mode to use initially.
72
- * @param options Options for the demodulator.
73
- */
74
- constructor(inRate, outRate, mode, options) {
75
- this.outRate = outRate;
76
- this.mode = mode;
77
- const maxF = 75000;
78
- const downsamplerTaps = options?.downsamplerTaps || 151;
79
- const rfTaps = options?.rfTaps || 151;
80
- this.shifter = new FrequencyShifter(inRate);
81
- if (inRate != outRate) {
82
- this.downsampler = new ComplexDownsampler(inRate, outRate, downsamplerTaps);
83
- }
84
- const kernel = makeLowPassKernel(outRate, maxF, rfTaps);
85
- this.filterI = new FIRFilter(kernel);
86
- this.filterQ = new FIRFilter(kernel);
87
- this.demodulator = new FMDemodulator(maxF / outRate);
88
- }
89
- shifter;
90
- downsampler;
91
- filterI;
92
- filterQ;
93
- demodulator;
94
- getMode() {
95
- return this.mode;
96
- }
97
- setMode(mode) {
98
- this.mode = mode;
99
- }
100
- /**
101
- * Demodulates the signal.
102
- * @param samplesI The I components of the samples.
103
- * @param samplesQ The Q components of the samples.
104
- * @param freqOffset The offset of the signal in the samples.
105
- * @returns The demodulated audio signal.
106
- */
107
- demodulate(samplesI, samplesQ, freqOffset) {
108
- this.shifter.inPlace(samplesI, samplesQ, -freqOffset);
109
- let [I, Q] = this.downsampler
110
- ? this.downsampler.downsample(samplesI, samplesQ)
111
- : [samplesI, samplesQ];
112
- let allPower = getPower(I, Q);
113
- this.filterI.inPlace(I);
114
- this.filterQ.inPlace(Q);
115
- let signalPower = (getPower(I, Q) * this.outRate) / 150000;
116
- this.demodulator.demodulate(I, Q, I);
117
- return {
118
- left: I,
119
- right: new Float32Array(I),
120
- stereo: false,
121
- snr: signalPower / allPower,
122
- };
123
- }
124
- }
125
- /**
126
- * Second stage demodulator for wideband FM signals.
127
- * Takes the output of stage 1 and does stereo extraction.
128
- * Only the I channel is used; Q channel is ignored.
129
- * */
130
- export class DemodWBFMStage2 {
131
- mode;
132
- /**
133
- * @param inRate The sample rate of the input samples.
134
- * @param outRate The sample rate of the output audio.
135
- * @param mode The mode to use initially.
136
- * @param options Options for the demodulator.
137
- */
138
- constructor(inRate, outRate, mode, options) {
139
- this.mode = mode;
140
- const pilotF = 19000;
141
- const deemphTc = options?.deemphasizerTc === undefined ? 50 : options.deemphasizerTc;
142
- const audioTaps = options?.audioTaps || 41;
143
- this.monoSampler = new RealDownsampler(inRate, outRate, audioTaps);
144
- this.stereoSampler = new RealDownsampler(inRate, outRate, audioTaps);
145
- this.stereoSeparator = new StereoSeparator(inRate, pilotF);
146
- this.leftDeemph = new Deemphasizer(outRate, deemphTc);
147
- this.rightDeemph = new Deemphasizer(outRate, deemphTc);
148
- }
149
- monoSampler;
150
- stereoSampler;
151
- stereoSeparator;
152
- leftDeemph;
153
- rightDeemph;
154
- getMode() {
155
- return this.mode;
156
- }
157
- setMode(mode) {
158
- this.mode = mode;
159
- }
160
- /**
161
- * Demodulates the signal.
162
- * @param samplesI The I components of the samples.
163
- * @returns The demodulated audio signal.
164
- */
165
- demodulate(samplesI) {
166
- const leftAudio = this.monoSampler.downsample(samplesI);
167
- const rightAudio = new Float32Array(leftAudio);
168
- let stereoOut = false;
169
- if (this.mode.stereo) {
170
- const stereo = this.stereoSeparator.separate(samplesI);
171
- if (stereo.found) {
172
- stereoOut = true;
173
- const diffAudio = this.stereoSampler.downsample(stereo.diff);
174
- for (let i = 0; i < diffAudio.length; ++i) {
175
- rightAudio[i] -= diffAudio[i];
176
- leftAudio[i] += diffAudio[i];
177
- }
178
- }
179
- }
180
- this.leftDeemph.inPlace(leftAudio);
181
- this.rightDeemph.inPlace(rightAudio);
182
- return {
183
- left: leftAudio,
184
- right: rightAudio,
185
- stereo: stereoOut,
186
- snr: 1,
187
- };
188
- }
189
- }
190
- /** Configurator for the WBFM mode. */
191
- export class ConfigWBFM extends Configurator {
192
- constructor(mode) {
193
- super(mode);
194
- }
195
- create() {
196
- return { scheme: "WBFM", stereo: true };
197
- }
198
- hasStereo() {
199
- return true;
200
- }
201
- getStereo() {
202
- return this.mode.stereo;
203
- }
204
- setStereo(stereo) {
205
- this.mode = { ...this.mode, stereo: stereo };
206
- return this;
207
- }
208
- getBandwidth() {
209
- return 150000;
210
- }
211
- }
212
- //# sourceMappingURL=demod-wbfm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"demod-wbfm.js","sourceRoot":"","sources":["../../src/demod/demod-wbfm.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,kDAAkD;AAClD,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,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAsB,MAAM,YAAY,CAAC;AAqB9D,6CAA6C;AAC7C,MAAM,OAAO,SAAS;IAUV;IATV;;;;;OAKG;IACH,YACE,MAAc,EACd,OAAe,EACP,IAAc,EACtB,OAAqB;QADb,SAAI,GAAJ,IAAI,CAAU;QAGtB,IAAI,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QACpE,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,CAAC,SAAS,EAAE,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O,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC1C,CAAC;IACD,SAAS;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,SAAS;QACP,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IAC1B,CAAC;IACD,SAAS,CAAC,MAAe;QACvB,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,YAAY;QACV,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -1,3 +0,0 @@
1
- /** Exports the `Demodulator` class with all the demodulation schemes already registered. */
2
- export * from "./empty-demodulator.js";
3
- //# sourceMappingURL=demodulator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"demodulator.d.ts","sourceRoot":"","sources":["../../src/demod/demodulator.ts"],"names":[],"mappings":"AAcA,4FAA4F;AAE5F,cAAc,wBAAwB,CAAC"}
@@ -1,28 +0,0 @@
1
- // Copyright 2025 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
- /** Exports the `Demodulator` class with all the demodulation schemes already registered. */
15
- export * from "./empty-demodulator.js";
16
- import { registerDemod } from "./modes.js";
17
- import { ConfigAM, DemodAM } from "./demod-am.js";
18
- import { ConfigCW, DemodCW } from "./demod-cw.js";
19
- import { ConfigNBFM, DemodNBFM } from "./demod-nbfm.js";
20
- import { ConfigSSB, DemodSSB } from "./demod-ssb.js";
21
- import { ConfigWBFM, DemodWBFM } from "./demod-wbfm.js";
22
- registerDemod("WBFM", DemodWBFM, ConfigWBFM);
23
- registerDemod("NBFM", DemodNBFM, ConfigNBFM);
24
- registerDemod("AM", DemodAM, ConfigAM);
25
- registerDemod("USB", DemodSSB, ConfigSSB);
26
- registerDemod("LSB", DemodSSB, ConfigSSB);
27
- registerDemod("CW", DemodCW, ConfigCW);
28
- //# sourceMappingURL=demodulator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"demodulator.js","sourceRoot":"","sources":["../../src/demod/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,4FAA4F;AAE5F,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExD,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAC7C,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAC7C,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AACvC,aAAa,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC1C,aAAa,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC1C,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC"}
@@ -1,82 +0,0 @@
1
- import { Mode } from "./modes.js";
2
- import { Player } from "./player.js";
3
- import { SampleReceiver } from "../radio.js";
4
- type DemodulatorOptions = {
5
- /**
6
- * The player to use. If undefined, an AudioPlayer will be used.
7
- */
8
- player?: Player;
9
- /**
10
- * Options for each mode. This is an object whose keys are registered mode names
11
- * and the values are objects sent to the mode constructor.
12
- */
13
- modeOptions?: {
14
- [key: Mode["scheme"]]: object;
15
- };
16
- };
17
- /**
18
- * A class that takes a stream of radio samples and demodulates
19
- * it into an audio signal.
20
- *
21
- * The demodulator parameters (scheme, bandwidth, etc) are settable
22
- * on the fly.
23
- *
24
- * Whenever a parameter is changed, the demodulator emits a
25
- * 'demodulator' event containing the new value. This makes it easy
26
- * to observe the demodulator's state.
27
- */
28
- export declare class Demodulator extends EventTarget implements SampleReceiver {
29
- /**
30
- * @param options Options for the demodulator.
31
- */
32
- constructor(options?: DemodulatorOptions);
33
- /**
34
- * @param player The player to use. If undefined, an AudioPlayer will be used.
35
- */
36
- constructor(player?: Player);
37
- /** The sample rate. */
38
- private inRate;
39
- /** The audio output device. */
40
- private player;
41
- /** Controller that silences the output if the SNR is low. */
42
- private squelchControl;
43
- /** Options for the different modes. */
44
- private modeOptions;
45
- /** The modulation parameters as a Mode object. */
46
- private mode;
47
- /** The demodulator class. */
48
- private demod;
49
- /** The frequency offset to demodulate from. */
50
- private frequencyOffset;
51
- /** Whether the latest samples were in stereo. */
52
- private latestStereo;
53
- /** A frequency change we are expecting. */
54
- private expectingFrequency?;
55
- /** Changes the modulation parameters. */
56
- setMode(mode: Mode): void;
57
- /** Returns the current modulation parameters. */
58
- getMode(): Mode;
59
- /** Changes the frequency offset. */
60
- setFrequencyOffset(offset: number): void;
61
- /** Returns the current frequency offset. */
62
- getFrequencyOffset(): number;
63
- /** Waits until samples arrive with the given center frequency and then sets the offset. */
64
- expectFrequencyAndSetOffset(center: number, offset: number): void;
65
- /** Sets the audio volume level, from 0 to 1. */
66
- setVolume(volume: number): void;
67
- /** Returns the current audio volume level. */
68
- getVolume(): number;
69
- /** Returns an appropriate instance of Scheme for the requested mode. */
70
- private getScheme;
71
- /** Changes the sample rate. */
72
- setSampleRate(sampleRate: number): void;
73
- /** Receives radio samples. */
74
- receiveSamples(I: Float32Array, Q: Float32Array, frequency: number): void;
75
- addEventListener(type: "stereo-status", callback: (e: StereoStatusEvent) => void | null, options?: boolean | AddEventListenerOptions | undefined): void;
76
- addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void;
77
- }
78
- export declare class StereoStatusEvent extends CustomEvent<boolean> {
79
- constructor(stereo: boolean);
80
- }
81
- export {};
82
- //# 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,KAAK,kBAAkB,GAAG;IACxB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAA;KAAE,CAAC;CACjD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,qBAAa,WAAY,SAAQ,WAAY,YAAW,cAAc;IACpE;;OAEG;gBACS,OAAO,CAAC,EAAE,kBAAkB;IACxC;;OAEG;gBACS,MAAM,CAAC,EAAE,MAAM;IAkB3B,uBAAuB;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,+BAA+B;IAC/B,OAAO,CAAC,MA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,iBAAkB,SAAQ,WAAW,CAAC,OAAO,CAAC;gBAC7C,MAAM,EAAE,OAAO;CAG5B"}
@@ -1,149 +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
- constructor(playerOrOptions) {
29
- super();
30
- const player = playerOrOptions !== undefined && Object.hasOwn(playerOrOptions, "play")
31
- ? playerOrOptions
32
- : playerOrOptions?.player;
33
- const modeOptions = playerOrOptions?.modeOptions;
34
- this.inRate = 1024000;
35
- this.player = player || new AudioPlayer();
36
- this.squelchControl = new SquelchControl(this.player.sampleRate);
37
- this.modeOptions = modeOptions || {};
38
- this.mode = getMode("WBFM");
39
- this.demod = this.getScheme(this.mode);
40
- this.frequencyOffset = 0;
41
- this.latestStereo = false;
42
- }
43
- /** The sample rate. */
44
- inRate;
45
- /** The audio output device. */
46
- player;
47
- /** Controller that silences the output if the SNR is low. */
48
- squelchControl;
49
- /** Options for the different modes. */
50
- modeOptions;
51
- /** The modulation parameters as a Mode object. */
52
- mode;
53
- /** The demodulator class. */
54
- demod;
55
- /** The frequency offset to demodulate from. */
56
- frequencyOffset;
57
- /** Whether the latest samples were in stereo. */
58
- latestStereo;
59
- /** A frequency change we are expecting. */
60
- expectingFrequency;
61
- /** Changes the modulation parameters. */
62
- setMode(mode) {
63
- this.demod = this.getScheme(mode, this.demod);
64
- this.mode = mode;
65
- }
66
- /** Returns the current modulation parameters. */
67
- getMode() {
68
- return this.mode;
69
- }
70
- /** Changes the frequency offset. */
71
- setFrequencyOffset(offset) {
72
- this.frequencyOffset = offset;
73
- }
74
- /** Returns the current frequency offset. */
75
- getFrequencyOffset() {
76
- return this.frequencyOffset;
77
- }
78
- /** Waits until samples arrive with the given center frequency and then sets the offset. */
79
- expectFrequencyAndSetOffset(center, offset) {
80
- this.expectingFrequency = { center, offset };
81
- }
82
- /** Sets the audio volume level, from 0 to 1. */
83
- setVolume(volume) {
84
- this.player.setVolume(volume);
85
- }
86
- /** Returns the current audio volume level. */
87
- getVolume() {
88
- return this.player.getVolume();
89
- }
90
- /** Returns an appropriate instance of Scheme for the requested mode. */
91
- getScheme(mode, demod) {
92
- if (mode.scheme == demod?.getMode().scheme) {
93
- demod.setMode(mode);
94
- return demod;
95
- }
96
- return getDemod(this.inRate, this.player.sampleRate, mode, this.modeOptions[mode.scheme]);
97
- }
98
- /** Changes the sample rate. */
99
- setSampleRate(sampleRate) {
100
- this.inRate = sampleRate;
101
- this.demod = this.getScheme(this.mode, undefined);
102
- }
103
- /** Receives radio samples. */
104
- receiveSamples(I, Q, frequency) {
105
- if (this.expectingFrequency?.center === frequency) {
106
- this.frequencyOffset = this.expectingFrequency.offset;
107
- this.expectingFrequency = undefined;
108
- }
109
- let { left, right, stereo, snr } = this.demod.demodulate(I, Q, this.frequencyOffset);
110
- this.squelchControl.applySquelch(this.mode, left, right, snr);
111
- this.player.play(left, right);
112
- if (stereo != this.latestStereo) {
113
- this.dispatchEvent(new StereoStatusEvent(stereo));
114
- this.latestStereo = stereo;
115
- }
116
- }
117
- addEventListener(type, callback, options) {
118
- super.addEventListener(type, callback, options);
119
- }
120
- }
121
- export class StereoStatusEvent extends CustomEvent {
122
- constructor(stereo) {
123
- super("stereo-status", { detail: stereo, bubbles: true, composed: true });
124
- }
125
- }
126
- class SquelchControl {
127
- sampleRate;
128
- constructor(sampleRate) {
129
- this.sampleRate = sampleRate;
130
- }
131
- countdown = 0;
132
- applySquelch(mode, left, right, snr) {
133
- const SQUELCH_TAIL = 0.1;
134
- let params = modeParameters(mode);
135
- if (!params.hasSquelch())
136
- return;
137
- if (params.getSquelch() < snr) {
138
- this.countdown = SQUELCH_TAIL * this.sampleRate;
139
- return;
140
- }
141
- if (this.countdown > 0) {
142
- this.countdown -= left.length;
143
- return;
144
- }
145
- left.fill(0);
146
- right.fill(0);
147
- }
148
- }
149
- //# 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;AAEjC,OAAO,EAAe,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAexD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,WAAY,SAAQ,WAAW;IAS1C,YAAY,eAA6C;QACvD,KAAK,EAAE,CAAC;QACR,MAAM,MAAM,GACV,eAAe,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC;YACrE,CAAC,CAAE,eAA0B;YAC7B,CAAC,CAAE,eAAsC,EAAE,MAAM,CAAC;QACtD,MAAM,WAAW,GAAI,eAAsC,EAAE,WAAW,CAAC;QACzE,IAAI,CAAC,MAAM,GAA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,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"}
@@ -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, options?: object): 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, options?: object) => 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,QAA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