@jtarrio/signals 0.9.6 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/demod/demod-wbfm.d.ts.map +1 -1
- package/dist/demod/demod-wbfm.js +9 -6
- package/dist/demod/demod-wbfm.js.map +1 -1
- package/dist/dsp/resamplers.d.ts +56 -23
- package/dist/dsp/resamplers.d.ts.map +1 -1
- package/dist/dsp/resamplers.js +224 -40
- package/dist/dsp/resamplers.js.map +1 -1
- package/dist/players/audioplayer.d.ts +9 -1
- package/dist/players/audioplayer.d.ts.map +1 -1
- package/dist/players/audioplayer.js +31 -7
- package/dist/players/audioplayer.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"demod-wbfm.d.ts","sourceRoot":"","sources":["../../src/demod/demod-wbfm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"demod-wbfm.d.ts","sourceRoot":"","sources":["../../src/demod/demod-wbfm.ts"],"names":[],"mappings":"AAmCA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,gCAAgC;AAChC,MAAM,MAAM,QAAQ,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;AAE3D,6BAA6B;AAC7B,MAAM,MAAM,WAAW,GAAG;IACxB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wFAAwF;IACxF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wFAAwF;IACxF,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,6CAA6C;AAC7C,qBAAa,SAAU,YAAW,KAAK,CAAC,QAAQ,CAAC;IAU7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kB;IACzC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,OAAO,CAAc;IAE7B,OAAO,IAAI,QAAQ;IAInB,OAAO,CAAC,IAAI,EAAE,QAAQ;IAItB;;;;OAIG;IACH,UAAU,CAAC,QAAQ,EAAE,YAAY,GAAG,WAAW;CAkChD;AAED,sCAAsC;AACtC,qBAAa,UAAW,SAAQ,YAAY,CAAC,QAAQ,CAAC;gBACxC,IAAI,EAAE,QAAQ,GAAG,MAAM;IAGnC,SAAS,CAAC,MAAM,IAAI,QAAQ;IAG5B,SAAS,IAAI,OAAO;IAGpB,SAAS,IAAI,OAAO;IAGpB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,UAAU;IAItC,YAAY,IAAI,MAAM;CAGvB"}
|
package/dist/demod/demod-wbfm.js
CHANGED
|
@@ -17,7 +17,7 @@ import { makeLowPassKernel } from "../dsp/coefficients.js";
|
|
|
17
17
|
import { FMDemodulator, StereoSeparator } from "../dsp/demodulators.js";
|
|
18
18
|
import { Deemphasis, FrequencyShifter, IqFFTFilter, IqFIRFilter, } from "../dsp/filters.js";
|
|
19
19
|
import { getPower } from "../dsp/power.js";
|
|
20
|
-
import { ComplexDownsampler,
|
|
20
|
+
import { ComplexDownsampler, getRealResampler, } from "../dsp/resamplers.js";
|
|
21
21
|
import { Configurator } from "./modes.js";
|
|
22
22
|
/** A demodulator for wideband FM signals. */
|
|
23
23
|
export class DemodWBFM {
|
|
@@ -142,9 +142,12 @@ export class DemodWBFMStage2 {
|
|
|
142
142
|
1e6;
|
|
143
143
|
const audioTaps = options?.audioTaps || 41;
|
|
144
144
|
const filterF = Math.min(15000, outRate / 2);
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
this.monoSampler = getRealResampler(inRate, outRate, {
|
|
146
|
+
lowPassFrequency: filterF,
|
|
147
|
+
taps: audioTaps,
|
|
148
|
+
gain: 1 / 0.9,
|
|
149
|
+
});
|
|
150
|
+
this.stereoSampler = this.monoSampler.clone();
|
|
148
151
|
this.stereoSeparator = new StereoSeparator(inRate, pilotF);
|
|
149
152
|
this.leftDeemph = new Deemphasis(outRate, deemphTc);
|
|
150
153
|
this.rightDeemph = new Deemphasis(outRate, deemphTc);
|
|
@@ -168,11 +171,11 @@ export class DemodWBFMStage2 {
|
|
|
168
171
|
* @returns The demodulated audio signal.
|
|
169
172
|
*/
|
|
170
173
|
demodulate(samplesI) {
|
|
171
|
-
let audio = this.monoSampler.
|
|
174
|
+
let audio = this.monoSampler.resample(samplesI);
|
|
172
175
|
if (this.mode.stereo) {
|
|
173
176
|
const stereo = this.stereoSeparator.separate(samplesI);
|
|
174
177
|
if (stereo.found) {
|
|
175
|
-
const diffAudio = this.stereoSampler.
|
|
178
|
+
const diffAudio = this.stereoSampler.resample(stereo.diff);
|
|
176
179
|
let leftAudio = this.outPool.get(audio.length);
|
|
177
180
|
let rightAudio = audio;
|
|
178
181
|
for (let i = 0; i < diffAudio.length; ++i) {
|
|
@@ -1 +1 @@
|
|
|
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,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EACL,UAAU,EAIV,gBAAgB,EAChB,WAAW,EAEX,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,iB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CAAC;iBACP,CAAC;YACJ,CAAC;QACH,CAAC;QAED,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC3C,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACjB,OAAO;YACL,IAAI,EAAE,KAAK;YACX,KAAK;YACL,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,CAAC;SACP,CAAC;IACJ,CAAC;CACF;AAED,sCAAsC;AACtC,MAAM,OAAO,UAAW,SAAQ,YAAsB;IACpD,YAAY,IAAuB;QACjC,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IACS,MAAM;QACd,OAAO,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"}
|
package/dist/dsp/resamplers.d.ts
CHANGED
|
@@ -1,41 +1,74 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export
|
|
1
|
+
/** Interface for classes that convert real signals between sample rates. */
|
|
2
|
+
export interface RealResampler {
|
|
3
|
+
resample(samples: Float32Array): Float32Array;
|
|
4
|
+
getDelay(): number;
|
|
5
|
+
clone(): RealResampler;
|
|
6
|
+
}
|
|
7
|
+
/** Interface for classes that convert I/Q signals between sample rates. */
|
|
8
|
+
export interface IqResampler {
|
|
9
|
+
resample(I: Float32Array, Q: Float32Array): [Float32Array, Float32Array];
|
|
10
|
+
getDelay(): number;
|
|
11
|
+
clone(): IqResampler;
|
|
12
|
+
}
|
|
13
|
+
/** Options for getRealResampler() and getIqResampler() */
|
|
14
|
+
export type ResamplerOptions = {
|
|
3
15
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
16
|
+
* The low-pass cut-off frequency for the filter.
|
|
17
|
+
* If unspecified, the lower of half the input or output sample rate is used.
|
|
18
|
+
*/
|
|
19
|
+
lowPassFrequency?: number;
|
|
20
|
+
/**
|
|
21
|
+
* The number of taps for the filter.
|
|
22
|
+
* If unspecified, 101 taps are used.
|
|
7
23
|
*/
|
|
8
|
-
|
|
24
|
+
taps?: number;
|
|
25
|
+
/**
|
|
26
|
+
* A gain for the filter.
|
|
27
|
+
* If unspecified, 1 is used.
|
|
28
|
+
*/
|
|
29
|
+
gain?: number;
|
|
30
|
+
/**
|
|
31
|
+
* A FIR kernel to use for the filter.
|
|
32
|
+
* If unspecified, a suitable kernel for the low pass frequency and number of pass is used.
|
|
33
|
+
*/
|
|
34
|
+
kernel?: Float32Array;
|
|
35
|
+
};
|
|
36
|
+
/** Returns a RealResampler that converts signals from the input rate to the output rate. */
|
|
37
|
+
export declare function getRealResampler(inRate: number, outRate: number, options?: ResamplerOptions): RealResampler;
|
|
38
|
+
/** Returns an IqResampler that converts signals from the input rate to the output rate. */
|
|
39
|
+
export declare function getIqResampler(inRate: number, outRate: number, options?: ResamplerOptions): IqResampler;
|
|
40
|
+
/**
|
|
41
|
+
* A class to convert the input to a lower sample rate.
|
|
42
|
+
* @deprecated Use getRealResampler() instead.
|
|
43
|
+
*/
|
|
44
|
+
export declare class RealDownsampler {
|
|
9
45
|
/**
|
|
10
46
|
* @param inRate The input sample rate.
|
|
11
47
|
* @param outRate The output sample rate.
|
|
12
|
-
* @param
|
|
48
|
+
* @param filterSpec The size or kernel of the low-pass filter to apply to the signal before downsampling.
|
|
13
49
|
*/
|
|
14
|
-
constructor(inRate: number, outRate: number,
|
|
15
|
-
private
|
|
50
|
+
constructor(inRate: number, outRate: number, filterSpec: number | Float32Array);
|
|
51
|
+
private resampler;
|
|
16
52
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @
|
|
53
|
+
* Returns a downsampled version of the given samples.
|
|
54
|
+
* @param samples The sample block to downsample.
|
|
55
|
+
* @returns The downsampled block.
|
|
19
56
|
*/
|
|
20
|
-
downsample(
|
|
57
|
+
downsample(samples: Float32Array): Float32Array;
|
|
21
58
|
getDelay(): number;
|
|
22
59
|
}
|
|
23
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* A class to convert a complex input to a lower sample rate.
|
|
62
|
+
* @deprecated Use getIqResampler() instead.
|
|
63
|
+
*/
|
|
24
64
|
export declare class ComplexDownsampler {
|
|
25
65
|
/**
|
|
26
66
|
* @param inRate The input sample rate.
|
|
27
67
|
* @param outRate The output sample rate.
|
|
28
|
-
* @param
|
|
29
|
-
*/
|
|
30
|
-
constructor(inRate: number, outRate: number, filterLen: number);
|
|
31
|
-
/**
|
|
32
|
-
* @param inRate The input sample rate.
|
|
33
|
-
* @param outRate The output sample rate.
|
|
34
|
-
* @param kernel The kernel to apply to the signal before downsampling.
|
|
68
|
+
* @param filterSpec The size or kernel of the low-pass filter to apply to the signal before downsampling.
|
|
35
69
|
*/
|
|
36
|
-
constructor(inRate: number, outRate: number,
|
|
37
|
-
private
|
|
38
|
-
private downsamplerQ;
|
|
70
|
+
constructor(inRate: number, outRate: number, filterSpec: number | Float32Array);
|
|
71
|
+
private resampler;
|
|
39
72
|
/**
|
|
40
73
|
* @param I The signal's real component.
|
|
41
74
|
* @param Q The signal's imaginary component.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resamplers.d.ts","sourceRoot":"","sources":["../../src/dsp/resamplers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resamplers.d.ts","sourceRoot":"","sources":["../../src/dsp/resamplers.ts"],"names":[],"mappings":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AE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GAAG,YAAY;IASnC,OAAO,CAAC,SAAS,CAAc;IAE/B;;;;OAIG;IACH,UAAU,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC;IAI1E,QAAQ,IAAI,MAAM;CAGnB"}
|
package/dist/dsp/resamplers.js
CHANGED
|
@@ -12,87 +12,271 @@
|
|
|
12
12
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
|
+
import { RadioError, RadioErrorType } from "../errors.js";
|
|
15
16
|
import { Float32Pool } from "./buffers.js";
|
|
16
17
|
import { makeLowPassKernel } from "./coefficients.js";
|
|
17
18
|
import { FIRFilter } from "./filters.js";
|
|
18
|
-
|
|
19
|
-
class Downsampler {
|
|
19
|
+
class PureRealDownsampler {
|
|
20
20
|
ratio;
|
|
21
|
-
|
|
22
|
-
* @param ratio The ratio of input/output sample rates.
|
|
23
|
-
* @param kernel The coefficients for the low-pass filter.
|
|
24
|
-
*/
|
|
25
|
-
constructor(ratio, filter) {
|
|
21
|
+
constructor(ratio, kernel) {
|
|
26
22
|
this.ratio = ratio;
|
|
27
|
-
|
|
23
|
+
if (ratio != Math.floor(ratio))
|
|
24
|
+
throw new RadioError(`Non-integer downsample ratio: ${ratio}`, RadioErrorType.DemodulationError);
|
|
25
|
+
this.filter = new FIRFilter(kernel);
|
|
28
26
|
this.pool = new Float32Pool(2);
|
|
27
|
+
this.residual = 0;
|
|
29
28
|
}
|
|
30
29
|
filter;
|
|
31
30
|
pool;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* @param samples The sample block to downsample.
|
|
35
|
-
* @returns The downsampled block.
|
|
36
|
-
*/
|
|
37
|
-
downsample(samples) {
|
|
31
|
+
residual;
|
|
32
|
+
resample(samples) {
|
|
38
33
|
const ratio = this.ratio;
|
|
39
|
-
const
|
|
40
|
-
|
|
34
|
+
const skip = (ratio - this.residual) % ratio;
|
|
35
|
+
const outLen = Math.floor((this.residual + samples.length - 1) / ratio) -
|
|
36
|
+
Math.floor((this.residual - 1) / ratio);
|
|
37
|
+
let output = this.pool.get(outLen);
|
|
41
38
|
this.filter.loadSamples(samples);
|
|
42
|
-
for (let i = 0; i <
|
|
43
|
-
output[i] = this.filter.get(
|
|
39
|
+
for (let i = 0; i < outLen; ++i) {
|
|
40
|
+
output[i] = this.filter.get(skip + i * ratio);
|
|
44
41
|
}
|
|
42
|
+
this.residual = (this.residual + samples.length) % ratio;
|
|
45
43
|
return output;
|
|
46
44
|
}
|
|
47
45
|
getDelay() {
|
|
48
46
|
return this.filter.getDelay() / this.ratio;
|
|
49
47
|
}
|
|
50
48
|
clone() {
|
|
51
|
-
|
|
49
|
+
let out = new PureRealDownsampler(this.ratio, new Float32Array(1));
|
|
50
|
+
out.filter = this.filter.clone();
|
|
51
|
+
return out;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
class PureRealUpsampler {
|
|
55
|
+
ratio;
|
|
56
|
+
constructor(ratio, kernel) {
|
|
57
|
+
this.ratio = ratio;
|
|
58
|
+
if (ratio != Math.floor(ratio))
|
|
59
|
+
throw new RadioError(`Non-integer upsample ratio: ${ratio}`, RadioErrorType.DemodulationError);
|
|
60
|
+
this.delay = new FIRFilter(kernel).getDelay();
|
|
61
|
+
if (kernel.length % ratio != 0) {
|
|
62
|
+
const wantedLen = ratio * Math.ceil(kernel.length / ratio);
|
|
63
|
+
const newKernel = new Float32Array(wantedLen);
|
|
64
|
+
newKernel.subarray(wantedLen - kernel.length, wantedLen).set(kernel);
|
|
65
|
+
kernel = newKernel;
|
|
66
|
+
}
|
|
67
|
+
this.filters = [];
|
|
68
|
+
for (let i = 0; i < ratio; ++i) {
|
|
69
|
+
const filterKernel = new Float32Array(kernel.length / ratio);
|
|
70
|
+
for (let j = 0; j < filterKernel.length; ++j) {
|
|
71
|
+
filterKernel[j] = kernel[(j + 1) * ratio - i - 1] * ratio;
|
|
72
|
+
}
|
|
73
|
+
this.filters[i] = new FIRFilter(filterKernel);
|
|
74
|
+
}
|
|
75
|
+
this.pool = new Float32Pool(2);
|
|
76
|
+
}
|
|
77
|
+
delay;
|
|
78
|
+
filters;
|
|
79
|
+
pool;
|
|
80
|
+
resample(samples) {
|
|
81
|
+
const ratio = this.ratio;
|
|
82
|
+
const outLen = samples.length * ratio;
|
|
83
|
+
let output = this.pool.get(outLen);
|
|
84
|
+
for (let j = 0; j < ratio; ++j) {
|
|
85
|
+
this.filters[j].loadSamples(samples);
|
|
86
|
+
}
|
|
87
|
+
for (let i = 0; i < samples.length; ++i) {
|
|
88
|
+
for (let j = 0; j < ratio; ++j) {
|
|
89
|
+
output[i * ratio + j] = this.filters[j].get(i);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return output;
|
|
93
|
+
}
|
|
94
|
+
getDelay() {
|
|
95
|
+
return this.delay;
|
|
96
|
+
}
|
|
97
|
+
clone() {
|
|
98
|
+
let out = new PureRealUpsampler(1, new Float32Array(1));
|
|
99
|
+
out.ratio = this.ratio;
|
|
100
|
+
out.filters = this.filters.map((f) => f.clone());
|
|
101
|
+
out.delay = this.delay;
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
60
104
|
}
|
|
61
|
-
|
|
105
|
+
class RealUpDownsampler {
|
|
106
|
+
upRatio;
|
|
107
|
+
downRatio;
|
|
108
|
+
constructor(upRatio, downRatio, kernel) {
|
|
109
|
+
this.upRatio = upRatio;
|
|
110
|
+
this.downRatio = downRatio;
|
|
111
|
+
if (upRatio != Math.floor(upRatio))
|
|
112
|
+
throw new RadioError(`Non-integer upsample ratio: ${upRatio}`, RadioErrorType.DemodulationError);
|
|
113
|
+
if (downRatio != Math.floor(downRatio))
|
|
114
|
+
throw new RadioError(`Non-integer downsample ratio: ${downRatio}`, RadioErrorType.DemodulationError);
|
|
115
|
+
this.delay = new FIRFilter(kernel).getDelay();
|
|
116
|
+
if (kernel.length % upRatio != 0) {
|
|
117
|
+
const wantedLen = upRatio * Math.ceil(kernel.length / upRatio);
|
|
118
|
+
const newKernel = new Float32Array(wantedLen);
|
|
119
|
+
newKernel.subarray(wantedLen - kernel.length, wantedLen).set(kernel);
|
|
120
|
+
kernel = newKernel;
|
|
121
|
+
}
|
|
122
|
+
this.filters = [];
|
|
123
|
+
for (let i = 0; i < upRatio; ++i) {
|
|
124
|
+
const filterKernel = new Float32Array(kernel.length / upRatio);
|
|
125
|
+
for (let j = 0; j < filterKernel.length; ++j) {
|
|
126
|
+
filterKernel[j] = kernel[(j + 1) * upRatio - i - 1] * upRatio;
|
|
127
|
+
}
|
|
128
|
+
this.filters[i] = new FIRFilter(filterKernel);
|
|
129
|
+
}
|
|
130
|
+
this.pool = new Float32Pool(4);
|
|
131
|
+
this.residual = 0;
|
|
132
|
+
}
|
|
133
|
+
delay;
|
|
134
|
+
filters;
|
|
135
|
+
pool;
|
|
136
|
+
residual;
|
|
137
|
+
resample(samples) {
|
|
138
|
+
const upRatio = this.upRatio;
|
|
139
|
+
const midLen = samples.length * upRatio;
|
|
140
|
+
for (let j = 0; j < upRatio; ++j) {
|
|
141
|
+
this.filters[j].loadSamples(samples);
|
|
142
|
+
}
|
|
143
|
+
const downRatio = this.downRatio;
|
|
144
|
+
const skip = (downRatio - this.residual) % downRatio;
|
|
145
|
+
const outLen = Math.floor((this.residual + midLen - 1) / downRatio) -
|
|
146
|
+
Math.floor((this.residual - 1) / downRatio);
|
|
147
|
+
let output = this.pool.get(outLen);
|
|
148
|
+
for (let k = 0; k < outLen; ++k) {
|
|
149
|
+
const ij = skip + k * downRatio;
|
|
150
|
+
const i = Math.floor(ij / upRatio);
|
|
151
|
+
const j = ij % upRatio;
|
|
152
|
+
output[k] = this.filters[j].get(i);
|
|
153
|
+
}
|
|
154
|
+
this.residual = (this.residual + midLen) % downRatio;
|
|
155
|
+
return output;
|
|
156
|
+
}
|
|
157
|
+
getDelay() {
|
|
158
|
+
return this.delay / this.downRatio;
|
|
159
|
+
}
|
|
160
|
+
clone() {
|
|
161
|
+
let out = new RealUpDownsampler(this.upRatio, this.downRatio, new Float32Array(1));
|
|
162
|
+
out.delay = this.delay;
|
|
163
|
+
out.filters = this.filters.map((f) => f.clone());
|
|
164
|
+
return out;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
class GenericIqResampler {
|
|
168
|
+
constructor(realResampler) {
|
|
169
|
+
this.resampleI = realResampler.clone();
|
|
170
|
+
this.resampleQ = realResampler.clone();
|
|
171
|
+
}
|
|
172
|
+
resampleI;
|
|
173
|
+
resampleQ;
|
|
174
|
+
resample(I, Q) {
|
|
175
|
+
return [this.resampleI.resample(I), this.resampleQ.resample(Q)];
|
|
176
|
+
}
|
|
177
|
+
getDelay() {
|
|
178
|
+
return this.resampleI.getDelay();
|
|
179
|
+
}
|
|
180
|
+
clone() {
|
|
181
|
+
return new GenericIqResampler(this.resampleI);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/** Returns a RealResampler that converts signals from the input rate to the output rate. */
|
|
185
|
+
export function getRealResampler(inRate, outRate, options) {
|
|
186
|
+
if (inRate > outRate && inRate % outRate == 0) {
|
|
187
|
+
// Pure downsampler
|
|
188
|
+
let corner = options?.lowPassFrequency || outRate / 2;
|
|
189
|
+
let taps = options?.taps || 101;
|
|
190
|
+
let gain = options?.gain;
|
|
191
|
+
let kernel = options?.kernel || makeLowPassKernel(inRate, corner, taps, gain);
|
|
192
|
+
return new PureRealDownsampler(inRate / outRate, kernel);
|
|
193
|
+
}
|
|
194
|
+
if (inRate < outRate && outRate % inRate == 0) {
|
|
195
|
+
// Pure upsampler
|
|
196
|
+
let corner = options?.lowPassFrequency || inRate / 2;
|
|
197
|
+
let taps = options?.taps || 101;
|
|
198
|
+
let gain = options?.gain;
|
|
199
|
+
let kernel = options?.kernel || makeLowPassKernel(outRate, corner, taps, gain);
|
|
200
|
+
return new PureRealUpsampler(outRate / inRate, kernel);
|
|
201
|
+
}
|
|
202
|
+
// Resampler
|
|
203
|
+
let gcd = greatestCommonDivisor(inRate, outRate);
|
|
204
|
+
let corner = options?.lowPassFrequency || Math.min(inRate, outRate) / 2;
|
|
205
|
+
let taps = options?.taps || 101;
|
|
206
|
+
let gain = options?.gain;
|
|
207
|
+
let kernel = options?.kernel ||
|
|
208
|
+
makeLowPassKernel((inRate * outRate) / gcd, corner, taps, gain);
|
|
209
|
+
return new RealUpDownsampler(outRate / gcd, inRate / gcd, kernel);
|
|
210
|
+
}
|
|
211
|
+
/** Returns an IqResampler that converts signals from the input rate to the output rate. */
|
|
212
|
+
export function getIqResampler(inRate, outRate, options) {
|
|
213
|
+
return new GenericIqResampler(getRealResampler(inRate, outRate, options));
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* A class to convert the input to a lower sample rate.
|
|
217
|
+
* @deprecated Use getRealResampler() instead.
|
|
218
|
+
*/
|
|
62
219
|
export class RealDownsampler {
|
|
220
|
+
/**
|
|
221
|
+
* @param inRate The input sample rate.
|
|
222
|
+
* @param outRate The output sample rate.
|
|
223
|
+
* @param filterSpec The size or kernel of the low-pass filter to apply to the signal before downsampling.
|
|
224
|
+
*/
|
|
63
225
|
constructor(inRate, outRate, filterSpec) {
|
|
64
|
-
|
|
226
|
+
let options = typeof filterSpec === "number"
|
|
227
|
+
? { taps: filterSpec }
|
|
228
|
+
: { kernel: filterSpec };
|
|
229
|
+
this.resampler = getRealResampler(inRate, outRate, options);
|
|
65
230
|
}
|
|
66
|
-
|
|
231
|
+
resampler;
|
|
67
232
|
/**
|
|
68
|
-
*
|
|
69
|
-
* @
|
|
233
|
+
* Returns a downsampled version of the given samples.
|
|
234
|
+
* @param samples The sample block to downsample.
|
|
235
|
+
* @returns The downsampled block.
|
|
70
236
|
*/
|
|
71
|
-
downsample(
|
|
72
|
-
return this.
|
|
237
|
+
downsample(samples) {
|
|
238
|
+
return this.resampler.resample(samples);
|
|
73
239
|
}
|
|
74
240
|
getDelay() {
|
|
75
|
-
return this.
|
|
241
|
+
return this.resampler.getDelay();
|
|
76
242
|
}
|
|
77
243
|
}
|
|
78
|
-
/**
|
|
244
|
+
/**
|
|
245
|
+
* A class to convert a complex input to a lower sample rate.
|
|
246
|
+
* @deprecated Use getIqResampler() instead.
|
|
247
|
+
*/
|
|
79
248
|
export class ComplexDownsampler {
|
|
249
|
+
/**
|
|
250
|
+
* @param inRate The input sample rate.
|
|
251
|
+
* @param outRate The output sample rate.
|
|
252
|
+
* @param filterSpec The size or kernel of the low-pass filter to apply to the signal before downsampling.
|
|
253
|
+
*/
|
|
80
254
|
constructor(inRate, outRate, filterSpec) {
|
|
81
|
-
|
|
82
|
-
|
|
255
|
+
let options = typeof filterSpec === "number"
|
|
256
|
+
? { taps: filterSpec }
|
|
257
|
+
: { kernel: filterSpec };
|
|
258
|
+
this.resampler = getIqResampler(inRate, outRate, options);
|
|
83
259
|
}
|
|
84
|
-
|
|
85
|
-
downsamplerQ;
|
|
260
|
+
resampler;
|
|
86
261
|
/**
|
|
87
262
|
* @param I The signal's real component.
|
|
88
263
|
* @param Q The signal's imaginary component.
|
|
89
264
|
* @returns An array with the output's real and imaginary components.
|
|
90
265
|
*/
|
|
91
266
|
downsample(I, Q) {
|
|
92
|
-
return
|
|
267
|
+
return this.resampler.resample(I, Q);
|
|
93
268
|
}
|
|
94
269
|
getDelay() {
|
|
95
|
-
return this.
|
|
270
|
+
return this.resampler.getDelay();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function greatestCommonDivisor(a, b) {
|
|
274
|
+
if (a < b) {
|
|
275
|
+
[a, b] = [b, a];
|
|
276
|
+
}
|
|
277
|
+
while (b != 0) {
|
|
278
|
+
[a, b] = [b, a % b];
|
|
96
279
|
}
|
|
280
|
+
return a;
|
|
97
281
|
}
|
|
98
282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,EAAE,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACd,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -6,13 +6,19 @@ export type PlayerOptions = {
|
|
|
6
6
|
* If not specified, the default AudioContext constructor is used.
|
|
7
7
|
*/
|
|
8
8
|
newAudioContext?: () => AudioContext;
|
|
9
|
+
/**
|
|
10
|
+
* How much time buffer to use to avoid stuttering, in seconds.
|
|
11
|
+
* If not specified, 0.05 seconds (50 milliseconds) is used.
|
|
12
|
+
*/
|
|
13
|
+
timeBuffer?: number;
|
|
9
14
|
};
|
|
10
15
|
/** A class to play a series of sample buffers at a constant rate using the Web Audio API. */
|
|
11
16
|
export declare class AudioPlayer implements Player {
|
|
12
17
|
private static OUT_RATE;
|
|
13
|
-
private static TIME_BUFFER;
|
|
14
18
|
constructor(options?: PlayerOptions);
|
|
15
19
|
private newAudioContext;
|
|
20
|
+
private timeBuffer;
|
|
21
|
+
private pool;
|
|
16
22
|
private lastPlayedAt;
|
|
17
23
|
private ac;
|
|
18
24
|
private gainNode;
|
|
@@ -30,5 +36,7 @@ export declare class AudioPlayer implements Player {
|
|
|
30
36
|
setVolume(volume: number): void;
|
|
31
37
|
getVolume(): number;
|
|
32
38
|
get sampleRate(): number;
|
|
39
|
+
private getBuffer;
|
|
40
|
+
private returnBuffer;
|
|
33
41
|
}
|
|
34
42
|
//# sourceMappingURL=audioplayer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audioplayer.d.ts","sourceRoot":"","sources":["../../src/players/audioplayer.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,+CAA+C;AAC/C,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"audioplayer.d.ts","sourceRoot":"","sources":["../../src/players/audioplayer.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,+CAA+C;AAC/C,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,YAAY,CAAC;IACrC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,6FAA6F;AAC7F,qBAAa,WAAY,YAAW,MAAM;IACxC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;gBAEpB,OAAO,CAAC,EAAE,aAAa;IAWnC,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,IAAI,CAAyC;IACrD,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,EAAE,CAA2B;IACrC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,IAAI,CAAS;IAErB;;;;OAIG;IACH,IAAI,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY;IAsB1D;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM;IAOxB,SAAS,IAAI,MAAM;IAInB,IAAI,UAAU,IAAI,MAAM,CAGvB;IAED,OAAO,CAAC,SAAS;IAajB,OAAO,CAAC,YAAY;CAQrB"}
|
|
@@ -14,16 +14,19 @@
|
|
|
14
14
|
/** A class to play a series of sample buffers at a constant rate using the Web Audio API. */
|
|
15
15
|
export class AudioPlayer {
|
|
16
16
|
static OUT_RATE = 48000;
|
|
17
|
-
static TIME_BUFFER = 0.05;
|
|
18
17
|
constructor(options) {
|
|
19
18
|
this.newAudioContext =
|
|
20
19
|
options?.newAudioContext || (() => new AudioContext());
|
|
20
|
+
this.timeBuffer = options?.timeBuffer || 0.05;
|
|
21
|
+
this.pool = new Map();
|
|
21
22
|
this.lastPlayedAt = -1;
|
|
22
23
|
this.ac = undefined;
|
|
23
24
|
this.gainNode = undefined;
|
|
24
25
|
this.gain = 0;
|
|
25
26
|
}
|
|
26
27
|
newAudioContext;
|
|
28
|
+
timeBuffer;
|
|
29
|
+
pool = new Map();
|
|
27
30
|
lastPlayedAt;
|
|
28
31
|
ac;
|
|
29
32
|
gainNode;
|
|
@@ -40,13 +43,15 @@ export class AudioPlayer {
|
|
|
40
43
|
this.gainNode.gain.value = this.gain;
|
|
41
44
|
this.gainNode.connect(this.ac.destination);
|
|
42
45
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
let now = this.ac.currentTime;
|
|
47
|
+
let next = this.lastPlayedAt + leftSamples.length / AudioPlayer.OUT_RATE;
|
|
48
|
+
this.lastPlayedAt = next > now ? next : now + this.timeBuffer;
|
|
49
|
+
const buffer = this.getBuffer(leftSamples.length);
|
|
50
|
+
buffer.copyToChannel(leftSamples, 0);
|
|
51
|
+
buffer.copyToChannel(rightSamples, 1);
|
|
52
|
+
let source = new AudioBufferSourceNode(this.ac, { buffer: buffer });
|
|
48
53
|
source.connect(this.gainNode);
|
|
49
|
-
|
|
54
|
+
source.onended = () => this.returnBuffer(buffer);
|
|
50
55
|
source.start(this.lastPlayedAt);
|
|
51
56
|
}
|
|
52
57
|
/**
|
|
@@ -67,5 +72,24 @@ export class AudioPlayer {
|
|
|
67
72
|
return this.ac.sampleRate;
|
|
68
73
|
return 48000;
|
|
69
74
|
}
|
|
75
|
+
getBuffer(length) {
|
|
76
|
+
let items = this.pool.get(length);
|
|
77
|
+
if (items && items.length > 0) {
|
|
78
|
+
return items.pop();
|
|
79
|
+
}
|
|
80
|
+
return new AudioBuffer({
|
|
81
|
+
sampleRate: AudioPlayer.OUT_RATE,
|
|
82
|
+
numberOfChannels: 2,
|
|
83
|
+
length: length,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
returnBuffer(buffer) {
|
|
87
|
+
let items = this.pool.get(buffer.length);
|
|
88
|
+
if (!items) {
|
|
89
|
+
items = [];
|
|
90
|
+
this.pool.set(buffer.length, items);
|
|
91
|
+
}
|
|
92
|
+
items.push(buffer);
|
|
93
|
+
}
|
|
70
94
|
}
|
|
71
95
|
//# sourceMappingURL=audioplayer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audioplayer.js","sourceRoot":"","sources":["../../src/players/audioplayer.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;
|
|
1
|
+
{"version":3,"file":"audioplayer.js","sourceRoot":"","sources":["../../src/players/audioplayer.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;AAkBjC,6FAA6F;AAC7F,MAAM,OAAO,WAAW;IACd,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC;IAEhC,YAAY,OAAuB;QACjC,IAAI,CAAC,eAAe;YAClB,OAAO,EAAE,eAAe,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,YAAY,EAAE,CAAC,CAAC;QACzD,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,IAAI,CAAC;QAC9C,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,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