@libraz/libsonare 1.0.3 → 1.1.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 +160 -1
- package/dist/index.d.ts +523 -180
- package/dist/index.js +998 -1001
- package/dist/index.js.map +1 -1
- package/dist/sonare.js +1 -1
- package/dist/sonare.wasm +0 -0
- package/package.json +13 -26
- package/src/index.ts +1838 -0
- package/src/public_types.ts +401 -0
- package/src/sonare.js.d.ts +624 -0
- package/src/stream_types.ts +98 -0
- package/src/wasm_types.ts +555 -0
- package/README.npm.md +0 -90
- package/dist/index.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,1013 +1,1010 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
* // Full analysis
|
|
17
|
-
* const result = analyze(samples, sampleRate);
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
// ============================================================================
|
|
21
|
-
// Public Types
|
|
22
|
-
// ============================================================================
|
|
23
|
-
/**
|
|
24
|
-
* Pitch class enum (C=0, C#=1, ..., B=11)
|
|
25
|
-
*/
|
|
26
|
-
export const PitchClass = {
|
|
27
|
-
C: 0,
|
|
28
|
-
Cs: 1,
|
|
29
|
-
D: 2,
|
|
30
|
-
Ds: 3,
|
|
31
|
-
E: 4,
|
|
32
|
-
F: 5,
|
|
33
|
-
Fs: 6,
|
|
34
|
-
G: 7,
|
|
35
|
-
Gs: 8,
|
|
36
|
-
A: 9,
|
|
37
|
-
As: 10,
|
|
38
|
-
B: 11,
|
|
1
|
+
// src/public_types.ts
|
|
2
|
+
var PitchClass = {
|
|
3
|
+
C: 0,
|
|
4
|
+
Cs: 1,
|
|
5
|
+
D: 2,
|
|
6
|
+
Ds: 3,
|
|
7
|
+
E: 4,
|
|
8
|
+
F: 5,
|
|
9
|
+
Fs: 6,
|
|
10
|
+
G: 7,
|
|
11
|
+
Gs: 8,
|
|
12
|
+
A: 9,
|
|
13
|
+
As: 10,
|
|
14
|
+
B: 11
|
|
39
15
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export const Mode = {
|
|
44
|
-
Major: 0,
|
|
45
|
-
Minor: 1,
|
|
16
|
+
var Mode = {
|
|
17
|
+
Major: 0,
|
|
18
|
+
Minor: 1
|
|
46
19
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
Minor7: 6,
|
|
58
|
-
Sus2: 7,
|
|
59
|
-
Sus4: 8,
|
|
20
|
+
var ChordQuality = {
|
|
21
|
+
Major: 0,
|
|
22
|
+
Minor: 1,
|
|
23
|
+
Diminished: 2,
|
|
24
|
+
Augmented: 3,
|
|
25
|
+
Dominant7: 4,
|
|
26
|
+
Major7: 5,
|
|
27
|
+
Minor7: 6,
|
|
28
|
+
Sus2: 7,
|
|
29
|
+
Sus4: 8
|
|
60
30
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
Bridge: 4,
|
|
70
|
-
Instrumental: 5,
|
|
71
|
-
Outro: 6,
|
|
31
|
+
var SectionType = {
|
|
32
|
+
Intro: 0,
|
|
33
|
+
Verse: 1,
|
|
34
|
+
PreChorus: 2,
|
|
35
|
+
Chorus: 3,
|
|
36
|
+
Bridge: 4,
|
|
37
|
+
Instrumental: 5,
|
|
38
|
+
Outro: 6
|
|
72
39
|
};
|
|
73
|
-
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
* Initialize the WASM module.
|
|
83
|
-
* Must be called before using any analysis functions.
|
|
84
|
-
*
|
|
85
|
-
* @param options - Optional module configuration
|
|
86
|
-
* @returns Promise that resolves when initialization is complete
|
|
87
|
-
*/
|
|
88
|
-
export async function init(options) {
|
|
89
|
-
if (module) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (initPromise) {
|
|
93
|
-
return initPromise;
|
|
94
|
-
}
|
|
95
|
-
initPromise = (async () => {
|
|
96
|
-
try {
|
|
97
|
-
const createModule = (await import('./sonare.js')).default;
|
|
98
|
-
module = await createModule(options);
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
initPromise = null;
|
|
102
|
-
throw error;
|
|
103
|
-
}
|
|
104
|
-
})();
|
|
40
|
+
|
|
41
|
+
// src/index.ts
|
|
42
|
+
var module = null;
|
|
43
|
+
var initPromise = null;
|
|
44
|
+
async function init(options) {
|
|
45
|
+
if (module) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (initPromise) {
|
|
105
49
|
return initPromise;
|
|
50
|
+
}
|
|
51
|
+
initPromise = (async () => {
|
|
52
|
+
try {
|
|
53
|
+
const createModule = (await import("./sonare.js")).default;
|
|
54
|
+
module = await createModule(options);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
initPromise = null;
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
})();
|
|
60
|
+
return initPromise;
|
|
61
|
+
}
|
|
62
|
+
function isInitialized() {
|
|
63
|
+
return module !== null;
|
|
64
|
+
}
|
|
65
|
+
function version() {
|
|
66
|
+
if (!module) {
|
|
67
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
68
|
+
}
|
|
69
|
+
return module.version();
|
|
70
|
+
}
|
|
71
|
+
function detectBpm(samples, sampleRate) {
|
|
72
|
+
if (!module) {
|
|
73
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
74
|
+
}
|
|
75
|
+
return module.detectBpm(samples, sampleRate);
|
|
76
|
+
}
|
|
77
|
+
function detectKey(samples, sampleRate) {
|
|
78
|
+
if (!module) {
|
|
79
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
80
|
+
}
|
|
81
|
+
const result = module.detectKey(samples, sampleRate);
|
|
82
|
+
return {
|
|
83
|
+
root: result.root,
|
|
84
|
+
mode: result.mode,
|
|
85
|
+
confidence: result.confidence,
|
|
86
|
+
name: result.name,
|
|
87
|
+
shortName: result.shortName
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function detectOnsets(samples, sampleRate) {
|
|
91
|
+
if (!module) {
|
|
92
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
93
|
+
}
|
|
94
|
+
return module.detectOnsets(samples, sampleRate);
|
|
95
|
+
}
|
|
96
|
+
function detectBeats(samples, sampleRate) {
|
|
97
|
+
if (!module) {
|
|
98
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
99
|
+
}
|
|
100
|
+
return module.detectBeats(samples, sampleRate);
|
|
106
101
|
}
|
|
107
|
-
/**
|
|
108
|
-
* Check if the module is initialized.
|
|
109
|
-
*/
|
|
110
|
-
export function isInitialized() {
|
|
111
|
-
return module !== null;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Get the library version.
|
|
115
|
-
*/
|
|
116
|
-
export function version() {
|
|
117
|
-
if (!module) {
|
|
118
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
119
|
-
}
|
|
120
|
-
return module.version();
|
|
121
|
-
}
|
|
122
|
-
// ============================================================================
|
|
123
|
-
// Quick API (High-level Analysis)
|
|
124
|
-
// ============================================================================
|
|
125
|
-
/**
|
|
126
|
-
* Detect BPM from audio samples.
|
|
127
|
-
*
|
|
128
|
-
* @param samples - Audio samples (mono, float32)
|
|
129
|
-
* @param sampleRate - Sample rate in Hz
|
|
130
|
-
* @returns Detected BPM
|
|
131
|
-
*/
|
|
132
|
-
export function detectBpm(samples, sampleRate) {
|
|
133
|
-
if (!module) {
|
|
134
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
135
|
-
}
|
|
136
|
-
return module.detectBpm(samples, sampleRate);
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Detect musical key from audio samples.
|
|
140
|
-
*
|
|
141
|
-
* @param samples - Audio samples (mono, float32)
|
|
142
|
-
* @param sampleRate - Sample rate in Hz
|
|
143
|
-
* @returns Detected key
|
|
144
|
-
*/
|
|
145
|
-
export function detectKey(samples, sampleRate) {
|
|
146
|
-
if (!module) {
|
|
147
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
148
|
-
}
|
|
149
|
-
const result = module.detectKey(samples, sampleRate);
|
|
150
|
-
return {
|
|
151
|
-
root: result.root,
|
|
152
|
-
mode: result.mode,
|
|
153
|
-
confidence: result.confidence,
|
|
154
|
-
name: result.name,
|
|
155
|
-
shortName: result.shortName,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Detect onset times from audio samples.
|
|
160
|
-
*
|
|
161
|
-
* @param samples - Audio samples (mono, float32)
|
|
162
|
-
* @param sampleRate - Sample rate in Hz
|
|
163
|
-
* @returns Array of onset times in seconds
|
|
164
|
-
*/
|
|
165
|
-
export function detectOnsets(samples, sampleRate) {
|
|
166
|
-
if (!module) {
|
|
167
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
168
|
-
}
|
|
169
|
-
return module.detectOnsets(samples, sampleRate);
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Detect beat times from audio samples.
|
|
173
|
-
*
|
|
174
|
-
* @param samples - Audio samples (mono, float32)
|
|
175
|
-
* @param sampleRate - Sample rate in Hz
|
|
176
|
-
* @returns Array of beat times in seconds
|
|
177
|
-
*/
|
|
178
|
-
export function detectBeats(samples, sampleRate) {
|
|
179
|
-
if (!module) {
|
|
180
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
181
|
-
}
|
|
182
|
-
return module.detectBeats(samples, sampleRate);
|
|
183
|
-
}
|
|
184
|
-
// Helper to convert WASM result to typed result
|
|
185
102
|
function convertAnalysisResult(wasm) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
103
|
+
const beatTimes = new Float32Array(wasm.beats.length);
|
|
104
|
+
for (let i = 0; i < wasm.beats.length; i++) {
|
|
105
|
+
beatTimes[i] = wasm.beats[i].time;
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
bpm: wasm.bpm,
|
|
109
|
+
bpmConfidence: wasm.bpmConfidence,
|
|
110
|
+
key: {
|
|
111
|
+
root: wasm.key.root,
|
|
112
|
+
mode: wasm.key.mode,
|
|
113
|
+
confidence: wasm.key.confidence,
|
|
114
|
+
name: wasm.key.name,
|
|
115
|
+
shortName: wasm.key.shortName
|
|
116
|
+
},
|
|
117
|
+
timeSignature: wasm.timeSignature,
|
|
118
|
+
beatTimes,
|
|
119
|
+
beats: wasm.beats,
|
|
120
|
+
chords: wasm.chords.map((c) => ({
|
|
121
|
+
root: c.root,
|
|
122
|
+
quality: c.quality,
|
|
123
|
+
start: c.start,
|
|
124
|
+
end: c.end,
|
|
125
|
+
confidence: c.confidence,
|
|
126
|
+
name: c.name
|
|
127
|
+
})),
|
|
128
|
+
sections: wasm.sections.map((s) => ({
|
|
129
|
+
type: s.type,
|
|
130
|
+
start: s.start,
|
|
131
|
+
end: s.end,
|
|
132
|
+
energyLevel: s.energyLevel,
|
|
133
|
+
confidence: s.confidence,
|
|
134
|
+
name: s.name
|
|
135
|
+
})),
|
|
136
|
+
timbre: wasm.timbre,
|
|
137
|
+
dynamics: wasm.dynamics,
|
|
138
|
+
rhythm: wasm.rhythm,
|
|
139
|
+
form: wasm.form
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function analyze(samples, sampleRate) {
|
|
143
|
+
if (!module) {
|
|
144
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
145
|
+
}
|
|
146
|
+
const result = module.analyze(samples, sampleRate);
|
|
147
|
+
return convertAnalysisResult(result);
|
|
148
|
+
}
|
|
149
|
+
function analyzeWithProgress(samples, sampleRate, onProgress) {
|
|
150
|
+
if (!module) {
|
|
151
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
152
|
+
}
|
|
153
|
+
const result = module.analyzeWithProgress(samples, sampleRate, onProgress);
|
|
154
|
+
return convertAnalysisResult(result);
|
|
155
|
+
}
|
|
156
|
+
function hpss(samples, sampleRate, kernelHarmonic = 31, kernelPercussive = 31) {
|
|
157
|
+
if (!module) {
|
|
158
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
159
|
+
}
|
|
160
|
+
return module.hpss(samples, sampleRate, kernelHarmonic, kernelPercussive);
|
|
161
|
+
}
|
|
162
|
+
function harmonic(samples, sampleRate) {
|
|
163
|
+
if (!module) {
|
|
164
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
165
|
+
}
|
|
166
|
+
return module.harmonic(samples, sampleRate);
|
|
167
|
+
}
|
|
168
|
+
function percussive(samples, sampleRate) {
|
|
169
|
+
if (!module) {
|
|
170
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
171
|
+
}
|
|
172
|
+
return module.percussive(samples, sampleRate);
|
|
173
|
+
}
|
|
174
|
+
function timeStretch(samples, sampleRate, rate) {
|
|
175
|
+
if (!module) {
|
|
176
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
177
|
+
}
|
|
178
|
+
return module.timeStretch(samples, sampleRate, rate);
|
|
179
|
+
}
|
|
180
|
+
function pitchShift(samples, sampleRate, semitones) {
|
|
181
|
+
if (!module) {
|
|
182
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
183
|
+
}
|
|
184
|
+
return module.pitchShift(samples, sampleRate, semitones);
|
|
185
|
+
}
|
|
186
|
+
function normalize(samples, sampleRate, targetDb = 0) {
|
|
187
|
+
if (!module) {
|
|
188
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
189
|
+
}
|
|
190
|
+
return module.normalize(samples, sampleRate, targetDb);
|
|
191
|
+
}
|
|
192
|
+
function mastering(samples, sampleRate, targetLufs = -14, ceilingDb = -1, truePeakOversample = 4) {
|
|
193
|
+
if (!module) {
|
|
194
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
195
|
+
}
|
|
196
|
+
return module.mastering(samples, sampleRate, targetLufs, ceilingDb, truePeakOversample);
|
|
197
|
+
}
|
|
198
|
+
function masteringProcessorNames() {
|
|
199
|
+
if (!module) {
|
|
200
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
201
|
+
}
|
|
202
|
+
return module.masteringProcessorNames();
|
|
203
|
+
}
|
|
204
|
+
function masteringPairProcessorNames() {
|
|
205
|
+
if (!module) {
|
|
206
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
207
|
+
}
|
|
208
|
+
return module.masteringPairProcessorNames();
|
|
209
|
+
}
|
|
210
|
+
function masteringPairAnalysisNames() {
|
|
211
|
+
if (!module) {
|
|
212
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
213
|
+
}
|
|
214
|
+
return module.masteringPairAnalysisNames();
|
|
215
|
+
}
|
|
216
|
+
function masteringStereoAnalysisNames() {
|
|
217
|
+
if (!module) {
|
|
218
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
219
|
+
}
|
|
220
|
+
return module.masteringStereoAnalysisNames();
|
|
221
|
+
}
|
|
222
|
+
function masteringProcess(processorName, samples, sampleRate, params = {}) {
|
|
223
|
+
if (!module) {
|
|
224
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
225
|
+
}
|
|
226
|
+
return module.masteringProcess(processorName, samples, sampleRate, params);
|
|
227
|
+
}
|
|
228
|
+
function masteringProcessStereo(processorName, left, right, sampleRate, params = {}) {
|
|
229
|
+
if (!module) {
|
|
230
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
231
|
+
}
|
|
232
|
+
if (left.length !== right.length) {
|
|
233
|
+
throw new Error("Stereo channel lengths must match.");
|
|
234
|
+
}
|
|
235
|
+
return module.masteringProcessStereo(processorName, left, right, sampleRate, params);
|
|
236
|
+
}
|
|
237
|
+
function masteringPairProcess(processorName, source, reference, sampleRate, params = {}) {
|
|
238
|
+
if (!module) {
|
|
239
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
240
|
+
}
|
|
241
|
+
return module.masteringPairProcess(processorName, source, reference, sampleRate, params);
|
|
242
|
+
}
|
|
243
|
+
function masteringPairAnalyze(analysisName, source, reference, sampleRate, params = {}) {
|
|
244
|
+
if (!module) {
|
|
245
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
246
|
+
}
|
|
247
|
+
return module.masteringPairAnalyze(analysisName, source, reference, sampleRate, params);
|
|
248
|
+
}
|
|
249
|
+
function masteringStereoAnalyze(analysisName, left, right, sampleRate, params = {}) {
|
|
250
|
+
if (!module) {
|
|
251
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
252
|
+
}
|
|
253
|
+
return module.masteringStereoAnalyze(analysisName, left, right, sampleRate, params);
|
|
254
|
+
}
|
|
255
|
+
function masteringChain(samples, sampleRate, config) {
|
|
256
|
+
if (!module) {
|
|
257
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
258
|
+
}
|
|
259
|
+
return module.masteringChain(samples, sampleRate, config);
|
|
260
|
+
}
|
|
261
|
+
function masteringChainStereo(left, right, sampleRate, config) {
|
|
262
|
+
if (!module) {
|
|
263
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
264
|
+
}
|
|
265
|
+
if (left.length !== right.length) {
|
|
266
|
+
throw new Error("Stereo channel lengths must match.");
|
|
267
|
+
}
|
|
268
|
+
return module.masteringChainStereo(left, right, sampleRate, config);
|
|
269
|
+
}
|
|
270
|
+
function masteringChainWithProgress(samples, sampleRate, config, onProgress) {
|
|
271
|
+
if (!module) {
|
|
272
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
273
|
+
}
|
|
274
|
+
return module.masteringChainWithProgress(
|
|
275
|
+
samples,
|
|
276
|
+
sampleRate,
|
|
277
|
+
config,
|
|
278
|
+
onProgress
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
function masteringChainStereoWithProgress(left, right, sampleRate, config, onProgress) {
|
|
282
|
+
if (!module) {
|
|
283
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
284
|
+
}
|
|
285
|
+
if (left.length !== right.length) {
|
|
286
|
+
throw new Error("Stereo channel lengths must match.");
|
|
287
|
+
}
|
|
288
|
+
return module.masteringChainStereoWithProgress(
|
|
289
|
+
left,
|
|
290
|
+
right,
|
|
291
|
+
sampleRate,
|
|
292
|
+
config,
|
|
293
|
+
onProgress
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
function masteringPresetNames() {
|
|
297
|
+
if (!module) {
|
|
298
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
299
|
+
}
|
|
300
|
+
return module.masteringPresetNames();
|
|
301
|
+
}
|
|
302
|
+
function masterAudio(samples, sampleRate, presetName, overrides = null) {
|
|
303
|
+
if (!module) {
|
|
304
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
305
|
+
}
|
|
306
|
+
return module.masterAudio(presetName, samples, sampleRate, overrides);
|
|
307
|
+
}
|
|
308
|
+
function masterAudioStereo(left, right, sampleRate, presetName, overrides = null) {
|
|
309
|
+
if (!module) {
|
|
310
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
311
|
+
}
|
|
312
|
+
if (left.length !== right.length) {
|
|
313
|
+
throw new Error("Stereo channel lengths must match.");
|
|
314
|
+
}
|
|
315
|
+
return module.masterAudioStereo(presetName, left, right, sampleRate, overrides);
|
|
316
|
+
}
|
|
317
|
+
var StreamingMasteringChain = class {
|
|
318
|
+
constructor(config) {
|
|
319
|
+
if (!module) {
|
|
320
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
321
|
+
}
|
|
322
|
+
this.chain = module.createStreamingMasteringChain(config);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Initialize processors for the given sample rate and block layout.
|
|
326
|
+
*
|
|
327
|
+
* @param sampleRate - Sample rate in Hz
|
|
328
|
+
* @param maxBlockSize - Maximum block size per process call
|
|
329
|
+
* @param numChannels - 1 (mono) or 2 (stereo)
|
|
330
|
+
*/
|
|
331
|
+
prepare(sampleRate, maxBlockSize, numChannels) {
|
|
332
|
+
this.chain.prepare(sampleRate, maxBlockSize, numChannels);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Process one mono block, returning the processed samples (same length).
|
|
336
|
+
*/
|
|
337
|
+
processMono(samples) {
|
|
338
|
+
return this.chain.processMono(samples);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Process one stereo block, returning the processed channels.
|
|
342
|
+
*/
|
|
343
|
+
processStereo(left, right) {
|
|
344
|
+
if (left.length !== right.length) {
|
|
345
|
+
throw new Error("Stereo channel lengths must match.");
|
|
346
|
+
}
|
|
347
|
+
return this.chain.processStereo(left, right);
|
|
348
|
+
}
|
|
349
|
+
/** Reset all processor state without rebuilding. */
|
|
350
|
+
reset() {
|
|
351
|
+
this.chain.reset();
|
|
352
|
+
}
|
|
353
|
+
/** Total reported latency in samples across all active processors. */
|
|
354
|
+
latencySamples() {
|
|
355
|
+
return this.chain.latencySamples();
|
|
356
|
+
}
|
|
357
|
+
/** Ordered stage names that will run (e.g. `"eq.tilt"`). */
|
|
358
|
+
stageNames() {
|
|
359
|
+
return this.chain.stageNames();
|
|
360
|
+
}
|
|
361
|
+
/** Release the underlying WASM object. Safe to call only once. */
|
|
362
|
+
delete() {
|
|
363
|
+
this.chain.delete();
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
function trim(samples, sampleRate, thresholdDb = -60) {
|
|
367
|
+
if (!module) {
|
|
368
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
369
|
+
}
|
|
370
|
+
return module.trim(samples, sampleRate, thresholdDb);
|
|
371
|
+
}
|
|
372
|
+
function stft(samples, sampleRate, nFft = 2048, hopLength = 512) {
|
|
373
|
+
if (!module) {
|
|
374
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
375
|
+
}
|
|
376
|
+
return module.stft(samples, sampleRate, nFft, hopLength);
|
|
377
|
+
}
|
|
378
|
+
function stftDb(samples, sampleRate, nFft = 2048, hopLength = 512) {
|
|
379
|
+
if (!module) {
|
|
380
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
381
|
+
}
|
|
382
|
+
return module.stftDb(samples, sampleRate, nFft, hopLength);
|
|
383
|
+
}
|
|
384
|
+
function melSpectrogram(samples, sampleRate, nFft = 2048, hopLength = 512, nMels = 128) {
|
|
385
|
+
if (!module) {
|
|
386
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
387
|
+
}
|
|
388
|
+
return module.melSpectrogram(samples, sampleRate, nFft, hopLength, nMels);
|
|
389
|
+
}
|
|
390
|
+
function mfcc(samples, sampleRate, nFft = 2048, hopLength = 512, nMels = 128, nMfcc = 13) {
|
|
391
|
+
if (!module) {
|
|
392
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
393
|
+
}
|
|
394
|
+
return module.mfcc(samples, sampleRate, nFft, hopLength, nMels, nMfcc);
|
|
395
|
+
}
|
|
396
|
+
function chroma(samples, sampleRate, nFft = 2048, hopLength = 512) {
|
|
397
|
+
if (!module) {
|
|
398
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
399
|
+
}
|
|
400
|
+
return module.chroma(samples, sampleRate, nFft, hopLength);
|
|
401
|
+
}
|
|
402
|
+
function spectralCentroid(samples, sampleRate, nFft = 2048, hopLength = 512) {
|
|
403
|
+
if (!module) {
|
|
404
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
405
|
+
}
|
|
406
|
+
return module.spectralCentroid(samples, sampleRate, nFft, hopLength);
|
|
407
|
+
}
|
|
408
|
+
function spectralBandwidth(samples, sampleRate, nFft = 2048, hopLength = 512) {
|
|
409
|
+
if (!module) {
|
|
410
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
411
|
+
}
|
|
412
|
+
return module.spectralBandwidth(samples, sampleRate, nFft, hopLength);
|
|
413
|
+
}
|
|
414
|
+
function spectralRolloff(samples, sampleRate, nFft = 2048, hopLength = 512, rollPercent = 0.85) {
|
|
415
|
+
if (!module) {
|
|
416
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
417
|
+
}
|
|
418
|
+
return module.spectralRolloff(samples, sampleRate, nFft, hopLength, rollPercent);
|
|
419
|
+
}
|
|
420
|
+
function spectralFlatness(samples, sampleRate, nFft = 2048, hopLength = 512) {
|
|
421
|
+
if (!module) {
|
|
422
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
423
|
+
}
|
|
424
|
+
return module.spectralFlatness(samples, sampleRate, nFft, hopLength);
|
|
425
|
+
}
|
|
426
|
+
function zeroCrossingRate(samples, sampleRate, frameLength = 2048, hopLength = 512) {
|
|
427
|
+
if (!module) {
|
|
428
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
429
|
+
}
|
|
430
|
+
return module.zeroCrossingRate(samples, sampleRate, frameLength, hopLength);
|
|
431
|
+
}
|
|
432
|
+
function rmsEnergy(samples, sampleRate, frameLength = 2048, hopLength = 512) {
|
|
433
|
+
if (!module) {
|
|
434
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
435
|
+
}
|
|
436
|
+
return module.rmsEnergy(samples, sampleRate, frameLength, hopLength);
|
|
437
|
+
}
|
|
438
|
+
function pitchYin(samples, sampleRate, frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3) {
|
|
439
|
+
if (!module) {
|
|
440
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
441
|
+
}
|
|
442
|
+
return module.pitchYin(samples, sampleRate, frameLength, hopLength, fmin, fmax, threshold);
|
|
443
|
+
}
|
|
444
|
+
function pitchPyin(samples, sampleRate, frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3) {
|
|
445
|
+
if (!module) {
|
|
446
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
447
|
+
}
|
|
448
|
+
return module.pitchPyin(samples, sampleRate, frameLength, hopLength, fmin, fmax, threshold);
|
|
449
|
+
}
|
|
450
|
+
function hzToMel(hz) {
|
|
451
|
+
if (!module) {
|
|
452
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
453
|
+
}
|
|
454
|
+
return module.hzToMel(hz);
|
|
455
|
+
}
|
|
456
|
+
function melToHz(mel) {
|
|
457
|
+
if (!module) {
|
|
458
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
459
|
+
}
|
|
460
|
+
return module.melToHz(mel);
|
|
461
|
+
}
|
|
462
|
+
function hzToMidi(hz) {
|
|
463
|
+
if (!module) {
|
|
464
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
465
|
+
}
|
|
466
|
+
return module.hzToMidi(hz);
|
|
467
|
+
}
|
|
468
|
+
function midiToHz(midi) {
|
|
469
|
+
if (!module) {
|
|
470
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
471
|
+
}
|
|
472
|
+
return module.midiToHz(midi);
|
|
473
|
+
}
|
|
474
|
+
function hzToNote(hz) {
|
|
475
|
+
if (!module) {
|
|
476
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
477
|
+
}
|
|
478
|
+
return module.hzToNote(hz);
|
|
479
|
+
}
|
|
480
|
+
function noteToHz(note) {
|
|
481
|
+
if (!module) {
|
|
482
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
483
|
+
}
|
|
484
|
+
return module.noteToHz(note);
|
|
485
|
+
}
|
|
486
|
+
function framesToTime(frames, sr, hopLength) {
|
|
487
|
+
if (!module) {
|
|
488
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
489
|
+
}
|
|
490
|
+
return module.framesToTime(frames, sr, hopLength);
|
|
491
|
+
}
|
|
492
|
+
function timeToFrames(time, sr, hopLength) {
|
|
493
|
+
if (!module) {
|
|
494
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
495
|
+
}
|
|
496
|
+
return module.timeToFrames(time, sr, hopLength);
|
|
497
|
+
}
|
|
498
|
+
function framesToSamples(frames, hopLength = 512, nFft = 0) {
|
|
499
|
+
if (!module) {
|
|
500
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
501
|
+
}
|
|
502
|
+
return module.framesToSamples(frames, hopLength, nFft);
|
|
503
|
+
}
|
|
504
|
+
function samplesToFrames(samples, hopLength = 512, nFft = 0) {
|
|
505
|
+
if (!module) {
|
|
506
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
507
|
+
}
|
|
508
|
+
return module.samplesToFrames(samples, hopLength, nFft);
|
|
509
|
+
}
|
|
510
|
+
function powerToDb(values, ref = 1, amin = 1e-10, topDb = 80) {
|
|
511
|
+
if (!module) {
|
|
512
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
513
|
+
}
|
|
514
|
+
return module.powerToDb(values, ref, amin, topDb);
|
|
515
|
+
}
|
|
516
|
+
function amplitudeToDb(values, ref = 1, amin = 1e-5, topDb = 80) {
|
|
517
|
+
if (!module) {
|
|
518
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
519
|
+
}
|
|
520
|
+
return module.amplitudeToDb(values, ref, amin, topDb);
|
|
521
|
+
}
|
|
522
|
+
function dbToPower(values, ref = 1) {
|
|
523
|
+
if (!module) {
|
|
524
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
525
|
+
}
|
|
526
|
+
return module.dbToPower(values, ref);
|
|
527
|
+
}
|
|
528
|
+
function dbToAmplitude(values, ref = 1) {
|
|
529
|
+
if (!module) {
|
|
530
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
531
|
+
}
|
|
532
|
+
return module.dbToAmplitude(values, ref);
|
|
533
|
+
}
|
|
534
|
+
function preemphasis(samples, coef = 0.97, zi) {
|
|
535
|
+
if (!module) {
|
|
536
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
537
|
+
}
|
|
538
|
+
return module.preemphasis(samples, coef, zi ?? null);
|
|
539
|
+
}
|
|
540
|
+
function deemphasis(samples, coef = 0.97, zi) {
|
|
541
|
+
if (!module) {
|
|
542
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
543
|
+
}
|
|
544
|
+
return module.deemphasis(samples, coef, zi ?? null);
|
|
545
|
+
}
|
|
546
|
+
function trimSilence(samples, topDb = 60, frameLength = 2048, hopLength = 512) {
|
|
547
|
+
if (!module) {
|
|
548
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
549
|
+
}
|
|
550
|
+
return module.trimSilence(samples, topDb, frameLength, hopLength);
|
|
551
|
+
}
|
|
552
|
+
function splitSilence(samples, topDb = 60, frameLength = 2048, hopLength = 512) {
|
|
553
|
+
if (!module) {
|
|
554
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
555
|
+
}
|
|
556
|
+
return module.splitSilence(samples, topDb, frameLength, hopLength);
|
|
557
|
+
}
|
|
558
|
+
function frameSignal(samples, frameLength, hopLength) {
|
|
559
|
+
if (!module) {
|
|
560
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
561
|
+
}
|
|
562
|
+
return module.frameSignal(samples, frameLength, hopLength);
|
|
563
|
+
}
|
|
564
|
+
function padCenter(values, size, padValue = 0) {
|
|
565
|
+
if (!module) {
|
|
566
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
567
|
+
}
|
|
568
|
+
return module.padCenter(values, size, padValue);
|
|
569
|
+
}
|
|
570
|
+
function fixLength(values, size, padValue = 0) {
|
|
571
|
+
if (!module) {
|
|
572
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
573
|
+
}
|
|
574
|
+
return module.fixLength(values, size, padValue);
|
|
575
|
+
}
|
|
576
|
+
function fixFrames(frames, xMin = 0, xMax = -1, pad = true) {
|
|
577
|
+
if (!module) {
|
|
578
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
579
|
+
}
|
|
580
|
+
return module.fixFrames(frames, xMin, xMax, pad);
|
|
581
|
+
}
|
|
582
|
+
function peakPick(values, preMax, postMax, preAvg, postAvg, delta, wait) {
|
|
583
|
+
if (!module) {
|
|
584
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
585
|
+
}
|
|
586
|
+
return module.peakPick(values, preMax, postMax, preAvg, postAvg, delta, wait);
|
|
587
|
+
}
|
|
588
|
+
function vectorNormalize(values, normType = 0, threshold = 1e-12) {
|
|
589
|
+
if (!module) {
|
|
590
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
591
|
+
}
|
|
592
|
+
return module.vectorNormalize(values, normType, threshold);
|
|
593
|
+
}
|
|
594
|
+
function pcen(values, nBins, nFrames, options = {}) {
|
|
595
|
+
if (!module) {
|
|
596
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
597
|
+
}
|
|
598
|
+
return module.pcen(values, nBins, nFrames, options);
|
|
599
|
+
}
|
|
600
|
+
function tonnetz(chromagram, nChroma, nFrames) {
|
|
601
|
+
if (!module) {
|
|
602
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
603
|
+
}
|
|
604
|
+
return module.tonnetz(chromagram, nChroma, nFrames);
|
|
605
|
+
}
|
|
606
|
+
function tempogram(onsetEnvelope, sampleRate, hopLength = 512, winLength = 384) {
|
|
607
|
+
if (!module) {
|
|
608
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
609
|
+
}
|
|
610
|
+
return module.tempogram(onsetEnvelope, sampleRate, hopLength, winLength);
|
|
611
|
+
}
|
|
612
|
+
function plp(onsetEnvelope, sampleRate, hopLength = 512, tempoMin = 30, tempoMax = 300, winLength = 384) {
|
|
613
|
+
if (!module) {
|
|
614
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
615
|
+
}
|
|
616
|
+
return module.plp(onsetEnvelope, sampleRate, hopLength, tempoMin, tempoMax, winLength);
|
|
617
|
+
}
|
|
618
|
+
function resample(samples, srcSr, targetSr) {
|
|
619
|
+
if (!module) {
|
|
620
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
621
|
+
}
|
|
622
|
+
return module.resample(samples, srcSr, targetSr);
|
|
623
|
+
}
|
|
624
|
+
var Audio = class _Audio {
|
|
625
|
+
constructor(samples, sampleRate) {
|
|
626
|
+
this._samples = samples;
|
|
627
|
+
this._sampleRate = sampleRate;
|
|
628
|
+
}
|
|
629
|
+
/** Create an Audio instance from raw sample data. */
|
|
630
|
+
static fromBuffer(samples, sampleRate) {
|
|
631
|
+
return new _Audio(samples, sampleRate);
|
|
632
|
+
}
|
|
633
|
+
/** The raw audio samples. */
|
|
634
|
+
get data() {
|
|
635
|
+
return this._samples;
|
|
636
|
+
}
|
|
637
|
+
/** Number of samples. */
|
|
638
|
+
get length() {
|
|
639
|
+
return this._samples.length;
|
|
640
|
+
}
|
|
641
|
+
/** Sample rate in Hz. */
|
|
642
|
+
get sampleRate() {
|
|
643
|
+
return this._sampleRate;
|
|
644
|
+
}
|
|
645
|
+
/** Duration in seconds. */
|
|
646
|
+
get duration() {
|
|
647
|
+
return this._samples.length / this._sampleRate;
|
|
648
|
+
}
|
|
649
|
+
// -- Analysis --
|
|
650
|
+
detectBpm() {
|
|
651
|
+
return detectBpm(this._samples, this._sampleRate);
|
|
652
|
+
}
|
|
653
|
+
detectKey() {
|
|
654
|
+
return detectKey(this._samples, this._sampleRate);
|
|
655
|
+
}
|
|
656
|
+
detectOnsets() {
|
|
657
|
+
return detectOnsets(this._samples, this._sampleRate);
|
|
658
|
+
}
|
|
659
|
+
detectBeats() {
|
|
660
|
+
return detectBeats(this._samples, this._sampleRate);
|
|
661
|
+
}
|
|
662
|
+
analyze() {
|
|
663
|
+
return analyze(this._samples, this._sampleRate);
|
|
664
|
+
}
|
|
665
|
+
analyzeWithProgress(onProgress) {
|
|
666
|
+
return analyzeWithProgress(this._samples, this._sampleRate, onProgress);
|
|
667
|
+
}
|
|
668
|
+
// -- Effects --
|
|
669
|
+
hpss(kernelHarmonic = 31, kernelPercussive = 31) {
|
|
670
|
+
return hpss(this._samples, this._sampleRate, kernelHarmonic, kernelPercussive);
|
|
671
|
+
}
|
|
672
|
+
harmonic() {
|
|
673
|
+
return harmonic(this._samples, this._sampleRate);
|
|
674
|
+
}
|
|
675
|
+
percussive() {
|
|
676
|
+
return percussive(this._samples, this._sampleRate);
|
|
677
|
+
}
|
|
678
|
+
timeStretch(rate) {
|
|
679
|
+
return timeStretch(this._samples, this._sampleRate, rate);
|
|
680
|
+
}
|
|
681
|
+
pitchShift(semitones) {
|
|
682
|
+
return pitchShift(this._samples, this._sampleRate, semitones);
|
|
683
|
+
}
|
|
684
|
+
normalize(targetDb = 0) {
|
|
685
|
+
return normalize(this._samples, this._sampleRate, targetDb);
|
|
686
|
+
}
|
|
687
|
+
mastering(targetLufs = -14, ceilingDb = -1, truePeakOversample = 4) {
|
|
688
|
+
return mastering(this._samples, this._sampleRate, targetLufs, ceilingDb, truePeakOversample);
|
|
689
|
+
}
|
|
690
|
+
masteringChain(config) {
|
|
691
|
+
return masteringChain(this._samples, this._sampleRate, config);
|
|
692
|
+
}
|
|
693
|
+
masterAudio(presetName, overrides = null) {
|
|
694
|
+
return masterAudio(this._samples, this._sampleRate, presetName, overrides);
|
|
695
|
+
}
|
|
696
|
+
masteringProcess(processorName, params = {}) {
|
|
697
|
+
return masteringProcess(processorName, this._samples, this._sampleRate, params);
|
|
698
|
+
}
|
|
699
|
+
trim(thresholdDb = -60) {
|
|
700
|
+
return trim(this._samples, this._sampleRate, thresholdDb);
|
|
701
|
+
}
|
|
702
|
+
// -- Features --
|
|
703
|
+
stft(nFft = 2048, hopLength = 512) {
|
|
704
|
+
return stft(this._samples, this._sampleRate, nFft, hopLength);
|
|
705
|
+
}
|
|
706
|
+
stftDb(nFft = 2048, hopLength = 512) {
|
|
707
|
+
return stftDb(this._samples, this._sampleRate, nFft, hopLength);
|
|
708
|
+
}
|
|
709
|
+
melSpectrogram(nFft = 2048, hopLength = 512, nMels = 128) {
|
|
710
|
+
return melSpectrogram(this._samples, this._sampleRate, nFft, hopLength, nMels);
|
|
711
|
+
}
|
|
712
|
+
mfcc(nFft = 2048, hopLength = 512, nMels = 128, nMfcc = 13) {
|
|
713
|
+
return mfcc(this._samples, this._sampleRate, nFft, hopLength, nMels, nMfcc);
|
|
714
|
+
}
|
|
715
|
+
chroma(nFft = 2048, hopLength = 512) {
|
|
716
|
+
return chroma(this._samples, this._sampleRate, nFft, hopLength);
|
|
717
|
+
}
|
|
718
|
+
spectralCentroid(nFft = 2048, hopLength = 512) {
|
|
719
|
+
return spectralCentroid(this._samples, this._sampleRate, nFft, hopLength);
|
|
720
|
+
}
|
|
721
|
+
spectralBandwidth(nFft = 2048, hopLength = 512) {
|
|
722
|
+
return spectralBandwidth(this._samples, this._sampleRate, nFft, hopLength);
|
|
723
|
+
}
|
|
724
|
+
spectralRolloff(nFft = 2048, hopLength = 512, rollPercent = 0.85) {
|
|
725
|
+
return spectralRolloff(this._samples, this._sampleRate, nFft, hopLength, rollPercent);
|
|
726
|
+
}
|
|
727
|
+
spectralFlatness(nFft = 2048, hopLength = 512) {
|
|
728
|
+
return spectralFlatness(this._samples, this._sampleRate, nFft, hopLength);
|
|
729
|
+
}
|
|
730
|
+
zeroCrossingRate(frameLength = 2048, hopLength = 512) {
|
|
731
|
+
return zeroCrossingRate(this._samples, this._sampleRate, frameLength, hopLength);
|
|
732
|
+
}
|
|
733
|
+
rmsEnergy(frameLength = 2048, hopLength = 512) {
|
|
734
|
+
return rmsEnergy(this._samples, this._sampleRate, frameLength, hopLength);
|
|
735
|
+
}
|
|
736
|
+
pitchYin(frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3) {
|
|
737
|
+
return pitchYin(this._samples, this._sampleRate, frameLength, hopLength, fmin, fmax, threshold);
|
|
738
|
+
}
|
|
739
|
+
pitchPyin(frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3) {
|
|
740
|
+
return pitchPyin(
|
|
741
|
+
this._samples,
|
|
742
|
+
this._sampleRate,
|
|
743
|
+
frameLength,
|
|
744
|
+
hopLength,
|
|
745
|
+
fmin,
|
|
746
|
+
fmax,
|
|
747
|
+
threshold
|
|
748
|
+
);
|
|
749
|
+
}
|
|
750
|
+
resample(targetSr) {
|
|
751
|
+
return resample(this._samples, this._sampleRate, targetSr);
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
var StreamAnalyzer = class {
|
|
755
|
+
/**
|
|
756
|
+
* Create a new StreamAnalyzer.
|
|
757
|
+
*
|
|
758
|
+
* @param config - Configuration options
|
|
759
|
+
*/
|
|
760
|
+
constructor(config) {
|
|
761
|
+
if (!module) {
|
|
762
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
763
|
+
}
|
|
764
|
+
this.analyzer = new module.StreamAnalyzer(
|
|
765
|
+
config.sampleRate,
|
|
766
|
+
config.nFft ?? 2048,
|
|
767
|
+
config.hopLength ?? 512,
|
|
768
|
+
config.nMels ?? 128,
|
|
769
|
+
config.computeMel ?? true,
|
|
770
|
+
config.computeChroma ?? true,
|
|
771
|
+
config.computeOnset ?? true,
|
|
772
|
+
config.emitEveryNFrames ?? 1
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Process audio samples.
|
|
777
|
+
*
|
|
778
|
+
* @param samples - Audio samples (mono, float32)
|
|
779
|
+
*/
|
|
780
|
+
process(samples) {
|
|
781
|
+
this.analyzer.process(samples);
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Process audio samples with explicit sample offset.
|
|
785
|
+
*
|
|
786
|
+
* @param samples - Audio samples (mono, float32)
|
|
787
|
+
* @param sampleOffset - Cumulative sample count at start of this chunk
|
|
788
|
+
*/
|
|
789
|
+
processWithOffset(samples, sampleOffset) {
|
|
790
|
+
this.analyzer.processWithOffset(samples, sampleOffset);
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Get the number of frames available to read.
|
|
794
|
+
*/
|
|
795
|
+
availableFrames() {
|
|
796
|
+
return this.analyzer.availableFrames();
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Read processed frames as Structure of Arrays.
|
|
800
|
+
*
|
|
801
|
+
* @param maxFrames - Maximum number of frames to read
|
|
802
|
+
* @returns Frame buffer with analysis results
|
|
803
|
+
*/
|
|
804
|
+
readFrames(maxFrames) {
|
|
805
|
+
return this.analyzer.readFramesSoa(maxFrames);
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Reset the analyzer state.
|
|
809
|
+
*
|
|
810
|
+
* @param baseSampleOffset - Starting sample offset (default 0)
|
|
811
|
+
*/
|
|
812
|
+
reset(baseSampleOffset = 0) {
|
|
813
|
+
this.analyzer.reset(baseSampleOffset);
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Get current statistics and progressive estimates.
|
|
817
|
+
*
|
|
818
|
+
* @returns Analyzer statistics including BPM, key, and chord progression
|
|
819
|
+
*/
|
|
820
|
+
stats() {
|
|
821
|
+
const s = this.analyzer.stats();
|
|
190
822
|
return {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
823
|
+
totalFrames: s.totalFrames,
|
|
824
|
+
totalSamples: s.totalSamples,
|
|
825
|
+
durationSeconds: s.durationSeconds,
|
|
826
|
+
estimate: {
|
|
827
|
+
bpm: s.estimate.bpm,
|
|
828
|
+
bpmConfidence: s.estimate.bpmConfidence,
|
|
829
|
+
bpmCandidateCount: s.estimate.bpmCandidateCount,
|
|
830
|
+
key: s.estimate.key,
|
|
831
|
+
keyMinor: s.estimate.keyMinor,
|
|
832
|
+
keyConfidence: s.estimate.keyConfidence,
|
|
833
|
+
chordRoot: s.estimate.chordRoot,
|
|
834
|
+
chordQuality: s.estimate.chordQuality,
|
|
835
|
+
chordConfidence: s.estimate.chordConfidence,
|
|
836
|
+
chordProgression: s.estimate.chordProgression.map((c) => ({
|
|
837
|
+
root: c.root,
|
|
838
|
+
quality: c.quality,
|
|
839
|
+
startTime: c.startTime,
|
|
840
|
+
confidence: c.confidence
|
|
841
|
+
})),
|
|
842
|
+
barChordProgression: s.estimate.barChordProgression.map((c) => ({
|
|
843
|
+
barIndex: c.barIndex,
|
|
844
|
+
root: c.root,
|
|
845
|
+
quality: c.quality,
|
|
846
|
+
startTime: c.startTime,
|
|
847
|
+
confidence: c.confidence
|
|
848
|
+
})),
|
|
849
|
+
currentBar: s.estimate.currentBar,
|
|
850
|
+
barDuration: s.estimate.barDuration,
|
|
851
|
+
votedPattern: (s.estimate.votedPattern || []).map((c) => ({
|
|
852
|
+
barIndex: c.barIndex,
|
|
853
|
+
root: c.root,
|
|
854
|
+
quality: c.quality,
|
|
855
|
+
startTime: c.startTime,
|
|
856
|
+
confidence: c.confidence
|
|
210
857
|
})),
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
name: s.name,
|
|
858
|
+
patternLength: s.estimate.patternLength,
|
|
859
|
+
detectedPatternName: s.estimate.detectedPatternName || "",
|
|
860
|
+
detectedPatternScore: s.estimate.detectedPatternScore || 0,
|
|
861
|
+
allPatternScores: (s.estimate.allPatternScores || []).map((p) => ({
|
|
862
|
+
name: p.name,
|
|
863
|
+
score: p.score
|
|
218
864
|
})),
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
865
|
+
accumulatedSeconds: s.estimate.accumulatedSeconds,
|
|
866
|
+
usedFrames: s.estimate.usedFrames,
|
|
867
|
+
updated: s.estimate.updated
|
|
868
|
+
}
|
|
223
869
|
};
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
export
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
* @returns STFT result with magnitude and power spectrograms
|
|
365
|
-
*/
|
|
366
|
-
export function stft(samples, sampleRate, nFft = 2048, hopLength = 512) {
|
|
367
|
-
if (!module) {
|
|
368
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
369
|
-
}
|
|
370
|
-
return module.stft(samples, sampleRate, nFft, hopLength);
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Compute STFT and return magnitude in decibels.
|
|
374
|
-
*
|
|
375
|
-
* @param samples - Audio samples (mono, float32)
|
|
376
|
-
* @param sampleRate - Sample rate in Hz
|
|
377
|
-
* @param nFft - FFT size (default: 2048)
|
|
378
|
-
* @param hopLength - Hop length (default: 512)
|
|
379
|
-
* @returns STFT result with dB values
|
|
380
|
-
*/
|
|
381
|
-
export function stftDb(samples, sampleRate, nFft = 2048, hopLength = 512) {
|
|
382
|
-
if (!module) {
|
|
383
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
384
|
-
}
|
|
385
|
-
return module.stftDb(samples, sampleRate, nFft, hopLength);
|
|
386
|
-
}
|
|
387
|
-
// ============================================================================
|
|
388
|
-
// Features - Mel Spectrogram
|
|
389
|
-
// ============================================================================
|
|
390
|
-
/**
|
|
391
|
-
* Compute Mel spectrogram.
|
|
392
|
-
*
|
|
393
|
-
* @param samples - Audio samples (mono, float32)
|
|
394
|
-
* @param sampleRate - Sample rate in Hz
|
|
395
|
-
* @param nFft - FFT size (default: 2048)
|
|
396
|
-
* @param hopLength - Hop length (default: 512)
|
|
397
|
-
* @param nMels - Number of Mel bands (default: 128)
|
|
398
|
-
* @returns Mel spectrogram result
|
|
399
|
-
*/
|
|
400
|
-
export function melSpectrogram(samples, sampleRate, nFft = 2048, hopLength = 512, nMels = 128) {
|
|
401
|
-
if (!module) {
|
|
402
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
403
|
-
}
|
|
404
|
-
return module.melSpectrogram(samples, sampleRate, nFft, hopLength, nMels);
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Compute MFCC (Mel-Frequency Cepstral Coefficients).
|
|
408
|
-
*
|
|
409
|
-
* @param samples - Audio samples (mono, float32)
|
|
410
|
-
* @param sampleRate - Sample rate in Hz
|
|
411
|
-
* @param nFft - FFT size (default: 2048)
|
|
412
|
-
* @param hopLength - Hop length (default: 512)
|
|
413
|
-
* @param nMels - Number of Mel bands (default: 128)
|
|
414
|
-
* @param nMfcc - Number of MFCC coefficients (default: 13)
|
|
415
|
-
* @returns MFCC result
|
|
416
|
-
*/
|
|
417
|
-
export function mfcc(samples, sampleRate, nFft = 2048, hopLength = 512, nMels = 128, nMfcc = 13) {
|
|
418
|
-
if (!module) {
|
|
419
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
420
|
-
}
|
|
421
|
-
return module.mfcc(samples, sampleRate, nFft, hopLength, nMels, nMfcc);
|
|
422
|
-
}
|
|
423
|
-
// ============================================================================
|
|
424
|
-
// Features - Chroma
|
|
425
|
-
// ============================================================================
|
|
426
|
-
/**
|
|
427
|
-
* Compute chromagram (pitch class distribution).
|
|
428
|
-
*
|
|
429
|
-
* @param samples - Audio samples (mono, float32)
|
|
430
|
-
* @param sampleRate - Sample rate in Hz
|
|
431
|
-
* @param nFft - FFT size (default: 2048)
|
|
432
|
-
* @param hopLength - Hop length (default: 512)
|
|
433
|
-
* @returns Chroma features result
|
|
434
|
-
*/
|
|
435
|
-
export function chroma(samples, sampleRate, nFft = 2048, hopLength = 512) {
|
|
436
|
-
if (!module) {
|
|
437
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
438
|
-
}
|
|
439
|
-
return module.chroma(samples, sampleRate, nFft, hopLength);
|
|
440
|
-
}
|
|
441
|
-
// ============================================================================
|
|
442
|
-
// Features - Spectral
|
|
443
|
-
// ============================================================================
|
|
444
|
-
/**
|
|
445
|
-
* Compute spectral centroid (center of mass of spectrum).
|
|
446
|
-
*
|
|
447
|
-
* @param samples - Audio samples (mono, float32)
|
|
448
|
-
* @param sampleRate - Sample rate in Hz
|
|
449
|
-
* @param nFft - FFT size (default: 2048)
|
|
450
|
-
* @param hopLength - Hop length (default: 512)
|
|
451
|
-
* @returns Spectral centroid in Hz for each frame
|
|
452
|
-
*/
|
|
453
|
-
export function spectralCentroid(samples, sampleRate, nFft = 2048, hopLength = 512) {
|
|
454
|
-
if (!module) {
|
|
455
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
456
|
-
}
|
|
457
|
-
return module.spectralCentroid(samples, sampleRate, nFft, hopLength);
|
|
458
|
-
}
|
|
459
|
-
/**
|
|
460
|
-
* Compute spectral bandwidth.
|
|
461
|
-
*
|
|
462
|
-
* @param samples - Audio samples (mono, float32)
|
|
463
|
-
* @param sampleRate - Sample rate in Hz
|
|
464
|
-
* @param nFft - FFT size (default: 2048)
|
|
465
|
-
* @param hopLength - Hop length (default: 512)
|
|
466
|
-
* @returns Spectral bandwidth in Hz for each frame
|
|
467
|
-
*/
|
|
468
|
-
export function spectralBandwidth(samples, sampleRate, nFft = 2048, hopLength = 512) {
|
|
469
|
-
if (!module) {
|
|
470
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
471
|
-
}
|
|
472
|
-
return module.spectralBandwidth(samples, sampleRate, nFft, hopLength);
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* Compute spectral rolloff frequency.
|
|
476
|
-
*
|
|
477
|
-
* @param samples - Audio samples (mono, float32)
|
|
478
|
-
* @param sampleRate - Sample rate in Hz
|
|
479
|
-
* @param nFft - FFT size (default: 2048)
|
|
480
|
-
* @param hopLength - Hop length (default: 512)
|
|
481
|
-
* @param rollPercent - Percentage threshold (default: 0.85)
|
|
482
|
-
* @returns Rolloff frequency in Hz for each frame
|
|
483
|
-
*/
|
|
484
|
-
export function spectralRolloff(samples, sampleRate, nFft = 2048, hopLength = 512, rollPercent = 0.85) {
|
|
485
|
-
if (!module) {
|
|
486
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
487
|
-
}
|
|
488
|
-
return module.spectralRolloff(samples, sampleRate, nFft, hopLength, rollPercent);
|
|
489
|
-
}
|
|
490
|
-
/**
|
|
491
|
-
* Compute spectral flatness.
|
|
492
|
-
*
|
|
493
|
-
* @param samples - Audio samples (mono, float32)
|
|
494
|
-
* @param sampleRate - Sample rate in Hz
|
|
495
|
-
* @param nFft - FFT size (default: 2048)
|
|
496
|
-
* @param hopLength - Hop length (default: 512)
|
|
497
|
-
* @returns Spectral flatness for each frame (0 = tonal, 1 = noise-like)
|
|
498
|
-
*/
|
|
499
|
-
export function spectralFlatness(samples, sampleRate, nFft = 2048, hopLength = 512) {
|
|
500
|
-
if (!module) {
|
|
501
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
502
|
-
}
|
|
503
|
-
return module.spectralFlatness(samples, sampleRate, nFft, hopLength);
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* Compute zero crossing rate.
|
|
507
|
-
*
|
|
508
|
-
* @param samples - Audio samples (mono, float32)
|
|
509
|
-
* @param sampleRate - Sample rate in Hz
|
|
510
|
-
* @param frameLength - Frame length (default: 2048)
|
|
511
|
-
* @param hopLength - Hop length (default: 512)
|
|
512
|
-
* @returns Zero crossing rate for each frame
|
|
513
|
-
*/
|
|
514
|
-
export function zeroCrossingRate(samples, sampleRate, frameLength = 2048, hopLength = 512) {
|
|
515
|
-
if (!module) {
|
|
516
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
517
|
-
}
|
|
518
|
-
return module.zeroCrossingRate(samples, sampleRate, frameLength, hopLength);
|
|
519
|
-
}
|
|
520
|
-
/**
|
|
521
|
-
* Compute RMS energy.
|
|
522
|
-
*
|
|
523
|
-
* @param samples - Audio samples (mono, float32)
|
|
524
|
-
* @param sampleRate - Sample rate in Hz
|
|
525
|
-
* @param frameLength - Frame length (default: 2048)
|
|
526
|
-
* @param hopLength - Hop length (default: 512)
|
|
527
|
-
* @returns RMS energy for each frame
|
|
528
|
-
*/
|
|
529
|
-
export function rmsEnergy(samples, sampleRate, frameLength = 2048, hopLength = 512) {
|
|
530
|
-
if (!module) {
|
|
531
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
532
|
-
}
|
|
533
|
-
return module.rmsEnergy(samples, sampleRate, frameLength, hopLength);
|
|
534
|
-
}
|
|
535
|
-
// ============================================================================
|
|
536
|
-
// Features - Pitch
|
|
537
|
-
// ============================================================================
|
|
538
|
-
/**
|
|
539
|
-
* Detect pitch using YIN algorithm.
|
|
540
|
-
*
|
|
541
|
-
* @param samples - Audio samples (mono, float32)
|
|
542
|
-
* @param sampleRate - Sample rate in Hz
|
|
543
|
-
* @param frameLength - Frame length (default: 2048)
|
|
544
|
-
* @param hopLength - Hop length (default: 512)
|
|
545
|
-
* @param fmin - Minimum frequency in Hz (default: 65)
|
|
546
|
-
* @param fmax - Maximum frequency in Hz (default: 2093)
|
|
547
|
-
* @param threshold - YIN threshold (default: 0.3)
|
|
548
|
-
* @returns Pitch detection result
|
|
549
|
-
*/
|
|
550
|
-
export function pitchYin(samples, sampleRate, frameLength = 2048, hopLength = 512, fmin = 65.0, fmax = 2093.0, threshold = 0.3) {
|
|
551
|
-
if (!module) {
|
|
552
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
553
|
-
}
|
|
554
|
-
return module.pitchYin(samples, sampleRate, frameLength, hopLength, fmin, fmax, threshold);
|
|
555
|
-
}
|
|
556
|
-
/**
|
|
557
|
-
* Detect pitch using pYIN algorithm (probabilistic YIN with HMM smoothing).
|
|
558
|
-
*
|
|
559
|
-
* @param samples - Audio samples (mono, float32)
|
|
560
|
-
* @param sampleRate - Sample rate in Hz
|
|
561
|
-
* @param frameLength - Frame length (default: 2048)
|
|
562
|
-
* @param hopLength - Hop length (default: 512)
|
|
563
|
-
* @param fmin - Minimum frequency in Hz (default: 65)
|
|
564
|
-
* @param fmax - Maximum frequency in Hz (default: 2093)
|
|
565
|
-
* @param threshold - YIN threshold (default: 0.3)
|
|
566
|
-
* @returns Pitch detection result
|
|
567
|
-
*/
|
|
568
|
-
export function pitchPyin(samples, sampleRate, frameLength = 2048, hopLength = 512, fmin = 65.0, fmax = 2093.0, threshold = 0.3) {
|
|
569
|
-
if (!module) {
|
|
570
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
571
|
-
}
|
|
572
|
-
return module.pitchPyin(samples, sampleRate, frameLength, hopLength, fmin, fmax, threshold);
|
|
573
|
-
}
|
|
574
|
-
// ============================================================================
|
|
575
|
-
// Core - Unit Conversion
|
|
576
|
-
// ============================================================================
|
|
577
|
-
/**
|
|
578
|
-
* Convert frequency in Hz to Mel scale.
|
|
579
|
-
*
|
|
580
|
-
* @param hz - Frequency in Hz
|
|
581
|
-
* @returns Mel frequency
|
|
582
|
-
*/
|
|
583
|
-
export function hzToMel(hz) {
|
|
584
|
-
if (!module) {
|
|
585
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
586
|
-
}
|
|
587
|
-
return module.hzToMel(hz);
|
|
588
|
-
}
|
|
589
|
-
/**
|
|
590
|
-
* Convert Mel scale to frequency in Hz.
|
|
591
|
-
*
|
|
592
|
-
* @param mel - Mel frequency
|
|
593
|
-
* @returns Frequency in Hz
|
|
594
|
-
*/
|
|
595
|
-
export function melToHz(mel) {
|
|
596
|
-
if (!module) {
|
|
597
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
598
|
-
}
|
|
599
|
-
return module.melToHz(mel);
|
|
600
|
-
}
|
|
601
|
-
/**
|
|
602
|
-
* Convert frequency in Hz to MIDI note number.
|
|
603
|
-
*
|
|
604
|
-
* @param hz - Frequency in Hz
|
|
605
|
-
* @returns MIDI note number (A4 = 440 Hz = 69)
|
|
606
|
-
*/
|
|
607
|
-
export function hzToMidi(hz) {
|
|
608
|
-
if (!module) {
|
|
609
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
610
|
-
}
|
|
611
|
-
return module.hzToMidi(hz);
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
* Convert MIDI note number to frequency in Hz.
|
|
615
|
-
*
|
|
616
|
-
* @param midi - MIDI note number
|
|
617
|
-
* @returns Frequency in Hz
|
|
618
|
-
*/
|
|
619
|
-
export function midiToHz(midi) {
|
|
620
|
-
if (!module) {
|
|
621
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
622
|
-
}
|
|
623
|
-
return module.midiToHz(midi);
|
|
624
|
-
}
|
|
625
|
-
/**
|
|
626
|
-
* Convert frequency in Hz to note name.
|
|
627
|
-
*
|
|
628
|
-
* @param hz - Frequency in Hz
|
|
629
|
-
* @returns Note name (e.g., "A4", "C#5")
|
|
630
|
-
*/
|
|
631
|
-
export function hzToNote(hz) {
|
|
632
|
-
if (!module) {
|
|
633
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
634
|
-
}
|
|
635
|
-
return module.hzToNote(hz);
|
|
636
|
-
}
|
|
637
|
-
/**
|
|
638
|
-
* Convert note name to frequency in Hz.
|
|
639
|
-
*
|
|
640
|
-
* @param note - Note name (e.g., "A4", "C#5")
|
|
641
|
-
* @returns Frequency in Hz
|
|
642
|
-
*/
|
|
643
|
-
export function noteToHz(note) {
|
|
644
|
-
if (!module) {
|
|
645
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
646
|
-
}
|
|
647
|
-
return module.noteToHz(note);
|
|
648
|
-
}
|
|
649
|
-
/**
|
|
650
|
-
* Convert frame index to time in seconds.
|
|
651
|
-
*
|
|
652
|
-
* @param frames - Frame index
|
|
653
|
-
* @param sr - Sample rate in Hz
|
|
654
|
-
* @param hopLength - Hop length in samples
|
|
655
|
-
* @returns Time in seconds
|
|
656
|
-
*/
|
|
657
|
-
export function framesToTime(frames, sr, hopLength) {
|
|
658
|
-
if (!module) {
|
|
659
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
660
|
-
}
|
|
661
|
-
return module.framesToTime(frames, sr, hopLength);
|
|
662
|
-
}
|
|
663
|
-
/**
|
|
664
|
-
* Convert time in seconds to frame index.
|
|
665
|
-
*
|
|
666
|
-
* @param time - Time in seconds
|
|
667
|
-
* @param sr - Sample rate in Hz
|
|
668
|
-
* @param hopLength - Hop length in samples
|
|
669
|
-
* @returns Frame index
|
|
670
|
-
*/
|
|
671
|
-
export function timeToFrames(time, sr, hopLength) {
|
|
672
|
-
if (!module) {
|
|
673
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
674
|
-
}
|
|
675
|
-
return module.timeToFrames(time, sr, hopLength);
|
|
676
|
-
}
|
|
677
|
-
// ============================================================================
|
|
678
|
-
// Core - Resample
|
|
679
|
-
// ============================================================================
|
|
680
|
-
/**
|
|
681
|
-
* Resample audio to a different sample rate.
|
|
682
|
-
*
|
|
683
|
-
* @param samples - Audio samples (mono, float32)
|
|
684
|
-
* @param srcSr - Source sample rate in Hz
|
|
685
|
-
* @param targetSr - Target sample rate in Hz
|
|
686
|
-
* @returns Resampled audio
|
|
687
|
-
*/
|
|
688
|
-
export function resample(samples, srcSr, targetSr) {
|
|
689
|
-
if (!module) {
|
|
690
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
691
|
-
}
|
|
692
|
-
return module.resample(samples, srcSr, targetSr);
|
|
693
|
-
}
|
|
694
|
-
// ============================================================================
|
|
695
|
-
// Audio Class
|
|
696
|
-
// ============================================================================
|
|
697
|
-
/**
|
|
698
|
-
* Wrapper around audio data that exposes all analysis and feature functions as instance methods.
|
|
699
|
-
*
|
|
700
|
-
* @example
|
|
701
|
-
* ```typescript
|
|
702
|
-
* import { init, Audio } from '@libraz/sonare';
|
|
703
|
-
*
|
|
704
|
-
* await init();
|
|
705
|
-
*
|
|
706
|
-
* const audio = Audio.fromBuffer(samples, 44100);
|
|
707
|
-
* console.log('BPM:', audio.detectBpm());
|
|
708
|
-
* console.log('Key:', audio.detectKey().name);
|
|
709
|
-
*
|
|
710
|
-
* const mel = audio.melSpectrogram();
|
|
711
|
-
* ```
|
|
712
|
-
*/
|
|
713
|
-
export class Audio {
|
|
714
|
-
constructor(samples, sampleRate) {
|
|
715
|
-
this._samples = samples;
|
|
716
|
-
this._sampleRate = sampleRate;
|
|
717
|
-
}
|
|
718
|
-
/** Create an Audio instance from raw sample data. */
|
|
719
|
-
static fromBuffer(samples, sampleRate) {
|
|
720
|
-
return new Audio(samples, sampleRate);
|
|
721
|
-
}
|
|
722
|
-
/** The raw audio samples. */
|
|
723
|
-
get data() {
|
|
724
|
-
return this._samples;
|
|
725
|
-
}
|
|
726
|
-
/** Number of samples. */
|
|
727
|
-
get length() {
|
|
728
|
-
return this._samples.length;
|
|
729
|
-
}
|
|
730
|
-
/** Sample rate in Hz. */
|
|
731
|
-
get sampleRate() {
|
|
732
|
-
return this._sampleRate;
|
|
733
|
-
}
|
|
734
|
-
/** Duration in seconds. */
|
|
735
|
-
get duration() {
|
|
736
|
-
return this._samples.length / this._sampleRate;
|
|
737
|
-
}
|
|
738
|
-
// -- Analysis --
|
|
739
|
-
detectBpm() {
|
|
740
|
-
return detectBpm(this._samples, this._sampleRate);
|
|
741
|
-
}
|
|
742
|
-
detectKey() {
|
|
743
|
-
return detectKey(this._samples, this._sampleRate);
|
|
744
|
-
}
|
|
745
|
-
detectOnsets() {
|
|
746
|
-
return detectOnsets(this._samples, this._sampleRate);
|
|
747
|
-
}
|
|
748
|
-
detectBeats() {
|
|
749
|
-
return detectBeats(this._samples, this._sampleRate);
|
|
750
|
-
}
|
|
751
|
-
analyze() {
|
|
752
|
-
return analyze(this._samples, this._sampleRate);
|
|
753
|
-
}
|
|
754
|
-
analyzeWithProgress(onProgress) {
|
|
755
|
-
return analyzeWithProgress(this._samples, this._sampleRate, onProgress);
|
|
756
|
-
}
|
|
757
|
-
// -- Effects --
|
|
758
|
-
hpss(kernelHarmonic = 31, kernelPercussive = 31) {
|
|
759
|
-
return hpss(this._samples, this._sampleRate, kernelHarmonic, kernelPercussive);
|
|
760
|
-
}
|
|
761
|
-
harmonic() {
|
|
762
|
-
return harmonic(this._samples, this._sampleRate);
|
|
763
|
-
}
|
|
764
|
-
percussive() {
|
|
765
|
-
return percussive(this._samples, this._sampleRate);
|
|
766
|
-
}
|
|
767
|
-
timeStretch(rate) {
|
|
768
|
-
return timeStretch(this._samples, this._sampleRate, rate);
|
|
769
|
-
}
|
|
770
|
-
pitchShift(semitones) {
|
|
771
|
-
return pitchShift(this._samples, this._sampleRate, semitones);
|
|
772
|
-
}
|
|
773
|
-
normalize(targetDb = 0.0) {
|
|
774
|
-
return normalize(this._samples, this._sampleRate, targetDb);
|
|
775
|
-
}
|
|
776
|
-
trim(thresholdDb = -60.0) {
|
|
777
|
-
return trim(this._samples, this._sampleRate, thresholdDb);
|
|
778
|
-
}
|
|
779
|
-
// -- Features --
|
|
780
|
-
stft(nFft = 2048, hopLength = 512) {
|
|
781
|
-
return stft(this._samples, this._sampleRate, nFft, hopLength);
|
|
782
|
-
}
|
|
783
|
-
stftDb(nFft = 2048, hopLength = 512) {
|
|
784
|
-
return stftDb(this._samples, this._sampleRate, nFft, hopLength);
|
|
785
|
-
}
|
|
786
|
-
melSpectrogram(nFft = 2048, hopLength = 512, nMels = 128) {
|
|
787
|
-
return melSpectrogram(this._samples, this._sampleRate, nFft, hopLength, nMels);
|
|
788
|
-
}
|
|
789
|
-
mfcc(nFft = 2048, hopLength = 512, nMels = 128, nMfcc = 13) {
|
|
790
|
-
return mfcc(this._samples, this._sampleRate, nFft, hopLength, nMels, nMfcc);
|
|
791
|
-
}
|
|
792
|
-
chroma(nFft = 2048, hopLength = 512) {
|
|
793
|
-
return chroma(this._samples, this._sampleRate, nFft, hopLength);
|
|
794
|
-
}
|
|
795
|
-
spectralCentroid(nFft = 2048, hopLength = 512) {
|
|
796
|
-
return spectralCentroid(this._samples, this._sampleRate, nFft, hopLength);
|
|
797
|
-
}
|
|
798
|
-
spectralBandwidth(nFft = 2048, hopLength = 512) {
|
|
799
|
-
return spectralBandwidth(this._samples, this._sampleRate, nFft, hopLength);
|
|
800
|
-
}
|
|
801
|
-
spectralRolloff(nFft = 2048, hopLength = 512, rollPercent = 0.85) {
|
|
802
|
-
return spectralRolloff(this._samples, this._sampleRate, nFft, hopLength, rollPercent);
|
|
803
|
-
}
|
|
804
|
-
spectralFlatness(nFft = 2048, hopLength = 512) {
|
|
805
|
-
return spectralFlatness(this._samples, this._sampleRate, nFft, hopLength);
|
|
806
|
-
}
|
|
807
|
-
zeroCrossingRate(frameLength = 2048, hopLength = 512) {
|
|
808
|
-
return zeroCrossingRate(this._samples, this._sampleRate, frameLength, hopLength);
|
|
809
|
-
}
|
|
810
|
-
rmsEnergy(frameLength = 2048, hopLength = 512) {
|
|
811
|
-
return rmsEnergy(this._samples, this._sampleRate, frameLength, hopLength);
|
|
812
|
-
}
|
|
813
|
-
pitchYin(frameLength = 2048, hopLength = 512, fmin = 65.0, fmax = 2093.0, threshold = 0.3) {
|
|
814
|
-
return pitchYin(this._samples, this._sampleRate, frameLength, hopLength, fmin, fmax, threshold);
|
|
815
|
-
}
|
|
816
|
-
pitchPyin(frameLength = 2048, hopLength = 512, fmin = 65.0, fmax = 2093.0, threshold = 0.3) {
|
|
817
|
-
return pitchPyin(this._samples, this._sampleRate, frameLength, hopLength, fmin, fmax, threshold);
|
|
818
|
-
}
|
|
819
|
-
resample(targetSr) {
|
|
820
|
-
return resample(this._samples, this._sampleRate, targetSr);
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
// ============================================================================
|
|
824
|
-
// StreamAnalyzer Class
|
|
825
|
-
// ============================================================================
|
|
826
|
-
/**
|
|
827
|
-
* Real-time streaming audio analyzer.
|
|
828
|
-
*
|
|
829
|
-
* @example
|
|
830
|
-
* ```typescript
|
|
831
|
-
* import { init, StreamAnalyzer } from '@libraz/sonare';
|
|
832
|
-
*
|
|
833
|
-
* await init();
|
|
834
|
-
*
|
|
835
|
-
* const analyzer = new StreamAnalyzer({ sampleRate: 44100 });
|
|
836
|
-
*
|
|
837
|
-
* // In audio processing callback
|
|
838
|
-
* analyzer.process(samples);
|
|
839
|
-
*
|
|
840
|
-
* // Get current analysis state
|
|
841
|
-
* const stats = analyzer.stats();
|
|
842
|
-
* console.log('BPM:', stats.estimate.bpm);
|
|
843
|
-
* console.log('Key:', stats.estimate.key);
|
|
844
|
-
* console.log('Chord progression:', stats.estimate.chordProgression);
|
|
845
|
-
* ```
|
|
846
|
-
*/
|
|
847
|
-
export class StreamAnalyzer {
|
|
848
|
-
/**
|
|
849
|
-
* Create a new StreamAnalyzer.
|
|
850
|
-
*
|
|
851
|
-
* @param config - Configuration options
|
|
852
|
-
*/
|
|
853
|
-
constructor(config) {
|
|
854
|
-
if (!module) {
|
|
855
|
-
throw new Error('Module not initialized. Call init() first.');
|
|
856
|
-
}
|
|
857
|
-
this.analyzer = new module.StreamAnalyzer(config.sampleRate, config.nFft ?? 2048, config.hopLength ?? 512, config.nMels ?? 128, config.computeMel ?? true, config.computeChroma ?? true, config.computeOnset ?? true, config.emitEveryNFrames ?? 1);
|
|
858
|
-
}
|
|
859
|
-
/**
|
|
860
|
-
* Process audio samples.
|
|
861
|
-
*
|
|
862
|
-
* @param samples - Audio samples (mono, float32)
|
|
863
|
-
*/
|
|
864
|
-
process(samples) {
|
|
865
|
-
this.analyzer.process(samples);
|
|
866
|
-
}
|
|
867
|
-
/**
|
|
868
|
-
* Process audio samples with explicit sample offset.
|
|
869
|
-
*
|
|
870
|
-
* @param samples - Audio samples (mono, float32)
|
|
871
|
-
* @param sampleOffset - Cumulative sample count at start of this chunk
|
|
872
|
-
*/
|
|
873
|
-
processWithOffset(samples, sampleOffset) {
|
|
874
|
-
this.analyzer.processWithOffset(samples, sampleOffset);
|
|
875
|
-
}
|
|
876
|
-
/**
|
|
877
|
-
* Get the number of frames available to read.
|
|
878
|
-
*/
|
|
879
|
-
availableFrames() {
|
|
880
|
-
return this.analyzer.availableFrames();
|
|
881
|
-
}
|
|
882
|
-
/**
|
|
883
|
-
* Read processed frames as Structure of Arrays.
|
|
884
|
-
*
|
|
885
|
-
* @param maxFrames - Maximum number of frames to read
|
|
886
|
-
* @returns Frame buffer with analysis results
|
|
887
|
-
*/
|
|
888
|
-
readFrames(maxFrames) {
|
|
889
|
-
return this.analyzer.readFramesSoa(maxFrames);
|
|
890
|
-
}
|
|
891
|
-
/**
|
|
892
|
-
* Reset the analyzer state.
|
|
893
|
-
*
|
|
894
|
-
* @param baseSampleOffset - Starting sample offset (default 0)
|
|
895
|
-
*/
|
|
896
|
-
reset(baseSampleOffset = 0) {
|
|
897
|
-
this.analyzer.reset(baseSampleOffset);
|
|
898
|
-
}
|
|
899
|
-
/**
|
|
900
|
-
* Get current statistics and progressive estimates.
|
|
901
|
-
*
|
|
902
|
-
* @returns Analyzer statistics including BPM, key, and chord progression
|
|
903
|
-
*/
|
|
904
|
-
stats() {
|
|
905
|
-
const s = this.analyzer.stats();
|
|
906
|
-
return {
|
|
907
|
-
totalFrames: s.totalFrames,
|
|
908
|
-
totalSamples: s.totalSamples,
|
|
909
|
-
durationSeconds: s.durationSeconds,
|
|
910
|
-
estimate: {
|
|
911
|
-
bpm: s.estimate.bpm,
|
|
912
|
-
bpmConfidence: s.estimate.bpmConfidence,
|
|
913
|
-
bpmCandidateCount: s.estimate.bpmCandidateCount,
|
|
914
|
-
key: s.estimate.key,
|
|
915
|
-
keyMinor: s.estimate.keyMinor,
|
|
916
|
-
keyConfidence: s.estimate.keyConfidence,
|
|
917
|
-
chordRoot: s.estimate.chordRoot,
|
|
918
|
-
chordQuality: s.estimate.chordQuality,
|
|
919
|
-
chordConfidence: s.estimate.chordConfidence,
|
|
920
|
-
chordProgression: s.estimate.chordProgression.map((c) => ({
|
|
921
|
-
root: c.root,
|
|
922
|
-
quality: c.quality,
|
|
923
|
-
startTime: c.startTime,
|
|
924
|
-
confidence: c.confidence,
|
|
925
|
-
})),
|
|
926
|
-
barChordProgression: s.estimate.barChordProgression.map((c) => ({
|
|
927
|
-
barIndex: c.barIndex,
|
|
928
|
-
root: c.root,
|
|
929
|
-
quality: c.quality,
|
|
930
|
-
startTime: c.startTime,
|
|
931
|
-
confidence: c.confidence,
|
|
932
|
-
})),
|
|
933
|
-
currentBar: s.estimate.currentBar,
|
|
934
|
-
barDuration: s.estimate.barDuration,
|
|
935
|
-
votedPattern: (s.estimate.votedPattern || []).map((c) => ({
|
|
936
|
-
barIndex: c.barIndex,
|
|
937
|
-
root: c.root,
|
|
938
|
-
quality: c.quality,
|
|
939
|
-
startTime: c.startTime,
|
|
940
|
-
confidence: c.confidence,
|
|
941
|
-
})),
|
|
942
|
-
patternLength: s.estimate.patternLength,
|
|
943
|
-
detectedPatternName: s.estimate.detectedPatternName || '',
|
|
944
|
-
detectedPatternScore: s.estimate.detectedPatternScore || 0,
|
|
945
|
-
allPatternScores: (s.estimate.allPatternScores || []).map((p) => ({
|
|
946
|
-
name: p.name,
|
|
947
|
-
score: p.score,
|
|
948
|
-
})),
|
|
949
|
-
accumulatedSeconds: s.estimate.accumulatedSeconds,
|
|
950
|
-
usedFrames: s.estimate.usedFrames,
|
|
951
|
-
updated: s.estimate.updated,
|
|
952
|
-
},
|
|
953
|
-
};
|
|
954
|
-
}
|
|
955
|
-
/**
|
|
956
|
-
* Get total frames processed.
|
|
957
|
-
*/
|
|
958
|
-
frameCount() {
|
|
959
|
-
return this.analyzer.frameCount();
|
|
960
|
-
}
|
|
961
|
-
/**
|
|
962
|
-
* Get current time position in seconds.
|
|
963
|
-
*/
|
|
964
|
-
currentTime() {
|
|
965
|
-
return this.analyzer.currentTime();
|
|
966
|
-
}
|
|
967
|
-
/**
|
|
968
|
-
* Get the sample rate.
|
|
969
|
-
*/
|
|
970
|
-
sampleRate() {
|
|
971
|
-
return this.analyzer.sampleRate();
|
|
972
|
-
}
|
|
973
|
-
/**
|
|
974
|
-
* Set the expected total duration for pattern lock timing.
|
|
975
|
-
*
|
|
976
|
-
* @param durationSeconds - Total duration in seconds
|
|
977
|
-
*/
|
|
978
|
-
setExpectedDuration(durationSeconds) {
|
|
979
|
-
this.analyzer.setExpectedDuration(durationSeconds);
|
|
980
|
-
}
|
|
981
|
-
/**
|
|
982
|
-
* Set normalization gain for loud/compressed audio.
|
|
983
|
-
*
|
|
984
|
-
* @param gain - Gain factor to apply (e.g., 0.5 for -6dB reduction)
|
|
985
|
-
*/
|
|
986
|
-
setNormalizationGain(gain) {
|
|
987
|
-
this.analyzer.setNormalizationGain(gain);
|
|
988
|
-
}
|
|
989
|
-
/**
|
|
990
|
-
* Set tuning reference frequency for non-standard tuning.
|
|
991
|
-
*
|
|
992
|
-
* @param refHz - Reference frequency for A4 (default 440 Hz)
|
|
993
|
-
* @example
|
|
994
|
-
* // If audio is 1 semitone sharp (A4 = 466.16 Hz)
|
|
995
|
-
* analyzer.setTuningRefHz(466.16);
|
|
996
|
-
* // If audio is 1 semitone flat (A4 = 415.30 Hz)
|
|
997
|
-
* analyzer.setTuningRefHz(415.30);
|
|
998
|
-
*/
|
|
999
|
-
setTuningRefHz(refHz) {
|
|
1000
|
-
this.analyzer.setTuningRefHz(refHz);
|
|
1001
|
-
}
|
|
1002
|
-
/**
|
|
1003
|
-
* Release resources. Call when done using the analyzer.
|
|
1004
|
-
*/
|
|
1005
|
-
dispose() {
|
|
1006
|
-
this.analyzer.delete();
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
// ============================================================================
|
|
1010
|
-
// Re-exports
|
|
1011
|
-
// ============================================================================
|
|
1012
|
-
export { PitchClass as Pitch };
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Get total frames processed.
|
|
873
|
+
*/
|
|
874
|
+
frameCount() {
|
|
875
|
+
return this.analyzer.frameCount();
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Get current time position in seconds.
|
|
879
|
+
*/
|
|
880
|
+
currentTime() {
|
|
881
|
+
return this.analyzer.currentTime();
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Get the sample rate.
|
|
885
|
+
*/
|
|
886
|
+
sampleRate() {
|
|
887
|
+
return this.analyzer.sampleRate();
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* Set the expected total duration for pattern lock timing.
|
|
891
|
+
*
|
|
892
|
+
* @param durationSeconds - Total duration in seconds
|
|
893
|
+
*/
|
|
894
|
+
setExpectedDuration(durationSeconds) {
|
|
895
|
+
this.analyzer.setExpectedDuration(durationSeconds);
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* Set normalization gain for loud/compressed audio.
|
|
899
|
+
*
|
|
900
|
+
* @param gain - Gain factor to apply (e.g., 0.5 for -6dB reduction)
|
|
901
|
+
*/
|
|
902
|
+
setNormalizationGain(gain) {
|
|
903
|
+
this.analyzer.setNormalizationGain(gain);
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* Set tuning reference frequency for non-standard tuning.
|
|
907
|
+
*
|
|
908
|
+
* @param refHz - Reference frequency for A4 (default 440 Hz)
|
|
909
|
+
* @example
|
|
910
|
+
* // If audio is 1 semitone sharp (A4 = 466.16 Hz)
|
|
911
|
+
* analyzer.setTuningRefHz(466.16);
|
|
912
|
+
* // If audio is 1 semitone flat (A4 = 415.30 Hz)
|
|
913
|
+
* analyzer.setTuningRefHz(415.30);
|
|
914
|
+
*/
|
|
915
|
+
setTuningRefHz(refHz) {
|
|
916
|
+
this.analyzer.setTuningRefHz(refHz);
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Release resources. Call when done using the analyzer.
|
|
920
|
+
*/
|
|
921
|
+
dispose() {
|
|
922
|
+
this.analyzer.delete();
|
|
923
|
+
}
|
|
924
|
+
};
|
|
925
|
+
export {
|
|
926
|
+
Audio,
|
|
927
|
+
ChordQuality,
|
|
928
|
+
Mode,
|
|
929
|
+
PitchClass as Pitch,
|
|
930
|
+
PitchClass,
|
|
931
|
+
SectionType,
|
|
932
|
+
StreamAnalyzer,
|
|
933
|
+
StreamingMasteringChain,
|
|
934
|
+
amplitudeToDb,
|
|
935
|
+
analyze,
|
|
936
|
+
analyzeWithProgress,
|
|
937
|
+
chroma,
|
|
938
|
+
dbToAmplitude,
|
|
939
|
+
dbToPower,
|
|
940
|
+
deemphasis,
|
|
941
|
+
detectBeats,
|
|
942
|
+
detectBpm,
|
|
943
|
+
detectKey,
|
|
944
|
+
detectOnsets,
|
|
945
|
+
fixFrames,
|
|
946
|
+
fixLength,
|
|
947
|
+
frameSignal,
|
|
948
|
+
framesToSamples,
|
|
949
|
+
framesToTime,
|
|
950
|
+
harmonic,
|
|
951
|
+
hpss,
|
|
952
|
+
hzToMel,
|
|
953
|
+
hzToMidi,
|
|
954
|
+
hzToNote,
|
|
955
|
+
init,
|
|
956
|
+
isInitialized,
|
|
957
|
+
masterAudio,
|
|
958
|
+
masterAudioStereo,
|
|
959
|
+
mastering,
|
|
960
|
+
masteringChain,
|
|
961
|
+
masteringChainStereo,
|
|
962
|
+
masteringChainStereoWithProgress,
|
|
963
|
+
masteringChainWithProgress,
|
|
964
|
+
masteringPairAnalysisNames,
|
|
965
|
+
masteringPairAnalyze,
|
|
966
|
+
masteringPairProcess,
|
|
967
|
+
masteringPairProcessorNames,
|
|
968
|
+
masteringPresetNames,
|
|
969
|
+
masteringProcess,
|
|
970
|
+
masteringProcessStereo,
|
|
971
|
+
masteringProcessorNames,
|
|
972
|
+
masteringStereoAnalysisNames,
|
|
973
|
+
masteringStereoAnalyze,
|
|
974
|
+
melSpectrogram,
|
|
975
|
+
melToHz,
|
|
976
|
+
mfcc,
|
|
977
|
+
midiToHz,
|
|
978
|
+
normalize,
|
|
979
|
+
noteToHz,
|
|
980
|
+
padCenter,
|
|
981
|
+
pcen,
|
|
982
|
+
peakPick,
|
|
983
|
+
percussive,
|
|
984
|
+
pitchPyin,
|
|
985
|
+
pitchShift,
|
|
986
|
+
pitchYin,
|
|
987
|
+
plp,
|
|
988
|
+
powerToDb,
|
|
989
|
+
preemphasis,
|
|
990
|
+
resample,
|
|
991
|
+
rmsEnergy,
|
|
992
|
+
samplesToFrames,
|
|
993
|
+
spectralBandwidth,
|
|
994
|
+
spectralCentroid,
|
|
995
|
+
spectralFlatness,
|
|
996
|
+
spectralRolloff,
|
|
997
|
+
splitSilence,
|
|
998
|
+
stft,
|
|
999
|
+
stftDb,
|
|
1000
|
+
tempogram,
|
|
1001
|
+
timeStretch,
|
|
1002
|
+
timeToFrames,
|
|
1003
|
+
tonnetz,
|
|
1004
|
+
trim,
|
|
1005
|
+
trimSilence,
|
|
1006
|
+
vectorNormalize,
|
|
1007
|
+
version,
|
|
1008
|
+
zeroCrossingRate
|
|
1009
|
+
};
|
|
1013
1010
|
//# sourceMappingURL=index.js.map
|