@jtarrio/webrtlsdr 0.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.
- package/LICENSE +203 -0
- package/README.md +69 -0
- package/dist/audio/player.d.ts +24 -0
- package/dist/audio/player.d.ts.map +1 -0
- package/dist/audio/player.js +68 -0
- package/dist/audio/player.js.map +1 -0
- package/dist/demod/demodulator.d.ts +59 -0
- package/dist/demod/demodulator.d.ts.map +1 -0
- package/dist/demod/demodulator.js +150 -0
- package/dist/demod/demodulator.js.map +1 -0
- package/dist/demod/sample-counter.d.ts +18 -0
- package/dist/demod/sample-counter.d.ts.map +1 -0
- package/dist/demod/sample-counter.js +43 -0
- package/dist/demod/sample-counter.js.map +1 -0
- package/dist/demod/scheme-am.d.ts +32 -0
- package/dist/demod/scheme-am.d.ts.map +1 -0
- package/dist/demod/scheme-am.js +75 -0
- package/dist/demod/scheme-am.js.map +1 -0
- package/dist/demod/scheme-cw.d.ts +22 -0
- package/dist/demod/scheme-cw.d.ts.map +1 -0
- package/dist/demod/scheme-cw.js +68 -0
- package/dist/demod/scheme-cw.js.map +1 -0
- package/dist/demod/scheme-nbfm.d.ts +32 -0
- package/dist/demod/scheme-nbfm.d.ts.map +1 -0
- package/dist/demod/scheme-nbfm.js +76 -0
- package/dist/demod/scheme-nbfm.js.map +1 -0
- package/dist/demod/scheme-ssb.d.ts +33 -0
- package/dist/demod/scheme-ssb.d.ts.map +1 -0
- package/dist/demod/scheme-ssb.js +75 -0
- package/dist/demod/scheme-ssb.js.map +1 -0
- package/dist/demod/scheme-wbfm.d.ts +38 -0
- package/dist/demod/scheme-wbfm.d.ts.map +1 -0
- package/dist/demod/scheme-wbfm.js +106 -0
- package/dist/demod/scheme-wbfm.js.map +1 -0
- package/dist/demod/scheme.d.ts +78 -0
- package/dist/demod/scheme.d.ts.map +1 -0
- package/dist/demod/scheme.js +96 -0
- package/dist/demod/scheme.js.map +1 -0
- package/dist/demod/spectrum.d.ts +18 -0
- package/dist/demod/spectrum.d.ts.map +1 -0
- package/dist/demod/spectrum.js +76 -0
- package/dist/demod/spectrum.js.map +1 -0
- package/dist/dsp/buffers.d.ts +72 -0
- package/dist/dsp/buffers.d.ts.map +1 -0
- package/dist/dsp/buffers.js +109 -0
- package/dist/dsp/buffers.js.map +1 -0
- package/dist/dsp/coefficients.d.ts +22 -0
- package/dist/dsp/coefficients.d.ts.map +1 -0
- package/dist/dsp/coefficients.js +77 -0
- package/dist/dsp/coefficients.js.map +1 -0
- package/dist/dsp/converters.d.ts +15 -0
- package/dist/dsp/converters.d.ts.map +1 -0
- package/dist/dsp/converters.js +43 -0
- package/dist/dsp/converters.js.map +1 -0
- package/dist/dsp/demodulators.d.ts +72 -0
- package/dist/dsp/demodulators.d.ts.map +1 -0
- package/dist/dsp/demodulators.js +245 -0
- package/dist/dsp/demodulators.js.map +1 -0
- package/dist/dsp/fft.d.ts +53 -0
- package/dist/dsp/fft.d.ts.map +1 -0
- package/dist/dsp/fft.js +175 -0
- package/dist/dsp/fft.js.map +1 -0
- package/dist/dsp/filters.d.ts +91 -0
- package/dist/dsp/filters.d.ts.map +1 -0
- package/dist/dsp/filters.js +250 -0
- package/dist/dsp/filters.js.map +1 -0
- package/dist/dsp/power.d.ts +2 -0
- package/dist/dsp/power.d.ts.map +1 -0
- package/dist/dsp/power.js +10 -0
- package/dist/dsp/power.js.map +1 -0
- package/dist/dsp/resamplers.d.ts +33 -0
- package/dist/dsp/resamplers.d.ts.map +1 -0
- package/dist/dsp/resamplers.js +91 -0
- package/dist/dsp/resamplers.js.map +1 -0
- package/dist/errors.d.ts +19 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +37 -0
- package/dist/errors.js.map +1 -0
- package/dist/radio/msgqueue.d.ts +23 -0
- package/dist/radio/msgqueue.d.ts.map +1 -0
- package/dist/radio/msgqueue.js +52 -0
- package/dist/radio/msgqueue.js.map +1 -0
- package/dist/radio/radio.d.ts +81 -0
- package/dist/radio/radio.d.ts.map +1 -0
- package/dist/radio/radio.js +305 -0
- package/dist/radio/radio.js.map +1 -0
- package/dist/radio/sample_receiver.d.ts +11 -0
- package/dist/radio/sample_receiver.d.ts.map +1 -0
- package/dist/radio/sample_receiver.js +49 -0
- package/dist/radio/sample_receiver.js.map +1 -0
- package/dist/rtlsdr/r820t.d.ts +18 -0
- package/dist/rtlsdr/r820t.d.ts.map +1 -0
- package/dist/rtlsdr/r820t.js +39 -0
- package/dist/rtlsdr/r820t.js.map +1 -0
- package/dist/rtlsdr/r828d.d.ts +28 -0
- package/dist/rtlsdr/r828d.d.ts.map +1 -0
- package/dist/rtlsdr/r828d.js +120 -0
- package/dist/rtlsdr/r828d.js.map +1 -0
- package/dist/rtlsdr/r8xx.d.ts +90 -0
- package/dist/rtlsdr/r8xx.d.ts.map +1 -0
- package/dist/rtlsdr/r8xx.js +468 -0
- package/dist/rtlsdr/r8xx.js.map +1 -0
- package/dist/rtlsdr/rtl2832u.d.ts +74 -0
- package/dist/rtlsdr/rtl2832u.d.ts.map +1 -0
- package/dist/rtlsdr/rtl2832u.js +342 -0
- package/dist/rtlsdr/rtl2832u.js.map +1 -0
- package/dist/rtlsdr/rtlcom.d.ts +144 -0
- package/dist/rtlsdr/rtlcom.d.ts.map +1 -0
- package/dist/rtlsdr/rtlcom.js +299 -0
- package/dist/rtlsdr/rtlcom.js.map +1 -0
- package/dist/rtlsdr/rtldevice.d.ts +53 -0
- package/dist/rtlsdr/rtldevice.d.ts.map +1 -0
- package/dist/rtlsdr/rtldevice.js +24 -0
- package/dist/rtlsdr/rtldevice.js.map +1 -0
- package/dist/rtlsdr/tuner.d.ts +20 -0
- package/dist/rtlsdr/tuner.d.ts.map +1 -0
- package/dist/rtlsdr/tuner.js +15 -0
- package/dist/rtlsdr/tuner.js.map +1 -0
- package/package.json +20 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
203
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Web RTL-SDR
|
|
2
|
+
|
|
3
|
+
Access RTL-SDR devices and receive and demodulate radio signals from your web application.
|
|
4
|
+
|
|
5
|
+
## What is this
|
|
6
|
+
|
|
7
|
+
This is a library that provides functions to access and operate an RTL-SDR device from a web application, receive radio signals, demodulate them, and play it through the computer's speakers or headphones.
|
|
8
|
+
|
|
9
|
+
It provides access at several levels, from low-level operations on the RTL-SDR stick itself, to a full reception/demodulation pipeline.
|
|
10
|
+
|
|
11
|
+
This library powers Radio Receiver, my browser-based SDR application, which you can try at [radio.ea1iti.es](https://radio.ea1iti.es).
|
|
12
|
+
|
|
13
|
+
## Compatible hardware and software
|
|
14
|
+
|
|
15
|
+
Web RTL-SDR was written to work with an RTL-2832U-based DVB-T (European digital TV) USB receiver, with a R820/828/860 tuner chip. Support for other chips may be added as required.
|
|
16
|
+
|
|
17
|
+
## How to install
|
|
18
|
+
|
|
19
|
+
```shell
|
|
20
|
+
npm install @jtarrio/webrtlsdr
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## How to use
|
|
24
|
+
|
|
25
|
+
I want to write a comprehensive set of documentation, but in the meantime, here is an introduction.
|
|
26
|
+
|
|
27
|
+
> [!NOTE]
|
|
28
|
+
> This library uses the WebUSB API to access the RTL-SDR device. This means that you need to do two things for it to work:
|
|
29
|
+
>
|
|
30
|
+
> - You must connect to the RTL-SDR device in response to a user gesture (a click or tap, generally.) You cannot, for example, connect to it automatically on opening a webpage or after a timeout.
|
|
31
|
+
> - Your web page must be served through a secure context. That means a HTTPS connection or a connection to `localhost`.
|
|
32
|
+
|
|
33
|
+
### High-level access to RTL-SDR (demodulate and play through the computer's speakers)
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { Demodulator } from "@jtarrio/webrtlsdr/demod/demodulator";
|
|
37
|
+
import { getMode } from "@jtarrio/webrtlsdr/demod/scheme";
|
|
38
|
+
import { Radio } from "@jtarrio/webrtlsdr/radio/radio";
|
|
39
|
+
import { RTL2832U_Provider } from "@jtarrio/webrtlsdr/rtlsdr/rtl2832u";
|
|
40
|
+
|
|
41
|
+
const sampleRate = 1024000;
|
|
42
|
+
let demodulator = new Demodulator(sampleRate);
|
|
43
|
+
let radio = new Radio(new RTL2832U_Provider(), spectrum, sampleRate);
|
|
44
|
+
|
|
45
|
+
radio.setFrequency(88500000);
|
|
46
|
+
demodulator.setVolume(1);
|
|
47
|
+
demodulator.setMode(getMode("WBFM"));
|
|
48
|
+
|
|
49
|
+
getElementById("playButton").addEventListener("click", () => radio.start());
|
|
50
|
+
getElementById("stopButton").addEventListener("click", () => radio.stop());
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Low-level access (read samples straight from the stick)
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
let provider = new RTL2832U_Provider();
|
|
57
|
+
let device = await provider.get();
|
|
58
|
+
await device.setSampleRate(1024000);
|
|
59
|
+
await device.setCenterFrequency(88500000);
|
|
60
|
+
await device.setGain(null);
|
|
61
|
+
await device.resetBuffer();
|
|
62
|
+
let samples = await device.readSamples(65536);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Acknowledgements
|
|
66
|
+
|
|
67
|
+
This is a spinoff of https://github.com/jtarrio/radioreceiver, which is, in turn, a fork of https://github.com/google/radioreceiver. I am the original author, but I was employed by Google at the time.
|
|
68
|
+
|
|
69
|
+
Kudos and thanks to the [RTL-SDR project](http://sdr.osmocom.org/trac/wiki/rtl-sdr) for figuring out the magic numbers needed to drive the USB tuner.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** A class to play a series of sample buffers at a constant rate. */
|
|
2
|
+
export declare class Player {
|
|
3
|
+
private static OUT_RATE;
|
|
4
|
+
private static TIME_BUFFER;
|
|
5
|
+
constructor();
|
|
6
|
+
private lastPlayedAt;
|
|
7
|
+
private ac;
|
|
8
|
+
private gainNode;
|
|
9
|
+
private gain;
|
|
10
|
+
/**
|
|
11
|
+
* Queues the given samples for playing at the appropriate time.
|
|
12
|
+
* @param leftSamples The samples for the left speaker.
|
|
13
|
+
* @param rightSamples The samples for the right speaker.
|
|
14
|
+
*/
|
|
15
|
+
play(leftSamples: Float32Array, rightSamples: Float32Array): void;
|
|
16
|
+
/**
|
|
17
|
+
* Sets the volume for playing samples.
|
|
18
|
+
* @param volume The volume to set, between 0 and 1.
|
|
19
|
+
*/
|
|
20
|
+
setVolume(volume: number): void;
|
|
21
|
+
getVolume(): number;
|
|
22
|
+
get sampleRate(): number;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=player.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"player.d.ts","sourceRoot":"","sources":["../../src/audio/player.ts"],"names":[],"mappings":"AAcA,qEAAqE;AACrE,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAChC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAQ;;IASlC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,EAAE,CAA2B;IACrC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,IAAI,CAAS;IAErB;;;;OAIG;IACH,IAAI,CACF,WAAW,EAAE,YAAY,EACzB,YAAY,EAAE,YAAY;IAqB5B;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM;IAOxB,SAAS,IAAI,MAAM;IAInB,IAAI,UAAU,IAAI,MAAM,CAGvB;CACF"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Copyright 2013 Google Inc. 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 class to play a series of sample buffers at a constant rate. */
|
|
15
|
+
export class Player {
|
|
16
|
+
static OUT_RATE = 48000;
|
|
17
|
+
static TIME_BUFFER = 0.05;
|
|
18
|
+
constructor() {
|
|
19
|
+
this.lastPlayedAt = -1;
|
|
20
|
+
this.ac = undefined;
|
|
21
|
+
this.gainNode = undefined;
|
|
22
|
+
this.gain = 0;
|
|
23
|
+
}
|
|
24
|
+
lastPlayedAt;
|
|
25
|
+
ac;
|
|
26
|
+
gainNode;
|
|
27
|
+
gain;
|
|
28
|
+
/**
|
|
29
|
+
* Queues the given samples for playing at the appropriate time.
|
|
30
|
+
* @param leftSamples The samples for the left speaker.
|
|
31
|
+
* @param rightSamples The samples for the right speaker.
|
|
32
|
+
*/
|
|
33
|
+
play(leftSamples, rightSamples) {
|
|
34
|
+
if (this.ac === undefined || this.gainNode === undefined) {
|
|
35
|
+
this.ac = new AudioContext();
|
|
36
|
+
this.gainNode = this.ac.createGain();
|
|
37
|
+
this.gainNode.gain.value = this.gain;
|
|
38
|
+
this.gainNode.connect(this.ac.destination);
|
|
39
|
+
}
|
|
40
|
+
const buffer = this.ac.createBuffer(2, leftSamples.length, Player.OUT_RATE);
|
|
41
|
+
buffer.getChannelData(0).set(leftSamples);
|
|
42
|
+
buffer.getChannelData(1).set(rightSamples);
|
|
43
|
+
let source = this.ac.createBufferSource();
|
|
44
|
+
source.buffer = buffer;
|
|
45
|
+
source.connect(this.gainNode);
|
|
46
|
+
this.lastPlayedAt = Math.max(this.lastPlayedAt + leftSamples.length / Player.OUT_RATE, this.ac.currentTime + Player.TIME_BUFFER);
|
|
47
|
+
source.start(this.lastPlayedAt);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Sets the volume for playing samples.
|
|
51
|
+
* @param volume The volume to set, between 0 and 1.
|
|
52
|
+
*/
|
|
53
|
+
setVolume(volume) {
|
|
54
|
+
this.gain = volume;
|
|
55
|
+
if (this.gainNode !== undefined) {
|
|
56
|
+
this.gainNode.gain.value = volume;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
getVolume() {
|
|
60
|
+
return this.gain;
|
|
61
|
+
}
|
|
62
|
+
get sampleRate() {
|
|
63
|
+
if (this.ac)
|
|
64
|
+
return this.ac.sampleRate;
|
|
65
|
+
return 48000;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=player.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"player.js","sourceRoot":"","sources":["../../src/audio/player.ts"],"names":[],"mappings":"AAAA,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,qEAAqE;AACrE,MAAM,OAAO,MAAM;IACT,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC;IACxB,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC;IAElC;QACE,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;IAChB,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YAAY,CAAC,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,MAAc;QACtB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;QACnB,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;QACpC,CAAC;IACH,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,IAAI,UAAU;QACZ,IAAI,IAAI,CAAC,EAAE;YAAE,OAAO,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC;QACvC,OAAO,KAAK,CAAC;IACf,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A class that takes a stream of radio samples and demodulates
|
|
3
|
+
* it into an audio signal.
|
|
4
|
+
*
|
|
5
|
+
* The demodulator parameters (scheme, bandwidth, etc) are settable
|
|
6
|
+
* on the fly.
|
|
7
|
+
*
|
|
8
|
+
* Whenever a parameter is changed, the demodulator emits a
|
|
9
|
+
* 'demodulator' event containing the new value. This makes it easy
|
|
10
|
+
* to observe the demodulator's state.
|
|
11
|
+
*/
|
|
12
|
+
import { Mode } from "./scheme";
|
|
13
|
+
import { SampleReceiver } from "../radio/sample_receiver";
|
|
14
|
+
/** The demodulator class. */
|
|
15
|
+
export declare class Demodulator extends EventTarget implements SampleReceiver {
|
|
16
|
+
private inRate;
|
|
17
|
+
constructor(inRate: number);
|
|
18
|
+
/** The audio output device. */
|
|
19
|
+
private player;
|
|
20
|
+
/** Controller that silences the output if the SNR is low. */
|
|
21
|
+
private squelchControl;
|
|
22
|
+
/** The modulation parameters as a Mode object. */
|
|
23
|
+
private mode;
|
|
24
|
+
/** The demodulator class. */
|
|
25
|
+
private scheme;
|
|
26
|
+
/** The frequency offset to demodulate from. */
|
|
27
|
+
private frequencyOffset;
|
|
28
|
+
/** Whether the latest samples were in stereo. */
|
|
29
|
+
private latestStereo;
|
|
30
|
+
/** A frequency change we are expecting. */
|
|
31
|
+
private expectingFrequency?;
|
|
32
|
+
/** Changes the modulation parameters. */
|
|
33
|
+
setMode(mode: Mode): void;
|
|
34
|
+
/** Returns the current modulation parameters. */
|
|
35
|
+
getMode(): Mode;
|
|
36
|
+
/** Changes the frequency offset. */
|
|
37
|
+
setFrequencyOffset(offset: number): void;
|
|
38
|
+
/** Returns the current frequency offset. */
|
|
39
|
+
getFrequencyOffset(): number;
|
|
40
|
+
/** Waits until samples arrive with the given center frequency and then sets the offset. */
|
|
41
|
+
expectFrequencyAndSetOffset(center: number, offset: number): void;
|
|
42
|
+
/** Sets the audio volume level, from 0 to 1. */
|
|
43
|
+
setVolume(volume: number): void;
|
|
44
|
+
/** Returns the current audio volume level. */
|
|
45
|
+
getVolume(): number;
|
|
46
|
+
/** Returns an appropriate instance of ModulationScheme for the requested mode. */
|
|
47
|
+
private getScheme;
|
|
48
|
+
/** Changes the sample rate. */
|
|
49
|
+
setSampleRate(sampleRate: number): void;
|
|
50
|
+
/** Receives radio samples. */
|
|
51
|
+
receiveSamples(I: Float32Array, Q: Float32Array, frequency: number): void;
|
|
52
|
+
andThen(next: SampleReceiver): SampleReceiver;
|
|
53
|
+
addEventListener(type: "stereo-status", callback: (e: StereoStatusEvent) => void | null, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
54
|
+
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
55
|
+
}
|
|
56
|
+
export declare class StereoStatusEvent extends CustomEvent<boolean> {
|
|
57
|
+
constructor(stereo: boolean);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=demodulator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demodulator.d.ts","sourceRoot":"","sources":["../../src/demod/demodulator.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;GAUG;AAEH,OAAO,EAAoB,IAAI,EAA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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"}
|
|
@@ -0,0 +1,150 @@
|
|
|
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 { SchemeAM } from "./scheme-am";
|
|
15
|
+
import { SchemeCW } from "./scheme-cw";
|
|
16
|
+
import { SchemeNBFM } from "./scheme-nbfm";
|
|
17
|
+
import { SchemeSSB } from "./scheme-ssb";
|
|
18
|
+
import { SchemeWBFM } from "./scheme-wbfm";
|
|
19
|
+
import { Player } from "../audio/player";
|
|
20
|
+
import { concatenateReceivers } from "../radio/sample_receiver";
|
|
21
|
+
/** The demodulator class. */
|
|
22
|
+
export class Demodulator extends EventTarget {
|
|
23
|
+
inRate;
|
|
24
|
+
constructor(inRate) {
|
|
25
|
+
super();
|
|
26
|
+
this.inRate = inRate;
|
|
27
|
+
this.player = new Player();
|
|
28
|
+
this.squelchControl = new SquelchControl(this.player.sampleRate);
|
|
29
|
+
this.mode = { scheme: "WBFM", stereo: true };
|
|
30
|
+
this.scheme = this.getScheme(this.mode);
|
|
31
|
+
this.frequencyOffset = 0;
|
|
32
|
+
this.latestStereo = false;
|
|
33
|
+
}
|
|
34
|
+
/** The audio output device. */
|
|
35
|
+
player;
|
|
36
|
+
/** Controller that silences the output if the SNR is low. */
|
|
37
|
+
squelchControl;
|
|
38
|
+
/** The modulation parameters as a Mode object. */
|
|
39
|
+
mode;
|
|
40
|
+
/** The demodulator class. */
|
|
41
|
+
scheme;
|
|
42
|
+
/** The frequency offset to demodulate from. */
|
|
43
|
+
frequencyOffset;
|
|
44
|
+
/** Whether the latest samples were in stereo. */
|
|
45
|
+
latestStereo;
|
|
46
|
+
/** A frequency change we are expecting. */
|
|
47
|
+
expectingFrequency;
|
|
48
|
+
/** Changes the modulation parameters. */
|
|
49
|
+
setMode(mode) {
|
|
50
|
+
this.scheme = this.getScheme(mode, this.scheme);
|
|
51
|
+
this.mode = mode;
|
|
52
|
+
}
|
|
53
|
+
/** Returns the current modulation parameters. */
|
|
54
|
+
getMode() {
|
|
55
|
+
return this.mode;
|
|
56
|
+
}
|
|
57
|
+
/** Changes the frequency offset. */
|
|
58
|
+
setFrequencyOffset(offset) {
|
|
59
|
+
this.frequencyOffset = offset;
|
|
60
|
+
}
|
|
61
|
+
/** Returns the current frequency offset. */
|
|
62
|
+
getFrequencyOffset() {
|
|
63
|
+
return this.frequencyOffset;
|
|
64
|
+
}
|
|
65
|
+
/** Waits until samples arrive with the given center frequency and then sets the offset. */
|
|
66
|
+
expectFrequencyAndSetOffset(center, offset) {
|
|
67
|
+
this.expectingFrequency = { center, offset };
|
|
68
|
+
}
|
|
69
|
+
/** Sets the audio volume level, from 0 to 1. */
|
|
70
|
+
setVolume(volume) {
|
|
71
|
+
this.player.setVolume(volume);
|
|
72
|
+
}
|
|
73
|
+
/** Returns the current audio volume level. */
|
|
74
|
+
getVolume() {
|
|
75
|
+
return this.player.getVolume();
|
|
76
|
+
}
|
|
77
|
+
/** Returns an appropriate instance of ModulationScheme for the requested mode. */
|
|
78
|
+
getScheme(mode, scheme) {
|
|
79
|
+
if (mode.scheme == scheme?.getMode().scheme) {
|
|
80
|
+
scheme.setMode(mode);
|
|
81
|
+
return scheme;
|
|
82
|
+
}
|
|
83
|
+
switch (mode.scheme) {
|
|
84
|
+
case "AM":
|
|
85
|
+
return new SchemeAM(this.inRate, this.player.sampleRate, mode);
|
|
86
|
+
case "NBFM":
|
|
87
|
+
return new SchemeNBFM(this.inRate, this.player.sampleRate, mode);
|
|
88
|
+
case "WBFM":
|
|
89
|
+
return new SchemeWBFM(this.inRate, this.player.sampleRate, mode);
|
|
90
|
+
case "LSB":
|
|
91
|
+
case "USB":
|
|
92
|
+
return new SchemeSSB(this.inRate, this.player.sampleRate, mode);
|
|
93
|
+
case "CW":
|
|
94
|
+
return new SchemeCW(this.inRate, this.player.sampleRate, mode);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** Changes the sample rate. */
|
|
98
|
+
setSampleRate(sampleRate) {
|
|
99
|
+
this.inRate = sampleRate;
|
|
100
|
+
this.scheme = this.getScheme(this.mode, undefined);
|
|
101
|
+
}
|
|
102
|
+
/** Receives radio samples. */
|
|
103
|
+
receiveSamples(I, Q, frequency) {
|
|
104
|
+
if (this.expectingFrequency?.center === frequency) {
|
|
105
|
+
this.frequencyOffset = this.expectingFrequency.offset;
|
|
106
|
+
this.expectingFrequency = undefined;
|
|
107
|
+
}
|
|
108
|
+
let { left, right, stereo, snr } = this.scheme.demodulate(I, Q, this.frequencyOffset);
|
|
109
|
+
this.squelchControl.applySquelch(this.mode, left, right, snr);
|
|
110
|
+
this.player.play(left, right);
|
|
111
|
+
if (stereo != this.latestStereo) {
|
|
112
|
+
this.dispatchEvent(new StereoStatusEvent(stereo));
|
|
113
|
+
this.latestStereo = stereo;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
andThen(next) {
|
|
117
|
+
return concatenateReceivers(this, next);
|
|
118
|
+
}
|
|
119
|
+
addEventListener(type, callback, options) {
|
|
120
|
+
super.addEventListener(type, callback, options);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export class StereoStatusEvent extends CustomEvent {
|
|
124
|
+
constructor(stereo) {
|
|
125
|
+
super("stereo-status", { detail: stereo, bubbles: true, composed: true });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
class SquelchControl {
|
|
129
|
+
sampleRate;
|
|
130
|
+
constructor(sampleRate) {
|
|
131
|
+
this.sampleRate = sampleRate;
|
|
132
|
+
}
|
|
133
|
+
countdown = 0;
|
|
134
|
+
applySquelch(mode, left, right, snr) {
|
|
135
|
+
const SQUELCH_TAIL = 0.1;
|
|
136
|
+
if (mode.scheme == "WBFM" || mode.scheme == "CW")
|
|
137
|
+
return;
|
|
138
|
+
if (mode.squelch < snr) {
|
|
139
|
+
this.countdown = SQUELCH_TAIL * this.sampleRate;
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (this.countdown > 0) {
|
|
143
|
+
this.countdown -= left.length;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
left.fill(0);
|
|
147
|
+
right.fill(0);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=demodulator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,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
|
+
constructor();
|
|
4
|
+
}
|
|
5
|
+
export declare class SampleCounter extends EventTarget implements SampleReceiver {
|
|
6
|
+
private sampleRate;
|
|
7
|
+
private clicksPerSecond?;
|
|
8
|
+
constructor(sampleRate: number, clicksPerSecond?: number | undefined);
|
|
9
|
+
private samplesPerClick?;
|
|
10
|
+
private countedSamples;
|
|
11
|
+
private getSamplesPerClick;
|
|
12
|
+
setSampleRate(sampleRate: number): void;
|
|
13
|
+
receiveSamples(I: Float32Array, Q: Float32Array): void;
|
|
14
|
+
andThen(next: SampleReceiver): SampleReceiver;
|
|
15
|
+
addEventListener(type: "sample-click", callback: (e: SampleClickEvent) => void | null, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
16
|
+
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=sample-counter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sample-counter.d.ts","sourceRoot":"","sources":["../../src/demod/sample-counter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEhF,qBAAa,gBAAiB,SAAQ,KAAK;;CAI1C;AAED,qBAAa,aAAc,SAAQ,WAAY,YAAW,cAAc;IAEpE,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,eAAe,CAAC;gBADhB,UAAU,EAAE,MAAM,EAClB,eAAe,CAAC,EAAE,MAAM,YAAA;IAOlC,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,OAAO,CAAC,IAAI,EAAE,cAAc,GAAG,cAAc;IAI7C,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"}
|