@jtarrio/webrtlsdr 2.0.4 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -6
- package/dist/errors.d.ts +1 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +0 -1
- package/dist/errors.js.map +1 -1
- package/dist/radio/radio.d.ts +22 -63
- package/dist/radio/radio.d.ts.map +1 -1
- package/dist/radio/radio.js +41 -255
- package/dist/radio/radio.js.map +1 -1
- package/dist/radio/source.d.ts +25 -0
- package/dist/radio/source.d.ts.map +1 -0
- package/dist/radio/source.js +69 -0
- package/dist/radio/source.js.map +1 -0
- package/dist/radio.d.ts +2 -1
- package/dist/radio.d.ts.map +1 -1
- package/dist/radio.js +1 -1
- package/dist/radio.js.map +1 -1
- package/dist/rtlsdr/rtl2832u.d.ts.map +1 -1
- package/dist/rtlsdr/rtl2832u.js.map +1 -1
- package/dist/rtlsdr/rtlcom.d.ts.map +1 -1
- package/dist/rtlsdr/rtlcom.js.map +1 -1
- package/package.json +4 -4
- package/dist/demod/demod-am.d.ts +0 -45
- package/dist/demod/demod-am.d.ts.map +0 -1
- package/dist/demod/demod-am.js +0 -108
- package/dist/demod/demod-am.js.map +0 -1
- package/dist/demod/demod-cw.d.ts +0 -36
- package/dist/demod/demod-cw.d.ts.map +0 -1
- package/dist/demod/demod-cw.js +0 -96
- package/dist/demod/demod-cw.js.map +0 -1
- package/dist/demod/demod-nbfm.d.ts +0 -45
- package/dist/demod/demod-nbfm.d.ts.map +0 -1
- package/dist/demod/demod-nbfm.js +0 -109
- package/dist/demod/demod-nbfm.js.map +0 -1
- package/dist/demod/demod-ssb.d.ts +0 -45
- package/dist/demod/demod-ssb.d.ts.map +0 -1
- package/dist/demod/demod-ssb.js +0 -107
- package/dist/demod/demod-ssb.js.map +0 -1
- package/dist/demod/demod-wbfm.d.ts +0 -95
- package/dist/demod/demod-wbfm.d.ts.map +0 -1
- package/dist/demod/demod-wbfm.js +0 -205
- package/dist/demod/demod-wbfm.js.map +0 -1
- package/dist/demod/demodulator.d.ts +0 -3
- package/dist/demod/demodulator.d.ts.map +0 -1
- package/dist/demod/demodulator.js +0 -28
- package/dist/demod/demodulator.js.map +0 -1
- package/dist/demod/empty-demodulator.d.ts +0 -62
- package/dist/demod/empty-demodulator.d.ts.map +0 -1
- package/dist/demod/empty-demodulator.js +0 -145
- package/dist/demod/empty-demodulator.js.map +0 -1
- package/dist/demod/modes.d.ts +0 -107
- package/dist/demod/modes.d.ts.map +0 -1
- package/dist/demod/modes.js +0 -101
- package/dist/demod/modes.js.map +0 -1
- package/dist/demod/player.d.ts +0 -19
- package/dist/demod/player.d.ts.map +0 -1
- package/dist/demod/player.js +0 -15
- package/dist/demod/player.js.map +0 -1
- package/dist/demod/sample-counter.d.ts +0 -22
- package/dist/demod/sample-counter.d.ts.map +0 -1
- package/dist/demod/sample-counter.js +0 -57
- package/dist/demod/sample-counter.js.map +0 -1
- package/dist/demod/spectrum.d.ts +0 -23
- package/dist/demod/spectrum.d.ts.map +0 -1
- package/dist/demod/spectrum.js +0 -78
- package/dist/demod/spectrum.js.map +0 -1
- package/dist/dsp/buffers.d.ts +0 -72
- package/dist/dsp/buffers.d.ts.map +0 -1
- package/dist/dsp/buffers.js +0 -122
- package/dist/dsp/buffers.js.map +0 -1
- package/dist/dsp/coefficients.d.ts +0 -22
- package/dist/dsp/coefficients.d.ts.map +0 -1
- package/dist/dsp/coefficients.js +0 -77
- package/dist/dsp/coefficients.js.map +0 -1
- package/dist/dsp/converters.d.ts +0 -15
- package/dist/dsp/converters.d.ts.map +0 -1
- package/dist/dsp/converters.js +0 -43
- package/dist/dsp/converters.js.map +0 -1
- package/dist/dsp/demodulators.d.ts +0 -72
- package/dist/dsp/demodulators.d.ts.map +0 -1
- package/dist/dsp/demodulators.js +0 -244
- package/dist/dsp/demodulators.js.map +0 -1
- package/dist/dsp/fft.d.ts +0 -53
- package/dist/dsp/fft.d.ts.map +0 -1
- package/dist/dsp/fft.js +0 -175
- package/dist/dsp/fft.js.map +0 -1
- package/dist/dsp/filters.d.ts +0 -91
- package/dist/dsp/filters.d.ts.map +0 -1
- package/dist/dsp/filters.js +0 -250
- package/dist/dsp/filters.js.map +0 -1
- package/dist/dsp/power.d.ts +0 -2
- package/dist/dsp/power.d.ts.map +0 -1
- package/dist/dsp/power.js +0 -23
- package/dist/dsp/power.js.map +0 -1
- package/dist/dsp/resamplers.d.ts +0 -33
- package/dist/dsp/resamplers.d.ts.map +0 -1
- package/dist/dsp/resamplers.js +0 -91
- package/dist/dsp/resamplers.js.map +0 -1
- package/dist/players/audioplayer.d.ts +0 -25
- package/dist/players/audioplayer.d.ts.map +0 -1
- package/dist/players/audioplayer.js +0 -68
- package/dist/players/audioplayer.js.map +0 -1
- package/dist/radio/msgqueue.d.ts +0 -23
- package/dist/radio/msgqueue.d.ts.map +0 -1
- package/dist/radio/msgqueue.js +0 -52
- package/dist/radio/msgqueue.js.map +0 -1
- package/dist/radio/sample_receiver.d.ts +0 -19
- package/dist/radio/sample_receiver.d.ts.map +0 -1
- package/dist/radio/sample_receiver.js +0 -54
- package/dist/radio/sample_receiver.js.map +0 -1
package/dist/demod/spectrum.js
DELETED
|
@@ -1,78 +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
|
-
// Continuous spectrum analyzer.
|
|
15
|
-
import { Float32RingBuffer } from "../dsp/buffers.js";
|
|
16
|
-
import { makeBlackmanWindow } from "../dsp/coefficients.js";
|
|
17
|
-
import { FFT } from "../dsp/fft.js";
|
|
18
|
-
/** A sample receiver that computes the received signal's spectrum. */
|
|
19
|
-
export class Spectrum {
|
|
20
|
-
constructor(fftSize) {
|
|
21
|
-
if (fftSize === undefined) {
|
|
22
|
-
fftSize = 2048;
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
fftSize = Math.max(32, Math.min(131072, fftSize));
|
|
26
|
-
}
|
|
27
|
-
this.I = new Float32RingBuffer(131072);
|
|
28
|
-
this.Q = new Float32RingBuffer(131072);
|
|
29
|
-
this.fft = FFT.ofLength(fftSize);
|
|
30
|
-
this.fft.setWindow(makeBlackmanWindow(this.fft.length));
|
|
31
|
-
this.lastOutput = new Float32Array(this.fft.length);
|
|
32
|
-
this.dirty = true;
|
|
33
|
-
}
|
|
34
|
-
I;
|
|
35
|
-
Q;
|
|
36
|
-
lastFrequency;
|
|
37
|
-
fft;
|
|
38
|
-
lastOutput;
|
|
39
|
-
dirty;
|
|
40
|
-
set size(newSize) {
|
|
41
|
-
this.fft = FFT.ofLength(newSize);
|
|
42
|
-
this.fft.setWindow(makeBlackmanWindow(this.fft.length));
|
|
43
|
-
this.lastOutput = new Float32Array(this.fft.length);
|
|
44
|
-
this.dirty = true;
|
|
45
|
-
}
|
|
46
|
-
get size() {
|
|
47
|
-
return this.fft.length;
|
|
48
|
-
}
|
|
49
|
-
setSampleRate(_) { }
|
|
50
|
-
receiveSamples(I, Q, frequency) {
|
|
51
|
-
this.I.store(I);
|
|
52
|
-
this.Q.store(Q);
|
|
53
|
-
this.lastFrequency = frequency;
|
|
54
|
-
this.dirty = true;
|
|
55
|
-
}
|
|
56
|
-
frequency() {
|
|
57
|
-
return this.lastFrequency;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Populates the given array with the spectrum of the latest received signals.
|
|
61
|
-
* For best results, the array should have at least `size` entries; if it's smaller,
|
|
62
|
-
* it will be filled with whatever fits.
|
|
63
|
-
*/
|
|
64
|
-
getSpectrum(spectrum) {
|
|
65
|
-
if (this.dirty) {
|
|
66
|
-
let fft = this.fft.transformCircularBuffers(this.I, this.Q);
|
|
67
|
-
this.lastOutput.fill(-Infinity);
|
|
68
|
-
for (let i = 0; i < this.lastOutput.length; ++i) {
|
|
69
|
-
this.lastOutput[i] =
|
|
70
|
-
10 *
|
|
71
|
-
Math.log10(fft.real[i] * fft.real[i] + fft.imag[i] * fft.imag[i]);
|
|
72
|
-
}
|
|
73
|
-
this.dirty = false;
|
|
74
|
-
}
|
|
75
|
-
spectrum.set(this.lastOutput.subarray(0, spectrum.length));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=spectrum.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spectrum.js","sourceRoot":"","sources":["../../src/demod/spectrum.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,gCAAgC;AAEhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC,sEAAsE;AACtE,MAAM,OAAO,QAAQ;IACnB,YAAY,OAAgB;QAC1B,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,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C,CAAC,CAAC;QAChB,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,QAAsB;QAChC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;YAC5D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC;YAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;gBAChD,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;oBAChB,EAAE;wBACF,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACtE,CAAC;YACD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;QACD,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7D,CAAC;CACF"}
|
package/dist/dsp/buffers.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A source of pre-allocated arrays of a given size.
|
|
3
|
-
*/
|
|
4
|
-
declare abstract class Buffer<T extends ArrayLike<number>> {
|
|
5
|
-
private make;
|
|
6
|
-
/**
|
|
7
|
-
* @param make A function that returns an array of the given length.
|
|
8
|
-
* @param count The number of buffers to keep around. Having more than 1 lets you modify one buffer while you use another.
|
|
9
|
-
* @param length An optional initial length for the arrays.
|
|
10
|
-
*/
|
|
11
|
-
constructor(make: (length: number) => T, count: number, length?: number);
|
|
12
|
-
private buffers;
|
|
13
|
-
private current;
|
|
14
|
-
/** Returns an array of the given size. You may need to clear it manually. */
|
|
15
|
-
get(length: number): T;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* A source of pre-allocated Uint8Array buffers of a given size.
|
|
19
|
-
*/
|
|
20
|
-
export declare class U8Buffer extends Buffer<Uint8Array> {
|
|
21
|
-
/**
|
|
22
|
-
* @param count The number of buffers to keep around. Having more than 1 lets you modify one buffer while you use another.
|
|
23
|
-
* @param length An optional initial size for the buffers.
|
|
24
|
-
*/
|
|
25
|
-
constructor(count: number, length?: number);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* A source of pre-allocated Float32Array buffers of a given size.
|
|
29
|
-
*/
|
|
30
|
-
export declare class Float32Buffer extends Buffer<Float32Array> {
|
|
31
|
-
/**
|
|
32
|
-
* @param count The number of buffers to keep around. Having more than 1 lets you modify one buffer while you use another.
|
|
33
|
-
* @param length An optional initial size for the buffers.
|
|
34
|
-
*/
|
|
35
|
-
constructor(count: number, length?: number);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* A source of pre-allocated [Float32Array, Float32Array] buffers of a given size.
|
|
39
|
-
*/
|
|
40
|
-
export declare class IqBuffer {
|
|
41
|
-
/**
|
|
42
|
-
* @param count The number of buffers to keep around. Having more than 1 lets you modify one buffer while you use another.
|
|
43
|
-
* @param length An optional initial size for the buffers.
|
|
44
|
-
*/
|
|
45
|
-
constructor(count: number, length?: number);
|
|
46
|
-
private buffers;
|
|
47
|
-
/** Returns a pair of arrays of the given size. You may need to clear them manually. */
|
|
48
|
-
get(length: number): [Float32Array, Float32Array];
|
|
49
|
-
}
|
|
50
|
-
interface TypedArray<T> extends ArrayLike<number> {
|
|
51
|
-
set(array: ArrayLike<number>, offset?: number): void;
|
|
52
|
-
subarray(begin?: number, end?: number): T;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* A ring buffer, where you can store data and then copy out the latest N values.
|
|
56
|
-
*/
|
|
57
|
-
declare class RingBuffer<T extends TypedArray<T>> {
|
|
58
|
-
private buffer;
|
|
59
|
-
constructor(buffer: T);
|
|
60
|
-
private position;
|
|
61
|
-
store(data: T): void;
|
|
62
|
-
copyTo(data: T): void;
|
|
63
|
-
private doCopy;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* A Float32 ring buffer, where you can store data and then copy out the latest N values.
|
|
67
|
-
*/
|
|
68
|
-
export declare class Float32RingBuffer extends RingBuffer<Float32Array> {
|
|
69
|
-
constructor(size: number);
|
|
70
|
-
}
|
|
71
|
-
export {};
|
|
72
|
-
//# sourceMappingURL=buffers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buffers.d.ts","sourceRoot":"","sources":["../../src/dsp/buffers.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,uBAAe,MAAM,CAAC,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC;IAO7C,OAAO,CAAC,IAAI;IANd;;;;OAIG;gBAEO,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC,EACnC,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM;IAMjB,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,OAAO,CAAS;IAExB,6EAA6E;IAC7E,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC;CASvB;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,MAAM,CAAC,UAAU,CAAC;IAC9C;;;OAGG;gBACS,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAG3C;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,MAAM,CAAC,YAAY,CAAC;IACrD;;;OAGG;gBACS,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAG3C;AAED;;GAEG;AACH,qBAAa,QAAQ;IACnB;;;OAGG;gBACS,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAI1C,OAAO,CAAC,OAAO,CAAgB;IAE/B,uFAAuF;IACvF,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC;CAGlD;AAED,UAAU,UAAU,CAAC,CAAC,CAAE,SAAQ,SAAS,CAAC,MAAM,CAAC;IAC/C,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;CAC3C;AAED;;GAEG;AACH,cAAM,UAAU,CAAC,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC;IAC1B,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,CAAC;IAI7B,OAAO,CAAC,QAAQ,CAAS;IAEzB,KAAK,CAAC,IAAI,EAAE,CAAC;IAMb,MAAM,CAAC,IAAI,EAAE,CAAC;IAOd,OAAO,CAAC,MAAM;CAoBf;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,UAAU,CAAC,YAAY,CAAC;gBACjD,IAAI,EAAE,MAAM;CAGzB"}
|
package/dist/dsp/buffers.js
DELETED
|
@@ -1,122 +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
|
-
* A source of pre-allocated arrays of a given size.
|
|
16
|
-
*/
|
|
17
|
-
class Buffer {
|
|
18
|
-
make;
|
|
19
|
-
/**
|
|
20
|
-
* @param make A function that returns an array of the given length.
|
|
21
|
-
* @param count The number of buffers to keep around. Having more than 1 lets you modify one buffer while you use another.
|
|
22
|
-
* @param length An optional initial length for the arrays.
|
|
23
|
-
*/
|
|
24
|
-
constructor(make, count, length) {
|
|
25
|
-
this.make = make;
|
|
26
|
-
this.buffers = [...Array(count).keys()].map(() => make(length || 0));
|
|
27
|
-
this.current = 0;
|
|
28
|
-
}
|
|
29
|
-
buffers;
|
|
30
|
-
current;
|
|
31
|
-
/** Returns an array of the given size. You may need to clear it manually. */
|
|
32
|
-
get(length) {
|
|
33
|
-
let out = this.buffers[this.current];
|
|
34
|
-
if (out.length != length) {
|
|
35
|
-
out = this.make(length);
|
|
36
|
-
this.buffers[this.current] = out;
|
|
37
|
-
}
|
|
38
|
-
this.current = (this.current + 1) % this.buffers.length;
|
|
39
|
-
return out;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* A source of pre-allocated Uint8Array buffers of a given size.
|
|
44
|
-
*/
|
|
45
|
-
export class U8Buffer extends Buffer {
|
|
46
|
-
/**
|
|
47
|
-
* @param count The number of buffers to keep around. Having more than 1 lets you modify one buffer while you use another.
|
|
48
|
-
* @param length An optional initial size for the buffers.
|
|
49
|
-
*/
|
|
50
|
-
constructor(count, length) {
|
|
51
|
-
super((l) => new Uint8Array(l), count, length);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* A source of pre-allocated Float32Array buffers of a given size.
|
|
56
|
-
*/
|
|
57
|
-
export class Float32Buffer extends Buffer {
|
|
58
|
-
/**
|
|
59
|
-
* @param count The number of buffers to keep around. Having more than 1 lets you modify one buffer while you use another.
|
|
60
|
-
* @param length An optional initial size for the buffers.
|
|
61
|
-
*/
|
|
62
|
-
constructor(count, length) {
|
|
63
|
-
super((l) => new Float32Array(l), count, length);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* A source of pre-allocated [Float32Array, Float32Array] buffers of a given size.
|
|
68
|
-
*/
|
|
69
|
-
export class IqBuffer {
|
|
70
|
-
/**
|
|
71
|
-
* @param count The number of buffers to keep around. Having more than 1 lets you modify one buffer while you use another.
|
|
72
|
-
* @param length An optional initial size for the buffers.
|
|
73
|
-
*/
|
|
74
|
-
constructor(count, length) {
|
|
75
|
-
this.buffers = new Float32Buffer(count * 2, length);
|
|
76
|
-
}
|
|
77
|
-
buffers;
|
|
78
|
-
/** Returns a pair of arrays of the given size. You may need to clear them manually. */
|
|
79
|
-
get(length) {
|
|
80
|
-
return [this.buffers.get(length), this.buffers.get(length)];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* A ring buffer, where you can store data and then copy out the latest N values.
|
|
85
|
-
*/
|
|
86
|
-
class RingBuffer {
|
|
87
|
-
buffer;
|
|
88
|
-
constructor(buffer) {
|
|
89
|
-
this.buffer = buffer;
|
|
90
|
-
this.position = 0;
|
|
91
|
-
}
|
|
92
|
-
position;
|
|
93
|
-
store(data) {
|
|
94
|
-
let count = Math.min(data.length, data.length, this.buffer.length);
|
|
95
|
-
let { dstOffset } = this.doCopy(count, data, 0, this.buffer, this.position);
|
|
96
|
-
this.position = dstOffset;
|
|
97
|
-
}
|
|
98
|
-
copyTo(data) {
|
|
99
|
-
let count = Math.min(data.length, this.buffer.length, data.length);
|
|
100
|
-
let srcOffset = (this.position + this.buffer.length - count) % this.buffer.length;
|
|
101
|
-
this.doCopy(count, this.buffer, srcOffset, data, 0);
|
|
102
|
-
}
|
|
103
|
-
doCopy(count, src, srcOffset, dst, dstOffset) {
|
|
104
|
-
while (count > 0) {
|
|
105
|
-
const copyCount = Math.min(count, src.length - srcOffset, dst.length - dstOffset);
|
|
106
|
-
dst.set(src.subarray(srcOffset, srcOffset + copyCount), dstOffset);
|
|
107
|
-
srcOffset = (srcOffset + copyCount) % src.length;
|
|
108
|
-
dstOffset = (dstOffset + copyCount) % dst.length;
|
|
109
|
-
count -= copyCount;
|
|
110
|
-
}
|
|
111
|
-
return { srcOffset, dstOffset };
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* A Float32 ring buffer, where you can store data and then copy out the latest N values.
|
|
116
|
-
*/
|
|
117
|
-
export class Float32RingBuffer extends RingBuffer {
|
|
118
|
-
constructor(size) {
|
|
119
|
-
super(new Float32Array(size));
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
//# sourceMappingURL=buffers.js.map
|
package/dist/dsp/buffers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buffers.js","sourceRoot":"","sources":["../../src/dsp/buffers.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;;GAEG;AACH,MAAe,MAAM;IAOT;IANV;;;;OAIG;IACH,YACU,IAA2B,EACnC,KAAa,EACb,MAAe;QAFP,SAAI,GAAJ,IAAI,CAAuB;QAInC,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;QACrE,IAA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jB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CACxB,KAAK,EACL,GAAG,CAAC,MAAM,GAAG,SAAS,EACtB,GAAG,CAAC,MAAM,GAAG,SAAS,CACvB,CAAC;YACF,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC,EAAE,SAAS,CAAC,CAAC;YACnE,SAAS,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;YACjD,SAAS,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;YACjD,KAAK,IAAI,SAAS,CAAC;QACrB,CAAC;QACD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;IAClC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,UAAwB;IAC7D,YAAY,IAAY;QACtB,KAAK,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates coefficients for a FIR low-pass filter with the given
|
|
3
|
-
* corner frequency and kernel length at the given sample rate.
|
|
4
|
-
* @param sampleRate The signal's sample rate.
|
|
5
|
-
* @param cornerFreq The -3dB frequency in Hz.
|
|
6
|
-
* @param length The filter kernel's length. Should be an odd number.
|
|
7
|
-
* @returns The FIR coefficients for the filter.
|
|
8
|
-
*/
|
|
9
|
-
export declare function makeLowPassKernel(sampleRate: number, cornerFreq: number, length: number): Float32Array;
|
|
10
|
-
/**
|
|
11
|
-
* Returns coefficients for a Hilbert transform.
|
|
12
|
-
* @param length The length of the kernel.
|
|
13
|
-
* @returns The kernel coefficients.
|
|
14
|
-
*/
|
|
15
|
-
export declare function makeHilbertKernel(length: number): Float32Array;
|
|
16
|
-
/**
|
|
17
|
-
* Returns coefficients for a Blackman window.
|
|
18
|
-
* @param length The length of the kernel.
|
|
19
|
-
* @returns The kernel coefficients.
|
|
20
|
-
*/
|
|
21
|
-
export declare function makeBlackmanWindow(length: number): Float32Array;
|
|
22
|
-
//# sourceMappingURL=coefficients.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"coefficients.d.ts","sourceRoot":"","sources":["../../src/dsp/coefficients.ts"],"names":[],"mappings":"AAeA;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,YAAY,CAqBd;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAU9D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAS/D"}
|
package/dist/dsp/coefficients.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 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
|
-
/**
|
|
16
|
-
* Generates coefficients for a FIR low-pass filter with the given
|
|
17
|
-
* corner frequency and kernel length at the given sample rate.
|
|
18
|
-
* @param sampleRate The signal's sample rate.
|
|
19
|
-
* @param cornerFreq The -3dB frequency in Hz.
|
|
20
|
-
* @param length The filter kernel's length. Should be an odd number.
|
|
21
|
-
* @returns The FIR coefficients for the filter.
|
|
22
|
-
*/
|
|
23
|
-
export function makeLowPassKernel(sampleRate, cornerFreq, length) {
|
|
24
|
-
length += (length + 1) % 2;
|
|
25
|
-
const freq = cornerFreq / sampleRate;
|
|
26
|
-
let coefs = new Float32Array(length);
|
|
27
|
-
const center = Math.floor(length / 2);
|
|
28
|
-
let sum = 0;
|
|
29
|
-
for (let i = 0; i < length; ++i) {
|
|
30
|
-
let val;
|
|
31
|
-
if (i == center) {
|
|
32
|
-
val = 2 * Math.PI * freq;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
val = Math.sin(2 * Math.PI * freq * (i - center)) / (i - center);
|
|
36
|
-
val *= 0.54 - 0.46 * Math.cos((2 * Math.PI * i) / (length - 1));
|
|
37
|
-
}
|
|
38
|
-
sum += val;
|
|
39
|
-
coefs[i] = val;
|
|
40
|
-
}
|
|
41
|
-
for (let i = 0; i < length; ++i) {
|
|
42
|
-
coefs[i] /= sum;
|
|
43
|
-
}
|
|
44
|
-
return coefs;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Returns coefficients for a Hilbert transform.
|
|
48
|
-
* @param length The length of the kernel.
|
|
49
|
-
* @returns The kernel coefficients.
|
|
50
|
-
*/
|
|
51
|
-
export function makeHilbertKernel(length) {
|
|
52
|
-
length += (length + 1) % 2;
|
|
53
|
-
const center = Math.floor(length / 2);
|
|
54
|
-
let out = new Float32Array(length);
|
|
55
|
-
for (let i = 0; i < out.length; ++i) {
|
|
56
|
-
if (i % 2 == 0) {
|
|
57
|
-
out[i] = 2 / (Math.PI * (center - i));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return out;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Returns coefficients for a Blackman window.
|
|
64
|
-
* @param length The length of the kernel.
|
|
65
|
-
* @returns The kernel coefficients.
|
|
66
|
-
*/
|
|
67
|
-
export function makeBlackmanWindow(length) {
|
|
68
|
-
let window = new Float32Array(length);
|
|
69
|
-
for (let n = 0; n < length; ++n) {
|
|
70
|
-
window[n] =
|
|
71
|
-
0.42 -
|
|
72
|
-
0.5 * Math.cos((2 * Math.PI * n) / (length - 1)) +
|
|
73
|
-
0.08 * Math.cos((4 * Math.PI * n) / (length - 1));
|
|
74
|
-
}
|
|
75
|
-
return window;
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=coefficients.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"coefficients.js","sourceRoot":"","sources":["../../src/dsp/coefficients.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;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAAkB,EAClB,UAAkB,EAClB,MAAc;IAEd,MAAM,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAC3B,MAAM,IAAI,GAAG,UAAU,GAAG,UAAU,CAAC;IACrC,IAAI,KAAK,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACtC,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QAChC,IAAI,GAAG,CAAC;QACR,IAAI,CAAC,IAAI,MAAM,EAAE,CAAC;YAChB,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN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AAU,kBAAkB,CAAC,MAAc;IAC/C,IAAI,MAAM,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;IACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QAChC,MAAM,CAAC,CAAC,CAAC;YACP,IAAI;gBACJ,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBAChD,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/dsp/converters.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts the given buffer of unsigned 8-bit samples into a pair of
|
|
3
|
-
* 32-bit floating-point sample streams.
|
|
4
|
-
*/
|
|
5
|
-
export declare class U8ToFloat32 {
|
|
6
|
-
/** @param length The expected length of each sample block. */
|
|
7
|
-
constructor(length?: number);
|
|
8
|
-
private buffer;
|
|
9
|
-
/**
|
|
10
|
-
* @param input A buffer containing the unsigned 8-bit samples.
|
|
11
|
-
* @returns An array that contains first the I stream and then the Q stream.
|
|
12
|
-
*/
|
|
13
|
-
convert(input: ArrayBuffer): [Float32Array, Float32Array];
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=converters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../src/dsp/converters.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,qBAAa,WAAW;IACtB,8DAA8D;gBAClD,MAAM,CAAC,EAAE,MAAM;IAI3B,OAAO,CAAC,MAAM,CAAW;IAEzB;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC;CAY1D"}
|
package/dist/dsp/converters.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 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 { IqBuffer } from "./buffers.js";
|
|
16
|
-
/**
|
|
17
|
-
* Converts the given buffer of unsigned 8-bit samples into a pair of
|
|
18
|
-
* 32-bit floating-point sample streams.
|
|
19
|
-
*/
|
|
20
|
-
export class U8ToFloat32 {
|
|
21
|
-
/** @param length The expected length of each sample block. */
|
|
22
|
-
constructor(length) {
|
|
23
|
-
this.buffer = new IqBuffer(4, length);
|
|
24
|
-
}
|
|
25
|
-
buffer;
|
|
26
|
-
/**
|
|
27
|
-
* @param input A buffer containing the unsigned 8-bit samples.
|
|
28
|
-
* @returns An array that contains first the I stream and then the Q stream.
|
|
29
|
-
*/
|
|
30
|
-
convert(input) {
|
|
31
|
-
let u8 = new Uint8Array(input);
|
|
32
|
-
const len = u8.length / 2;
|
|
33
|
-
let out = this.buffer.get(len);
|
|
34
|
-
const outI = out[0];
|
|
35
|
-
const outQ = out[1];
|
|
36
|
-
for (let i = 0; i < len; ++i) {
|
|
37
|
-
outI[i] = u8[2 * i] / 128 - 0.995;
|
|
38
|
-
outQ[i] = u8[2 * i + 1] / 128 - 0.995;
|
|
39
|
-
}
|
|
40
|
-
return out;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=converters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"converters.js","sourceRoot":"","sources":["../../src/dsp/converters.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,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC;;;GAGG;AACH,MAAM,OAAO,WAAW;IACtB,8DAA8D;IAC9D,YAAY,MAAe;QACzB,IAAI,CAAC,MAAM,GAAG,IAAI,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IAEO,MAAM,CAAW;IAEzB;;;OAGG;IACH,OAAO,CAAC,KAAkB;QACxB,IAAI,EAAE,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;QAC/B,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;QAC1B,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACpB,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC;YAC7B,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC;YAClC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC;QACxC,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/** The sideband to demodulate. */
|
|
2
|
-
export declare enum Sideband {
|
|
3
|
-
Upper = 0,
|
|
4
|
-
Lower = 1
|
|
5
|
-
}
|
|
6
|
-
/** A class to demodulate a USB or LSB signal. */
|
|
7
|
-
export declare class SSBDemodulator {
|
|
8
|
-
/**
|
|
9
|
-
* @param sideband The sideband to demodulate.
|
|
10
|
-
*/
|
|
11
|
-
constructor(sideband: Sideband);
|
|
12
|
-
private filterDelay;
|
|
13
|
-
private filterHilbert;
|
|
14
|
-
private hilbertMul;
|
|
15
|
-
/** Demodulates the given I/Q samples into the real output. */
|
|
16
|
-
demodulate(I: Float32Array, Q: Float32Array, out: Float32Array): void;
|
|
17
|
-
}
|
|
18
|
-
/** A class to demodulate an AM signal. */
|
|
19
|
-
export declare class AMDemodulator {
|
|
20
|
-
/**
|
|
21
|
-
* @param sampleRate The signal's sample rate.
|
|
22
|
-
*/
|
|
23
|
-
constructor(sampleRate: number);
|
|
24
|
-
private alpha;
|
|
25
|
-
private carrierAmplitude;
|
|
26
|
-
/** Demodulates the given I/Q samples into the real output. */
|
|
27
|
-
demodulate(I: Float32Array, Q: Float32Array, out: Float32Array): void;
|
|
28
|
-
}
|
|
29
|
-
/** A class to demodulate an FM signal. */
|
|
30
|
-
export declare class FMDemodulator {
|
|
31
|
-
/**
|
|
32
|
-
* @param maxDeviation The maximum deviation for the signal, as a fraction of the sample rate.
|
|
33
|
-
*/
|
|
34
|
-
constructor(maxDeviation: number);
|
|
35
|
-
private mul;
|
|
36
|
-
private lI;
|
|
37
|
-
private lQ;
|
|
38
|
-
/** Changes the maximum deviation. */
|
|
39
|
-
setMaxDeviation(maxDeviation: number): void;
|
|
40
|
-
/** Demodulates the given I/Q samples into the real output. */
|
|
41
|
-
demodulate(I: Float32Array, Q: Float32Array, out: Float32Array): void;
|
|
42
|
-
}
|
|
43
|
-
/** A class to demodulate the stereo signal in a demodulated FM signal. */
|
|
44
|
-
export declare class StereoSeparator {
|
|
45
|
-
/**
|
|
46
|
-
* @param sampleRate The sample rate for the input signal.
|
|
47
|
-
* @param pilotFreq The frequency of the pilot tone.
|
|
48
|
-
*/
|
|
49
|
-
constructor(sampleRate: number, pilotFreq: number);
|
|
50
|
-
private static STD_THRES;
|
|
51
|
-
private buffer;
|
|
52
|
-
private sin;
|
|
53
|
-
private cos;
|
|
54
|
-
private iavg;
|
|
55
|
-
private qavg;
|
|
56
|
-
private cavg;
|
|
57
|
-
private sinTable;
|
|
58
|
-
private cosTable;
|
|
59
|
-
/**
|
|
60
|
-
* Locks on to the pilot tone and uses it to demodulate the stereo audio.
|
|
61
|
-
* @param samples The original audio stream.
|
|
62
|
-
* @returns An object with a key 'found' that tells whether a
|
|
63
|
-
* consistent stereo pilot tone was detected and a key 'diff'
|
|
64
|
-
* that contains the original stream demodulated with the
|
|
65
|
-
* reconstructed stereo carrier.
|
|
66
|
-
*/
|
|
67
|
-
separate(samples: Float32Array): {
|
|
68
|
-
found: boolean;
|
|
69
|
-
diff: Float32Array;
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=demodulators.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"demodulators.d.ts","sourceRoot":"","sources":["../../src/dsp/demodulators.ts"],"names":[],"mappings":"AAmBA,kCAAkC;AAClC,oBAAY,QAAQ;IAClB,KAAK,IAAA;IACL,KAAK,IAAA;CACN;AAED,iDAAiD;AACjD,qBAAa,cAAc;IACzB;;OAEG;gBACS,QAAQ,EAAE,QAAQ;IAQ9B,OAAO,CAAC,WAAW,CAAY;IAC/B,OAAO,CAAC,aAAa,CAAY;IACjC,OAAO,CAAC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