wavesurfer.js 7.0.0-alpha.43 → 7.0.0-alpha.44
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 +2 -1
- package/dist/base-plugin.d.ts +2 -8
- package/dist/base-plugin.js +7 -4
- package/dist/decoder.d.ts +1 -1
- package/dist/decoder.js +2 -4
- package/dist/plugins/envelope.d.ts +13 -5
- package/dist/plugins/envelope.js +59 -30
- package/dist/plugins/envelope.min.js +1 -1
- package/dist/plugins/minimap.d.ts +3 -2
- package/dist/plugins/minimap.js +8 -8
- package/dist/plugins/minimap.min.js +1 -1
- package/dist/plugins/multitrack.min.js +1 -1
- package/dist/plugins/record.js +5 -4
- package/dist/plugins/record.min.js +1 -1
- package/dist/plugins/regions.d.ts +2 -2
- package/dist/plugins/regions.js +9 -7
- package/dist/plugins/regions.min.js +1 -1
- package/dist/plugins/spectrogram-fft.d.mts +22 -0
- package/dist/plugins/spectrogram-fft.d.ts +9 -0
- package/dist/plugins/spectrogram-fft.js +150 -0
- package/dist/plugins/spectrogram-fft.mjs +175 -0
- package/dist/plugins/spectrogram.d.mts +177 -0
- package/dist/plugins/spectrogram.d.ts +58 -16
- package/dist/plugins/spectrogram.js +312 -140
- package/dist/plugins/spectrogram.min.js +1 -0
- package/dist/plugins/spectrogram.mjs +407 -0
- package/dist/plugins/timeline.d.ts +2 -2
- package/dist/plugins/timeline.js +3 -4
- package/dist/plugins/timeline.min.js +1 -1
- package/dist/renderer.d.ts +1 -1
- package/dist/renderer.js +3 -3
- package/dist/wavesurfer.d.ts +6 -0
- package/dist/wavesurfer.js +10 -6
- package/dist/wavesurfer.min.js +1 -1
- package/package.json +1 -1
- package/dist/legacy-adapter.d.ts +0 -7
- package/dist/legacy-adapter.js +0 -15
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* Calculate FFT - Based on https://github.com/corbanbrook/dsp.js
|
|
4
|
+
*
|
|
5
|
+
* @param {Number} bufferSize Buffer size
|
|
6
|
+
* @param {Number} sampleRate Sample rate
|
|
7
|
+
* @param {Function} windowFunc Window function
|
|
8
|
+
* @param {Number} alpha Alpha channel
|
|
9
|
+
*/
|
|
10
|
+
class FFT {
|
|
11
|
+
constructor(bufferSize, sampleRate, windowFunc, alpha) {
|
|
12
|
+
this.bufferSize = bufferSize;
|
|
13
|
+
this.sampleRate = sampleRate;
|
|
14
|
+
this.bandwidth = (2 / bufferSize) * (sampleRate / 2);
|
|
15
|
+
this.sinTable = new Float32Array(bufferSize);
|
|
16
|
+
this.cosTable = new Float32Array(bufferSize);
|
|
17
|
+
this.windowValues = new Float32Array(bufferSize);
|
|
18
|
+
this.reverseTable = new Uint32Array(bufferSize);
|
|
19
|
+
this.peakBand = 0;
|
|
20
|
+
this.peak = 0;
|
|
21
|
+
var i;
|
|
22
|
+
switch (windowFunc) {
|
|
23
|
+
case 'bartlett':
|
|
24
|
+
for (i = 0; i < bufferSize; i++) {
|
|
25
|
+
this.windowValues[i] =
|
|
26
|
+
(2 / (bufferSize - 1)) *
|
|
27
|
+
((bufferSize - 1) / 2 - Math.abs(i - (bufferSize - 1) / 2));
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
case 'bartlettHann':
|
|
31
|
+
for (i = 0; i < bufferSize; i++) {
|
|
32
|
+
this.windowValues[i] =
|
|
33
|
+
0.62 -
|
|
34
|
+
0.48 * Math.abs(i / (bufferSize - 1) - 0.5) -
|
|
35
|
+
0.38 * Math.cos((Math.PI * 2 * i) / (bufferSize - 1));
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
case 'blackman':
|
|
39
|
+
alpha = alpha || 0.16;
|
|
40
|
+
for (i = 0; i < bufferSize; i++) {
|
|
41
|
+
this.windowValues[i] =
|
|
42
|
+
(1 - alpha) / 2 -
|
|
43
|
+
0.5 * Math.cos((Math.PI * 2 * i) / (bufferSize - 1)) +
|
|
44
|
+
(alpha / 2) *
|
|
45
|
+
Math.cos((4 * Math.PI * i) / (bufferSize - 1));
|
|
46
|
+
}
|
|
47
|
+
break;
|
|
48
|
+
case 'cosine':
|
|
49
|
+
for (i = 0; i < bufferSize; i++) {
|
|
50
|
+
this.windowValues[i] = Math.cos((Math.PI * i) / (bufferSize - 1) - Math.PI / 2);
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
case 'gauss':
|
|
54
|
+
alpha = alpha || 0.25;
|
|
55
|
+
for (i = 0; i < bufferSize; i++) {
|
|
56
|
+
this.windowValues[i] = Math.pow(Math.E, -0.5 *
|
|
57
|
+
Math.pow((i - (bufferSize - 1) / 2) /
|
|
58
|
+
((alpha * (bufferSize - 1)) / 2), 2));
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
case 'hamming':
|
|
62
|
+
for (i = 0; i < bufferSize; i++) {
|
|
63
|
+
this.windowValues[i] =
|
|
64
|
+
0.54 -
|
|
65
|
+
0.46 * Math.cos((Math.PI * 2 * i) / (bufferSize - 1));
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
case 'hann':
|
|
69
|
+
case undefined:
|
|
70
|
+
for (i = 0; i < bufferSize; i++) {
|
|
71
|
+
this.windowValues[i] =
|
|
72
|
+
0.5 * (1 - Math.cos((Math.PI * 2 * i) / (bufferSize - 1)));
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
case 'lanczoz':
|
|
76
|
+
for (i = 0; i < bufferSize; i++) {
|
|
77
|
+
this.windowValues[i] =
|
|
78
|
+
Math.sin(Math.PI * ((2 * i) / (bufferSize - 1) - 1)) /
|
|
79
|
+
(Math.PI * ((2 * i) / (bufferSize - 1) - 1));
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
case 'rectangular':
|
|
83
|
+
for (i = 0; i < bufferSize; i++) {
|
|
84
|
+
this.windowValues[i] = 1;
|
|
85
|
+
}
|
|
86
|
+
break;
|
|
87
|
+
case 'triangular':
|
|
88
|
+
for (i = 0; i < bufferSize; i++) {
|
|
89
|
+
this.windowValues[i] =
|
|
90
|
+
(2 / bufferSize) *
|
|
91
|
+
(bufferSize / 2 - Math.abs(i - (bufferSize - 1) / 2));
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
default:
|
|
95
|
+
throw Error("No such window function '" + windowFunc + "'");
|
|
96
|
+
}
|
|
97
|
+
var limit = 1;
|
|
98
|
+
var bit = bufferSize >> 1;
|
|
99
|
+
var i;
|
|
100
|
+
while (limit < bufferSize) {
|
|
101
|
+
for (i = 0; i < limit; i++) {
|
|
102
|
+
this.reverseTable[i + limit] = this.reverseTable[i] + bit;
|
|
103
|
+
}
|
|
104
|
+
limit = limit << 1;
|
|
105
|
+
bit = bit >> 1;
|
|
106
|
+
}
|
|
107
|
+
for (i = 0; i < bufferSize; i++) {
|
|
108
|
+
this.sinTable[i] = Math.sin(-Math.PI / i);
|
|
109
|
+
this.cosTable[i] = Math.cos(-Math.PI / i);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
calculateSpectrum(buffer) {
|
|
113
|
+
// Locally scope variables for speed up
|
|
114
|
+
var bufferSize = this.bufferSize, cosTable = this.cosTable, sinTable = this.sinTable, reverseTable = this.reverseTable, real = new Float32Array(bufferSize), imag = new Float32Array(bufferSize), bSi = 2 / this.bufferSize, sqrt = Math.sqrt, rval, ival, mag, spectrum = new Float32Array(bufferSize / 2);
|
|
115
|
+
var k = Math.floor(Math.log(bufferSize) / Math.LN2);
|
|
116
|
+
if (Math.pow(2, k) !== bufferSize) {
|
|
117
|
+
throw 'Invalid buffer size, must be a power of 2.';
|
|
118
|
+
}
|
|
119
|
+
if (bufferSize !== buffer.length) {
|
|
120
|
+
throw 'Supplied buffer is not the same size as defined FFT. FFT Size: ' +
|
|
121
|
+
bufferSize +
|
|
122
|
+
' Buffer Size: ' +
|
|
123
|
+
buffer.length;
|
|
124
|
+
}
|
|
125
|
+
var halfSize = 1, phaseShiftStepReal, phaseShiftStepImag, currentPhaseShiftReal, currentPhaseShiftImag, off, tr, ti, tmpReal;
|
|
126
|
+
for (var i = 0; i < bufferSize; i++) {
|
|
127
|
+
real[i] =
|
|
128
|
+
buffer[reverseTable[i]] * this.windowValues[reverseTable[i]];
|
|
129
|
+
imag[i] = 0;
|
|
130
|
+
}
|
|
131
|
+
while (halfSize < bufferSize) {
|
|
132
|
+
phaseShiftStepReal = cosTable[halfSize];
|
|
133
|
+
phaseShiftStepImag = sinTable[halfSize];
|
|
134
|
+
currentPhaseShiftReal = 1;
|
|
135
|
+
currentPhaseShiftImag = 0;
|
|
136
|
+
for (var fftStep = 0; fftStep < halfSize; fftStep++) {
|
|
137
|
+
var i = fftStep;
|
|
138
|
+
while (i < bufferSize) {
|
|
139
|
+
off = i + halfSize;
|
|
140
|
+
tr =
|
|
141
|
+
currentPhaseShiftReal * real[off] -
|
|
142
|
+
currentPhaseShiftImag * imag[off];
|
|
143
|
+
ti =
|
|
144
|
+
currentPhaseShiftReal * imag[off] +
|
|
145
|
+
currentPhaseShiftImag * real[off];
|
|
146
|
+
real[off] = real[i] - tr;
|
|
147
|
+
imag[off] = imag[i] - ti;
|
|
148
|
+
real[i] += tr;
|
|
149
|
+
imag[i] += ti;
|
|
150
|
+
i += halfSize << 1;
|
|
151
|
+
}
|
|
152
|
+
tmpReal = currentPhaseShiftReal;
|
|
153
|
+
currentPhaseShiftReal =
|
|
154
|
+
tmpReal * phaseShiftStepReal -
|
|
155
|
+
currentPhaseShiftImag * phaseShiftStepImag;
|
|
156
|
+
currentPhaseShiftImag =
|
|
157
|
+
tmpReal * phaseShiftStepImag +
|
|
158
|
+
currentPhaseShiftImag * phaseShiftStepReal;
|
|
159
|
+
}
|
|
160
|
+
halfSize = halfSize << 1;
|
|
161
|
+
}
|
|
162
|
+
for (var i = 0, N = bufferSize / 2; i < N; i++) {
|
|
163
|
+
rval = real[i];
|
|
164
|
+
ival = imag[i];
|
|
165
|
+
mag = bSi * sqrt(rval * rval + ival * ival);
|
|
166
|
+
if (mag > this.peak) {
|
|
167
|
+
this.peakBand = i;
|
|
168
|
+
this.peak = mag;
|
|
169
|
+
}
|
|
170
|
+
spectrum[i] = mag;
|
|
171
|
+
}
|
|
172
|
+
return spectrum;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
export default FFT;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} SpectrogramPluginParams
|
|
3
|
+
* @property {string|HTMLElement} container Selector of element or element in
|
|
4
|
+
* which to render
|
|
5
|
+
* @property {number} fftSamples=512 Number of samples to fetch to FFT. Must be
|
|
6
|
+
* a power of 2.
|
|
7
|
+
* @property {boolean} splitChannels=false Render with separate spectrograms for
|
|
8
|
+
* the channels of the audio
|
|
9
|
+
* @property {number} height=fftSamples/2 Height of the spectrogram view in CSS
|
|
10
|
+
* pixels
|
|
11
|
+
* @property {boolean} labels Set to true to display frequency labels.
|
|
12
|
+
* @property {number} noverlap Size of the overlapping window. Must be <
|
|
13
|
+
* fftSamples. Auto deduced from canvas size by default.
|
|
14
|
+
* @property {string} windowFunc='hann' The window function to be used. One of
|
|
15
|
+
* these: `'bartlett'`, `'bartlettHann'`, `'blackman'`, `'cosine'`, `'gauss'`,
|
|
16
|
+
* `'hamming'`, `'hann'`, `'lanczoz'`, `'rectangular'`, `'triangular'`
|
|
17
|
+
* @property {?number} alpha Some window functions have this extra value.
|
|
18
|
+
* (Between 0 and 1)
|
|
19
|
+
* @property {number} pixelRatio=wavesurfer.params.pixelRatio to control the
|
|
20
|
+
* size of the spectrogram in relation with its canvas. 1 = Draw on the whole
|
|
21
|
+
* canvas. 2 = Draw on a quarter (1/2 the length and 1/2 the width)
|
|
22
|
+
* @property {number} frequencyMin=0 Min frequency to scale spectrogram.
|
|
23
|
+
* @property {number} frequencyMax=12000 Max frequency to scale spectrogram.
|
|
24
|
+
* Set this to samplerate/2 to draw whole range of spectrogram.
|
|
25
|
+
* @property {?boolean} deferInit Set to true to manually call
|
|
26
|
+
* `initPlugin('spectrogram')`
|
|
27
|
+
* @property {?number[][]} colorMap A 256 long array of 4-element arrays.
|
|
28
|
+
* Each entry should contain a float between 0 and 1 and specify
|
|
29
|
+
* r, g, b, and alpha.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Render a spectrogram visualisation of the audio.
|
|
33
|
+
*
|
|
34
|
+
* @implements {PluginClass}
|
|
35
|
+
* @extends {Observer}
|
|
36
|
+
* @example
|
|
37
|
+
* // es6
|
|
38
|
+
* import SpectrogramPlugin from 'wavesurfer.spectrogram.js';
|
|
39
|
+
*
|
|
40
|
+
* // commonjs
|
|
41
|
+
* var SpectrogramPlugin = require('wavesurfer.spectrogram.js');
|
|
42
|
+
*
|
|
43
|
+
* // if you are using <script> tags
|
|
44
|
+
* var SpectrogramPlugin = window.WaveSurfer.spectrogram;
|
|
45
|
+
*
|
|
46
|
+
* // ... initialising wavesurfer with the plugin
|
|
47
|
+
* var wavesurfer = WaveSurfer.create({
|
|
48
|
+
* // wavesurfer options ...
|
|
49
|
+
* plugins: [
|
|
50
|
+
* SpectrogramPlugin.create({
|
|
51
|
+
* // plugin options ...
|
|
52
|
+
* })
|
|
53
|
+
* ]
|
|
54
|
+
* });
|
|
55
|
+
*/
|
|
56
|
+
export default class SpectrogramPlugin implements PluginClass {
|
|
57
|
+
/**
|
|
58
|
+
* Spectrogram plugin definition factory
|
|
59
|
+
*
|
|
60
|
+
* This function must be used to create a plugin definition which can be
|
|
61
|
+
* used by wavesurfer to correctly instantiate the plugin.
|
|
62
|
+
*
|
|
63
|
+
* @param {SpectrogramPluginParams} params Parameters used to initialise the plugin
|
|
64
|
+
* @return {PluginDefinition} An object representing the plugin.
|
|
65
|
+
*/
|
|
66
|
+
static create(params: SpectrogramPluginParams): PluginDefinition;
|
|
67
|
+
constructor(params: any, ws: any);
|
|
68
|
+
params: any;
|
|
69
|
+
wavesurfer: any;
|
|
70
|
+
util: any;
|
|
71
|
+
frequenciesDataUrl: any;
|
|
72
|
+
_onScroll: (e: any) => void;
|
|
73
|
+
_onRender: () => void;
|
|
74
|
+
_onWrapperClick: (e: any) => void;
|
|
75
|
+
_onReady: () => void;
|
|
76
|
+
container: any;
|
|
77
|
+
colorMap: any;
|
|
78
|
+
width: any;
|
|
79
|
+
pixelRatio: any;
|
|
80
|
+
fftSamples: any;
|
|
81
|
+
height: any;
|
|
82
|
+
noverlap: any;
|
|
83
|
+
windowFunc: any;
|
|
84
|
+
alpha: any;
|
|
85
|
+
splitChannels: any;
|
|
86
|
+
channels: number;
|
|
87
|
+
frequencyMin: any;
|
|
88
|
+
frequencyMax: any;
|
|
89
|
+
init(): void;
|
|
90
|
+
destroy(): void;
|
|
91
|
+
wrapper: HTMLElement | null | undefined;
|
|
92
|
+
createWrapper(): void;
|
|
93
|
+
labelsEl: HTMLCanvasElement | undefined;
|
|
94
|
+
_wrapperClickHandler(event: any): void;
|
|
95
|
+
createCanvas(): void;
|
|
96
|
+
canvas: HTMLCanvasElement | undefined;
|
|
97
|
+
spectrCc: CanvasRenderingContext2D | null | undefined;
|
|
98
|
+
render(): void;
|
|
99
|
+
updateCanvasStyle(): void;
|
|
100
|
+
drawSpectrogram(frequenciesData: any, my: any): void;
|
|
101
|
+
getFrequencies(callback: any): void;
|
|
102
|
+
buffer: any;
|
|
103
|
+
loadFrequenciesData(url: any): any;
|
|
104
|
+
freqType(freq: any): string | number;
|
|
105
|
+
unitType(freq: any): "KHz" | "Hz";
|
|
106
|
+
loadLabels(bgFill: any, fontSizeFreq: any, fontSizeUnit: any, fontType: any, textColorFreq: any, textColorUnit: any, textAlign: any, container: any): void;
|
|
107
|
+
updateScroll(e: any): void;
|
|
108
|
+
resample(oldMatrix: any): Uint8Array[];
|
|
109
|
+
}
|
|
110
|
+
export type SpectrogramPluginParams = {
|
|
111
|
+
/**
|
|
112
|
+
* Selector of element or element in
|
|
113
|
+
* which to render
|
|
114
|
+
*/
|
|
115
|
+
container: string | HTMLElement;
|
|
116
|
+
/**
|
|
117
|
+
* =512 Number of samples to fetch to FFT. Must be
|
|
118
|
+
* a power of 2.
|
|
119
|
+
*/
|
|
120
|
+
fftSamples: number;
|
|
121
|
+
/**
|
|
122
|
+
* =false Render with separate spectrograms for
|
|
123
|
+
* the channels of the audio
|
|
124
|
+
*/
|
|
125
|
+
splitChannels: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* =fftSamples/2 Height of the spectrogram view in CSS
|
|
128
|
+
* pixels
|
|
129
|
+
*/
|
|
130
|
+
height: number;
|
|
131
|
+
/**
|
|
132
|
+
* Set to true to display frequency labels.
|
|
133
|
+
*/
|
|
134
|
+
labels: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Size of the overlapping window. Must be <
|
|
137
|
+
* fftSamples. Auto deduced from canvas size by default.
|
|
138
|
+
*/
|
|
139
|
+
noverlap: number;
|
|
140
|
+
/**
|
|
141
|
+
* ='hann' The window function to be used. One of
|
|
142
|
+
* these: `'bartlett'`, `'bartlettHann'`, `'blackman'`, `'cosine'`, `'gauss'`,
|
|
143
|
+
* `'hamming'`, `'hann'`, `'lanczoz'`, `'rectangular'`, `'triangular'`
|
|
144
|
+
*/
|
|
145
|
+
windowFunc: string;
|
|
146
|
+
/**
|
|
147
|
+
* Some window functions have this extra value.
|
|
148
|
+
* (Between 0 and 1)
|
|
149
|
+
*/
|
|
150
|
+
alpha: number | null;
|
|
151
|
+
/**
|
|
152
|
+
* =wavesurfer.params.pixelRatio to control the
|
|
153
|
+
* size of the spectrogram in relation with its canvas. 1 = Draw on the whole
|
|
154
|
+
* canvas. 2 = Draw on a quarter (1/2 the length and 1/2 the width)
|
|
155
|
+
*/
|
|
156
|
+
pixelRatio: number;
|
|
157
|
+
/**
|
|
158
|
+
* =0 Min frequency to scale spectrogram.
|
|
159
|
+
*/
|
|
160
|
+
frequencyMin: number;
|
|
161
|
+
/**
|
|
162
|
+
* =12000 Max frequency to scale spectrogram.
|
|
163
|
+
* Set this to samplerate/2 to draw whole range of spectrogram.
|
|
164
|
+
*/
|
|
165
|
+
frequencyMax: number;
|
|
166
|
+
/**
|
|
167
|
+
* Set to true to manually call
|
|
168
|
+
* `initPlugin('spectrogram')`
|
|
169
|
+
*/
|
|
170
|
+
deferInit: boolean | null;
|
|
171
|
+
/**
|
|
172
|
+
* A 256 long array of 4-element arrays.
|
|
173
|
+
* Each entry should contain a float between 0 and 1 and specify
|
|
174
|
+
* r, g, b, and alpha.
|
|
175
|
+
*/
|
|
176
|
+
colorMap: number[][] | null;
|
|
177
|
+
};
|
|
@@ -1,24 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spectrogram plugin
|
|
3
|
+
*
|
|
4
|
+
* Render a spectrogram visualisation of the audio.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // ... initialising wavesurfer with the plugin
|
|
8
|
+
* var wavesurfer = WaveSurfer.create({
|
|
9
|
+
* // wavesurfer options ...
|
|
10
|
+
* plugins: [
|
|
11
|
+
* SpectrogramPlugin.create({
|
|
12
|
+
* // plugin options ...
|
|
13
|
+
* })
|
|
14
|
+
* ]
|
|
15
|
+
* });
|
|
16
|
+
*/
|
|
1
17
|
import BasePlugin from '../base-plugin.js';
|
|
2
18
|
export type SpectrogramPluginOptions = {
|
|
3
|
-
|
|
4
|
-
|
|
19
|
+
/** Selector of element or element in which to render */
|
|
20
|
+
container: string | HTMLElement;
|
|
21
|
+
/** Number of samples to fetch to FFT. Must be a power of 2. */
|
|
22
|
+
fftSamples?: number;
|
|
23
|
+
/** Height of the spectrogram view in CSS pixels */
|
|
24
|
+
height?: number;
|
|
25
|
+
/** Set to true to display frequency labels. */
|
|
26
|
+
labels?: boolean;
|
|
27
|
+
/** Size of the overlapping window. Must be < fftSamples. Auto deduced from canvas size by default. */
|
|
28
|
+
noverlap?: number;
|
|
29
|
+
/** The window function to be used. */
|
|
30
|
+
windowFunc?: 'bartlett' | 'bartlettHann' | 'blackman' | 'cosine' | 'gauss' | 'hamming' | 'hann' | 'lanczoz' | 'rectangular' | 'triangular';
|
|
31
|
+
/** Some window functions have this extra value. (Between 0 and 1) */
|
|
32
|
+
alpha?: number;
|
|
33
|
+
/** Min frequency to scale spectrogram. */
|
|
34
|
+
frequencyMin?: number;
|
|
35
|
+
/** Max frequency to scale spectrogram. Set this to samplerate/2 to draw whole range of spectrogram. */
|
|
36
|
+
frequencyMax?: number;
|
|
37
|
+
/**
|
|
38
|
+
* A 256 long array of 4-element arrays. Each entry should contain a float between 0 and 1 and specify r, g, b, and alpha.
|
|
39
|
+
* Each entry should contain a float between 0 and 1 and specify r, g, b, and alpha.
|
|
40
|
+
*/
|
|
41
|
+
colorMap?: number[][];
|
|
5
42
|
};
|
|
6
43
|
export type SpectrogramPluginEvents = {
|
|
7
|
-
|
|
8
|
-
|
|
44
|
+
ready: [];
|
|
45
|
+
click: [relativeX: number];
|
|
9
46
|
};
|
|
10
|
-
|
|
11
|
-
private mediaSpectrogramer;
|
|
12
|
-
private recordedUrl;
|
|
47
|
+
export default class SpectrogramPlugin extends BasePlugin<SpectrogramPluginEvents, SpectrogramPluginOptions> {
|
|
13
48
|
static create(options?: SpectrogramPluginOptions): SpectrogramPlugin;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
isSpectrograming(): boolean;
|
|
20
|
-
stopSpectrograming(): void;
|
|
21
|
-
getSpectrogramedUrl(): string;
|
|
49
|
+
utils: {
|
|
50
|
+
style: (el: HTMLElement, styles: Record<string, string>) => CSSStyleDeclaration & Record<string, string>;
|
|
51
|
+
};
|
|
52
|
+
constructor(options: SpectrogramPluginOptions);
|
|
53
|
+
onInit(): void;
|
|
22
54
|
destroy(): void;
|
|
55
|
+
createWrapper(): void;
|
|
56
|
+
_wrapperClickHandler(event: any): void;
|
|
57
|
+
createCanvas(): void;
|
|
58
|
+
render(): void;
|
|
59
|
+
drawSpectrogram: (frequenciesData: any) => void;
|
|
60
|
+
getFrequencies(callback: any): void;
|
|
61
|
+
loadFrequenciesData(url: any): Promise<void>;
|
|
62
|
+
freqType(freq: any): string | number;
|
|
63
|
+
unitType(freq: any): "KHz" | "Hz";
|
|
64
|
+
loadLabels(bgFill: any, fontSizeFreq: any, fontSizeUnit: any, fontType: any, textColorFreq: any, textColorUnit: any, textAlign: any, container: any): void;
|
|
65
|
+
resample(oldMatrix: any): Uint8Array[];
|
|
23
66
|
}
|
|
24
|
-
export default SpectrogramPlugin;
|