carta1 1.1.5 → 1.1.7
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/bin/cli.js +72 -2
- package/codec/core/options.js +20 -5
- package/codec/pipeline/encoder.js +18 -11
- package/dist/carta1-worker.min.js +1 -1
- package/dist/carta1-worker.min.js.map +1 -1
- package/dist/carta1.min.js +1 -1
- package/dist/carta1.min.js.map +1 -1
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -82,6 +82,57 @@ function validateTitle(title) {
|
|
|
82
82
|
return { valid: true }
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Validate fixed block modes format and values
|
|
87
|
+
*
|
|
88
|
+
* @param {string} modes - Modes string in format "a,b,c"
|
|
89
|
+
* @returns {Object} Validation result
|
|
90
|
+
* @returns {boolean} returns.valid - Whether modes are valid
|
|
91
|
+
* @returns {Array<number>} [returns.modes] - Parsed modes if valid
|
|
92
|
+
* @returns {string} [returns.error] - Error message if invalid
|
|
93
|
+
*/
|
|
94
|
+
function validateModes(modes) {
|
|
95
|
+
if (!modes) {
|
|
96
|
+
return { valid: true }
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const parts = modes.split(',')
|
|
100
|
+
if (parts.length !== 3) {
|
|
101
|
+
return {
|
|
102
|
+
valid: false,
|
|
103
|
+
error: `Modes must have exactly 3 values separated by commas, got ${parts.length}`,
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const parsedModes = []
|
|
108
|
+
const validValues = [
|
|
109
|
+
[0, 2], // Position 1: 0 or 2
|
|
110
|
+
[0, 2], // Position 2: 0 or 2
|
|
111
|
+
[0, 3], // Position 3: 0 or 3
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
for (let i = 0; i < 3; i++) {
|
|
115
|
+
const mode = parseInt(parts[i], 10)
|
|
116
|
+
if (isNaN(mode)) {
|
|
117
|
+
return {
|
|
118
|
+
valid: false,
|
|
119
|
+
error: `Mode at position ${i + 1} is not a number: "${parts[i]}"`,
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (!validValues[i].includes(mode)) {
|
|
124
|
+
return {
|
|
125
|
+
valid: false,
|
|
126
|
+
error: `Mode at position ${i + 1} must be ${validValues[i].join(' or ')}, got ${mode}`,
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
parsedModes.push(mode)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return { valid: true, modes: parsedModes }
|
|
134
|
+
}
|
|
135
|
+
|
|
85
136
|
/**
|
|
86
137
|
* Progress tracking utility for encoding/decoding operations
|
|
87
138
|
*
|
|
@@ -386,6 +437,16 @@ async function encodeFile(inputFile, outputFile, options) {
|
|
|
386
437
|
}
|
|
387
438
|
}
|
|
388
439
|
|
|
440
|
+
// Validate modes if provided
|
|
441
|
+
let fixedBlockModes = null
|
|
442
|
+
if (options.modes) {
|
|
443
|
+
const validation = validateModes(options.modes)
|
|
444
|
+
if (!validation.valid) {
|
|
445
|
+
throw new Error(validation.error)
|
|
446
|
+
}
|
|
447
|
+
fixedBlockModes = validation.modes
|
|
448
|
+
}
|
|
449
|
+
|
|
389
450
|
if (!options.quiet) {
|
|
390
451
|
const bitrate = Math.round((BITRATE_PER_CHANNEL * reader.channels) / 1000)
|
|
391
452
|
console.log(
|
|
@@ -405,8 +466,11 @@ async function encodeFile(inputFile, outputFile, options) {
|
|
|
405
466
|
|
|
406
467
|
// Create encoder options with spectrum focus if provided
|
|
407
468
|
const encoderOptions = new EncoderOptions()
|
|
408
|
-
if (options.
|
|
409
|
-
encoderOptions.setValue('allocationBias', options.
|
|
469
|
+
if (options.bias !== undefined) {
|
|
470
|
+
encoderOptions.setValue('allocationBias', options.bias)
|
|
471
|
+
}
|
|
472
|
+
if (fixedBlockModes) {
|
|
473
|
+
encoderOptions.setValue('fixedBlockModes', fixedBlockModes)
|
|
410
474
|
}
|
|
411
475
|
|
|
412
476
|
const encodedFrames = AudioProcessor.encodeStream(reader, {
|
|
@@ -642,6 +706,10 @@ async function main() {
|
|
|
642
706
|
'Bit allocation bias (default: 1.0)',
|
|
643
707
|
parseFloat
|
|
644
708
|
)
|
|
709
|
+
.option(
|
|
710
|
+
'-m, --modes <modes>',
|
|
711
|
+
'Fixed block modes [0/2],[0/2],[0/3] for low,mid,high bands (skips transient detection)'
|
|
712
|
+
)
|
|
645
713
|
.argument('<input>', 'Input file path')
|
|
646
714
|
.argument('<output>', 'Output file path')
|
|
647
715
|
.parse()
|
|
@@ -693,3 +761,5 @@ main().catch((error) => {
|
|
|
693
761
|
console.error(error.stack)
|
|
694
762
|
process.exit(1)
|
|
695
763
|
})
|
|
764
|
+
|
|
765
|
+
export { validateModes }
|
package/codec/core/options.js
CHANGED
|
@@ -19,6 +19,7 @@ class EncoderOptions {
|
|
|
19
19
|
transientThresholdMid: 1.5,
|
|
20
20
|
transientThresholdHigh: 2.0,
|
|
21
21
|
allocationBias: 1.0,
|
|
22
|
+
fixedBlockModes: null,
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
this.metadata = {
|
|
@@ -54,6 +55,13 @@ class EncoderOptions {
|
|
|
54
55
|
range: [0.5, 3.0],
|
|
55
56
|
step: 0.01,
|
|
56
57
|
},
|
|
58
|
+
fixedBlockModes: {
|
|
59
|
+
default: this.values.fixedBlockModes,
|
|
60
|
+
name: 'Fixed block modes',
|
|
61
|
+
description:
|
|
62
|
+
'Override transient detection and use fixed block modes. Format: [low, mid, high] where low/mid can be 0 or 2, high can be 0 or 3. When set, transient detection is skipped.',
|
|
63
|
+
type: 'array',
|
|
64
|
+
},
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
// Apply user-provided options
|
|
@@ -86,12 +94,15 @@ class EncoderOptions {
|
|
|
86
94
|
}
|
|
87
95
|
|
|
88
96
|
const meta = this.metadata[key]
|
|
89
|
-
const [min, max] = meta.range
|
|
90
97
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
)
|
|
98
|
+
// Skip range validation for array types
|
|
99
|
+
if (meta.type !== 'array') {
|
|
100
|
+
const [min, max] = meta.range
|
|
101
|
+
if (value < min || value > max) {
|
|
102
|
+
throw new Error(
|
|
103
|
+
`Value for ${key} must be between ${min} and ${max}, got ${value}`
|
|
104
|
+
)
|
|
105
|
+
}
|
|
95
106
|
}
|
|
96
107
|
|
|
97
108
|
this.values[key] = value
|
|
@@ -126,6 +137,10 @@ class EncoderOptions {
|
|
|
126
137
|
return this.values.allocationBias
|
|
127
138
|
}
|
|
128
139
|
|
|
140
|
+
get fixedBlockModes() {
|
|
141
|
+
return this.values.fixedBlockModes
|
|
142
|
+
}
|
|
143
|
+
|
|
129
144
|
getMetadata(key) {
|
|
130
145
|
return this.metadata[key]
|
|
131
146
|
}
|
|
@@ -125,17 +125,24 @@ export function blockSelectorStage(context) {
|
|
|
125
125
|
*/
|
|
126
126
|
return (input) => {
|
|
127
127
|
const { bands } = input
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
128
|
+
|
|
129
|
+
// Use fixed block modes if provided, otherwise do transient detection
|
|
130
|
+
let blockModes
|
|
131
|
+
if (options.fixedBlockModes) {
|
|
132
|
+
blockModes = options.fixedBlockModes
|
|
133
|
+
} else {
|
|
134
|
+
const fftSizes = [FFT_SIZE_LOW, FFT_SIZE_MID, FFT_SIZE_HIGH]
|
|
135
|
+
blockModes = bands.map((bandSamples, bandIndex) => {
|
|
136
|
+
const coeffs = performFFT(bandSamples, fftSizes[bandIndex])
|
|
137
|
+
const transient = detectTransient(
|
|
138
|
+
coeffs,
|
|
139
|
+
bufferPool.transientDetection[bandIndex],
|
|
140
|
+
options.transientThresholdLow
|
|
141
|
+
)
|
|
142
|
+
bufferPool.transientDetection[bandIndex] = coeffs
|
|
143
|
+
return transient * Math.max(bandIndex + 1, 2)
|
|
144
|
+
})
|
|
145
|
+
}
|
|
139
146
|
|
|
140
147
|
return {
|
|
141
148
|
bands,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e={},r=44100,t=new Uint8Array([0,8,0,0]),n=2048,o=212,a=new Int32Array([8,8,8,8,4,4,4,4,8,8,8,8,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,9,9,9,9,10,10,10,10,12,12,12,12,12,12,12,12,20,20,20,20,20,20,20,20]),i=new Int32Array([20,28,32,36,40,44,48,52]),u=new Int32Array([20,36,52]),f=new Int32Array([0,8,16,24,32,36,40,44,48,56,64,72,80,86,92,98,104,110,116,122,128,134,140,146,152,159,166,173,180,189,198,207,216,226,236,246,256,268,280,292,304,316,328,340,352,372,392,412,432,452,472,492]),c=new Int32Array([0,32,64,96,8,40,72,104,12,44,76,108,20,52,84,116,26,58,90,122,128,160,192,224,134,166,198,230,141,173,205,237,150,182,214,246,256,288,320,352,384,416,448,480,268,300,332,364,396,428,460,492]),l=256,s=512,v=function(){for(var e=new Float64Array(32),r=0;r<32;r++)e[r]=Math.sin((r+.5)*Math.PI/64);return e}(),h=46,y=new Float32Array([-1461907e-11,-9205479e-11,-56157569e-12,.00030117269,.0002422519,-.00085293897,-.0005205574,.0020340169,.00078333891,-.0042153862,-.00075614988,.0078402944,-61169922e-12,-.01344162,.0024626821,.021736089,-.007801671,-.034090221,.01880949,.054326009,-.043596379,-.099384367,.13207909,.46424159]),d=function(){for(var e=new Float32Array(48),r=0;r<24;r++)e[r]=2*y[r],e[47-r]=2*y[r];return e}(),b=function(){for(var e=new Float32Array(24),r=0;r<24;r++)e[r]=d[2*r];return e}(),p=function(){for(var e=new Float32Array(24),r=0;r<24;r++)e[r]=d[2*r+1];return e}(),m=[{size:128,windowStart:48},{size:128,windowStart:48},{size:256,windowStart:112}],w=32,g=32,S=16,k=32767,A=32768,O=new Int32Array([0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),j=function(){for(var e=new Float64Array(64),r=0;r<64;r++)e[r]=Math.pow(2,r/3-21);return e}(),M=function(){for(var e=O[15],r=new Float64Array(e+1),t=0;t<=e;t++)r[t]=Math.pow(2,-t);return r}();function B(e,r,t,n){if(0!==n){var o=Math.floor(r/8),a=r%8;t&=(1<<n)-1;for(var i=0;i<n&&o<e.length;){var u=8-a,f=Math.min(n-i,u),c=t>>n-i-f&(1<<f)-1,l=(1<<f)-1<<u-f;e[o]=e[o]&~l|c<<u-f,i+=f,o++,a=0}}}function F(e,r,t){if(0===t)return 0;for(var n=Math.floor(r/8),o=r%8,a=0,i=0;i<t&&n<e.length;){var u=8-o,f=Math.min(t-i,u),c=(1<<f)-1;a=a<<f|e[n]>>u-f&c,i+=f,n++,o=0}return a}function P(e,r,t){var n=F(e,r,t);return n>=1<<t-1?n-(1<<t):n}function T(e){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},T(e)}function C(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,z(n.key),n)}}function z(e){var r=function(e,r){if("object"!=T(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=T(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==T(r)?r:r+""}function I(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return q(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?q(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,u=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function q(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function x(e){var r=new Uint8Array(o),t=new DataView(r.buffer),n=i.indexOf(e.nBfu),a=2-e.blockModes[0]<<14|2-e.blockModes[1]<<12|3-e.blockModes[2]<<10|n<<5;t.setUint16(0,a,!1);for(var u=16,f=0;f<e.nBfu;f++)B(r,u,e.wordLengthIndices[f],4),u+=4;for(var c=0;c<e.nBfu;c++)B(r,u,e.scaleFactorIndices[c],6),u+=6;for(var l=0;l<e.nBfu;l++){var s=O[e.wordLengthIndices[l]];if(s>0){var v,h=I(e.quantizedCoefficients[l]);try{for(h.s();!(v=h.n()).done;){var y=v.value;B(r,u,y<0?y+(1<<s):y,s),u+=s}}catch(e){h.e(e)}finally{h.f()}}}return r[209]=0,r[210]=0,r[211]=0,r}function E(e){if(e.length!==o)throw new Error("Frame must be ".concat(o," bytes"));for(var r=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,!1),t=[2-(r>>14&3),2-(r>>12&3),3-(r>>10&3)],n=i[r>>5&7],u=16,f=new Int32Array(n),c=0;c<n;c++)f[c]=F(e,u,4),u+=4;for(var l=new Int32Array(n),s=0;s<n;s++)l[s]=F(e,u,6),u+=6;for(var v=[],h=0;h<n;h++){var y=O[f[h]],d=a[h],b=new Int32Array(d);if(y>0)for(var p=0;p<d;p++)b[p]=P(e,u,y),u+=y;v.push(b)}return{nBfu:n,scaleFactorIndices:l,wordLengthIndices:f,quantizedCoefficients:v,blockModes:t}}var _=function(){return e=function e(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e)},o=[{key:"createHeader",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=new Uint8Array(n),i=new DataView(a.buffer);a.set(t,0);var u=(new TextEncoder).encode(e);return a.set(u.subarray(0,Math.min(u.length,255)),4),i.setUint32(260,r,!0),a[264]=o,a}},{key:"parseHeader",value:function(e){if(e.length!==n)throw new Error("Header must be ".concat(n," bytes"));for(var r=0;r<t.length;r++)if(e[r]!==t[r])throw new Error("Invalid AEA file");var o=new DataView(e.buffer,e.byteOffset,e.byteLength),a=e.indexOf(0,4),i=-1===a?256:a-4;return{title:(new TextDecoder).decode(e.subarray(4,4+i)),frameCount:o.getUint32(260,!0),channelCount:e[264]}}}],(r=null)&&C(e.prototype,r),o&&C(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,o}();function D(e){return D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},D(e)}function U(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function H(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?U(Object(t),!0).forEach(function(r){L(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):U(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function L(e,r,t){return(r=V(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function W(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,u=[],f=!0,c=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=a.call(t)).done)&&(u.push(n.value),u.length!==r);f=!0);}catch(e){c=!0,o=e}finally{try{if(!f&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(c)throw o}}return u}}(e,r)||function(e,r){if(e){if("string"==typeof e)return G(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?G(e,r):void 0}}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function G(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function N(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,V(n.key),n)}}function V(e){var r=function(e,r){if("object"!=D(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=D(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==D(r)?r:r+""}var R=function(){return e=function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.values={transientThresholdLow:1,transientThresholdMid:1.5,transientThresholdHigh:2,allocationBias:1},this.metadata={transientThresholdLow:{default:this.values.transientThresholdLow,name:"Low Band Transient Threshold",description:"Controls the transient detection threshold for the low frequency band (0-5.5kHz). Lower values make detection more sensitive, triggering short blocks more easily. Higher values require stronger transients.",range:[.01,2],step:.01},transientThresholdMid:{default:this.values.transientThresholdMid,name:"Mid Band Transient Threshold",description:"Controls the transient detection threshold for the mid frequency band (5.5-11kHz). Lower values make detection more sensitive, triggering short blocks more easily. Higher values require stronger transients.",range:[.01,3],step:.01},transientThresholdHigh:{default:this.values.transientThresholdHigh,name:"High Band Transient Threshold",description:"Controls the transient detection threshold for the high frequency band (11-22kHz). Lower values make detection more sensitive, triggering short blocks more easily. Higher values require stronger transients.",range:[.01,4],step:.01},allocationBias:{default:this.values.allocationBias,name:"Bit allocation bias",description:"Controls how bits are distributed across the frequency spectrum during allocation. Higher values focus more bits on loud spectral components, while lower values spread bits more evenly across frequencies.",range:[.5,3],step:.01}},r&&this.setOptions(r)},(r=[{key:"setOptions",value:function(e){for(var r=0,t=Object.entries(e);r<t.length;r++){var n=W(t[r],2),o=n[0],a=n[1];o in this.values&&this.setValue(o,a)}}},{key:"setValue",value:function(e,r){if(!(e in this.metadata))throw new Error("Unknown option: ".concat(e));var t=W(this.metadata[e].range,2),n=t[0],o=t[1];if(r<n||r>o)throw new Error("Value for ".concat(e," must be between ").concat(n," and ").concat(o,", got ").concat(r));this.values[e]=r}},{key:"getValue",value:function(e){if(!(e in this.values))throw new Error("Unknown option: ".concat(e));return this.values[e]}},{key:"transientThresholdLow",get:function(){return this.values.transientThresholdLow}},{key:"transientThresholdMid",get:function(){return this.values.transientThresholdMid}},{key:"transientThresholdHigh",get:function(){return this.values.transientThresholdHigh}},{key:"allocationBias",get:function(){return this.values.allocationBias}},{key:"getMetadata",value:function(e){return this.metadata[e]}},{key:"getAllMetadata",value:function(){return H({},this.metadata)}},{key:"reset",value:function(){for(var e=0,r=Object.entries(this.metadata);e<r.length;e++){var t=W(r[e],2),n=t[0],o=t[1];this.values[n]=o.default}}},{key:"toObject",value:function(){return{values:H({},this.values),metadata:H({},this.metadata)}}}])&&N(e.prototype,r),t&&N(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,t}();function $(e){throw new Error(e)}function J(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];var o=t.map(function(r){return r(e)});return function(e){return o.reduce(function(e,r){return r(e)},e)}}function K(e,r){for(var t=r[e.length],n=0;n<e.length;n++)t[n]=e[e.length-1-n];return t}function Q(e,r){var t,n,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=e.length,i=a>>1,u=null!==(t=null==o||null===(n=o.delay)||void 0===n?void 0:n[a])&&void 0!==t?t:$("qmfAnalysis: qmfWorkBuffers.delay[".concat(a,"] is required"));u.set(r),u.set(e,r.length);for(var f=new Float32Array(i),c=new Float32Array(i),l=0;l<i;l++){for(var s=0,v=0,h=2*l,y=0;y<24;y++)s+=u[h+47-2*y]*b[y],v+=u[h+46-2*y]*p[y];f[l]=s+v,c[l]=s-v}return{lowBand:f,highBand:c,newDelay:u.slice(-46)}}function X(e,r,t){var n,o,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=e.length,u=2*i,f=null!==(n=null==a||null===(o=a.delay)||void 0===o?void 0:o[u])&&void 0!==n?n:$("qmfSynthesis: qmfWorkBuffers.delay[".concat(u,"] is required"));f.set(t);for(var c=0;c<i;c++){var l=e[c],s=r[c],v=h+2*c;f[v]=.5*(l+s),f[v+1]=.5*(l-s)}for(var y=new Float32Array(u),d=0;d<i;d++){for(var m=2*d,w=0,g=0,S=0;S<24;S++){var k=m+2*S;w+=f[k]*b[S],g+=f[k+1]*p[S]}y[2*d]=g,y[2*d+1]=w}return{output:y,newDelay:f.slice(-46)}}function Y(e){return Y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Y(e)}function Z(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,ee(n.key),n)}}function ee(e){var r=function(e,r){if("object"!=Y(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=Y(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==Y(r)?r:r+""}var re=function(){return e=function e(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e)},t=[{key:"fft",value:function(e,r){var t=e.length;if(1!==t){for(var n=Math.log2(t),o=0;o<t;o++){for(var a=0,i=o,u=0;u<n;u++)a=a<<1|1&i,i>>=1;if(a>o){var f=[e[a],e[o]];e[o]=f[0],e[a]=f[1];var c=[r[a],r[o]];r[o]=c[0],r[a]=c[1]}}for(var l=2;l<=t;l<<=1)for(var s=l>>1,v=-2*Math.PI/l,h=Math.cos(v),y=Math.sin(v),d=0;d<t;d+=l)for(var b=1,p=0,m=0;m<s;m++){var w=d+m,g=w+s,S=e[w],k=r[w],A=e[g],O=r[g],j=A*b-O*p,M=A*p+O*b;e[w]=S+j,r[w]=k+M,e[g]=S-j,r[g]=k-M;var B=b*h-p*y;p=b*y+p*h,b=B}}}}],(r=null)&&Z(e.prototype,r),t&&Z(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,t}();function te(e){return te="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},te(e)}function ne(e,r,t){return r=ae(r),function(e,r){if(r&&("object"==te(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,oe()?Reflect.construct(r,t||[],ae(e).constructor):r.apply(e,t))}function oe(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(oe=function(){return!!e})()}function ae(e){return ae=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},ae(e)}function ie(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&ue(e,r)}function ue(e,r){return ue=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,r){return e.__proto__=r,e},ue(e,r)}function fe(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,le(n.key),n)}}function ce(e,r,t){return r&&fe(e.prototype,r),t&&fe(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function le(e){var r=function(e,r){if("object"!=te(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=te(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==te(r)?r:r+""}function se(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}var ve=ce(function e(r,t){se(this,e),this.size=r,this.halfSize=r>>1,this.quarterSize=r>>2,this.fftSize=this.halfSize>>1;var n=2*Math.PI/(8*r),o=2*Math.PI/r,a=Math.sqrt(t/r);this.sinCosTable=new Float64Array(this.halfSize);for(var i=0;i<this.quarterSize;i++){var u=o*i+n;this.sinCosTable[2*i]=a*Math.cos(u),this.sinCosTable[2*i+1]=a*Math.sin(u)}}),he=function(){function e(r,t){return se(this,e),ne(this,e,[r,t])}return ie(e,ve),ce(e,[{key:"transform",value:function(e){var r,t,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=null!==(r=null==o?void 0:o[this.fftSize])&&void 0!==r?r:$("MDCT.transform: mdctBuffers[".concat(this.fftSize,"] is required")),i=null!==(t=null==a?void 0:a.real)&&void 0!==t?t:$("MDCT.transform: mdctBuffers[".concat(this.fftSize,"].real is required")),u=null!==(n=null==a?void 0:a.imag)&&void 0!==n?n:$("MDCT.transform: mdctBuffers[".concat(this.fftSize,"].imag is required")),f=this.quarterSize,c=3*f;i.fill(0),u.fill(0);for(var l=0;l<f;l+=2){var s=c+l,v=f+l,h=f-1-l,y=e[c-1-l]+e[s],d=e[v]-e[h],b=this.sinCosTable[l],p=this.sinCosTable[l+1];i[l>>1]=y*b+d*p,u[l>>1]=d*b-y*p}for(var m=f;m<this.halfSize;m+=2){var w=m>>1,g=m-f,S=f+m,k=5*f-1-m,A=e[c-1-m]-e[g],O=e[S]+e[k],j=this.sinCosTable[m],M=this.sinCosTable[m+1];i[w]=A*j+O*M,u[w]=O*j-A*M}re.fft(i,u);for(var B=new Float32Array(this.halfSize),F=0;F<this.fftSize;F++){var P=this.sinCosTable[2*F],T=this.sinCosTable[2*F+1],C=i[F],z=u[F];B[2*F]=-C*P-z*T,B[this.halfSize-1-2*F]=-C*T+z*P}return B}}])}(),ye=function(){function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return se(this,e),ne(this,e,[r,t||r])}return ie(e,ve),ce(e,[{key:"transform",value:function(e){var r,t,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=null!==(r=null==o?void 0:o[this.fftSize])&&void 0!==r?r:$("IMDCT.transform: mdctBuffers[".concat(this.fftSize,"] is required")),i=null!==(t=null==a?void 0:a.real)&&void 0!==t?t:$("IMDCT.transform: mdctBuffers[".concat(this.fftSize,"].real is required")),u=null!==(n=null==a?void 0:a.imag)&&void 0!==n?n:$("IMDCT.transform: mdctBuffers[".concat(this.fftSize,"].imag is required")),f=this.quarterSize,c=3*f;i.fill(0),u.fill(0);for(var l=0;l<this.fftSize;l++){var s=2*l,v=-e[s],h=-e[this.halfSize-1-s],y=this.sinCosTable[s],d=this.sinCosTable[s+1];i[l]=h*d+v*y,u[l]=h*y-v*d}re.fft(i,u);for(var b=new Float32Array(this.size),p=0;p<this.fftSize/2;p++){var m=2*p,w=this.sinCosTable[m],g=this.sinCosTable[m+1],S=i[p],k=u[p],A=S*w+k*g,O=S*g-k*w;b[c-1-m]=A,b[c+m]=A,b[f+m]=O,b[f-1-m]=-O}for(var j=this.fftSize/2;j<this.fftSize;j++){var M=2*(j-this.fftSize/2)+f,B=2*j,F=this.sinCosTable[B],P=this.sinCosTable[B+1],T=i[j],C=u[j],z=T*F+C*P,I=T*P-C*F;b[c-1-M]=z,b[M-f]=-z,b[f+M]=I,b[5*f-1-M]=I}return b}}])}(),de=new he(64,.5),be=new he(l,.5),pe=new he(s,1),me=new ye(64,512),we=new ye(l,2048),ge=new ye(s,2048);function Se(e,r,t){for(var n=e.length,o=new Float32Array(2*n),a=0;a<n;a++){var i=t[a],u=t[2*n-1-a],f=e[a],c=r[n-1-a];o[a]=f*u-c*i,o[2*n-1-a]=f*i+c*u}return o}function ke(e,r,t){var n=e.length,o=new Int32Array(n);if(0===t||0===r)return o.fill(0,0,n),o;for(var a=(1<<t-1)-1,i=a/j[r],u=a,f=-a,c=0;c<n;c++){var l=e[c]*i,s=l+(l>=0?.5:-.5)|0;o[c]=s>u?u:s<f?f:s}return o}function Ae(e,r,t){if(0===t||0===r)return new Float32Array(e.length);for(var n=j[r],o=(1<<t-1)-1,a=new Float32Array(e.length),i=0;i<e.length;i++)a[i]=e[i]*n/o;return a}function Oe(e,r,t,n){var o=t,a=function(e,r,t,n,o){for(var a=new Int32Array(52),i=new Int32Array(e),u=[],f=[],c=function(e,r,t){var n=a[e],i=j[n];if(0===i)return 0;var u=Math.pow(i,o),f=0|O[r],c=0|O[t];return u*((0===f?2:M[f])-M[c])},l=0;l<e;l++){var s=0|t[l];if(0!==s){var v=je(r[l].subarray(0,s));if(a[l]=v,0!==v){var h=0,y=1,d=O[y]-O[h]|0;if(!(d<=0)){var b=c(l,h,y);u.push(l),f.push(b/d)}}}}for(var p=(u.length>>1)-1;p>=0;p--)Be(u,f,p);for(;n>0&&u.length>0;){var m=u[0],w=0|i[m],g=w+1,S=0|t[m],k=(O[g]-O[w]|0)*S;if(k>n||k<=0)Me(u,f);else if(n-=k,i[m]=g,g<15){var A=g+1,B=O[A]-O[g]|0;B>0?(f[0]=c(m,g,A)/B,Be(u,f,0)):Me(u,f)}else Me(u,f)}return{wordLengths:i,scaleFactorIndices:a}}(o,e,r,1656-10*o,n);return{bfuCount:o,allocation:a.wordLengths,scaleFactorIndices:a.scaleFactorIndices}}function je(e){for(var r=0,t=0;t<e.length;t++){var n=Math.abs(e[t]);n>r&&(r=n)}if(0===r)return 0;var o=Math.ceil(3*(Math.log2(r)+21));return Math.max(0,Math.min(63,o))}function Me(e,r){var t=e.length-1;e[0]=e[t],r[0]=r[t],e.pop(),r.pop(),e.length&&Be(e,r,0)}function Be(e,r,t){for(var n=e.length,o=t,a=e[o],i=r[o];;){var u=1+(o<<1),f=u+1,c=o,l=i;if(u<n&&r[u]>l&&(c=u,l=r[u]),f<n&&r[f]>l&&(c=f),c===o)break;e[o]=e[c],r[o]=r[c],o=c}e[o]=a,r[o]=i}function Fe(e){return Fe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fe(e)}function Pe(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Ce(n.key),n)}}function Te(e,r,t){return r&&Pe(e.prototype,r),t&&Pe(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ce(e){var r=function(e,r){if("object"!=Fe(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=Fe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==Fe(r)?r:r+""}var ze=Te(function e(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.transformBuffers={64:new Float32Array(64),128:new Float32Array(128),256:new Float32Array(256),512:new Float32Array(512)},this.qmfWorkBuffers={delay:{128:new Float32Array(174),256:new Float32Array(302),512:new Float32Array(558)},highBandDelay:{128:new Float32Array(167),256:new Float32Array(295)}},this.qmfDelays={lowBand:new Float32Array(h),midBand:new Float32Array(h),highBand:new Float32Array(39)},this.transientDetection=[new Float32Array(64),new Float32Array(64),new Float32Array(128)],this.mdctBuffers={16:{real:new Float32Array(16),imag:new Float32Array(16)},64:{real:new Float32Array(64),imag:new Float32Array(64)},128:{real:new Float32Array(128),imag:new Float32Array(128)}},this.mdctOverlap=[new Float32Array(32),new Float32Array(32),new Float32Array(32)],this.imdctOverlap=[new Float32Array(256),new Float32Array(256),new Float32Array(512)],this.reversalBuffers={32:new Float32Array(32),128:new Float32Array(128),256:new Float32Array(256)}});function Ie(e,r,t){if(!r)return!1;var n=function(e,r){var t=function(e,r){for(var t=0,n=0,o=0;o<e.length;o++){var a=Math.abs(e[o]),i=a-Math.abs(r[o]);i>0&&(t+=i),n+=a*a}var u=Math.sqrt(n)||1e-6;return t/u}(e,r),n=qe(e),o=qe(r),a=Math.abs(n-o),i=xe(e),u=xe(r),f=Math.abs(i-u),c=function(e,r){for(var t=0,n=0,o=0;o<e.length;o++)t+=e[o]*e[o],n+=r[o]*r[o];t=Math.max(t,1e-10),n=Math.max(n,1e-10);var a=10*Math.log10(t/n);return Math.max(0,a)}(e,r);return{spectralFlux:t,flatnessChange:a,hfChange:f,energyChange:c}}(e,r),o=function(e){var r=e.spectralFlux,t=e.flatnessChange,n=e.hfChange,o=e.energyChange,a=r,i=Math.sqrt(t),u=Math.log1p(10*n)/Math.log1p(10),f=Math.min(o/30,1);return(a+i+u+f)/4}(n);return o>t}function qe(e){for(var r=0,t=0,n=0,o=0;o<e.length;o++){var a=Math.abs(e[o]);a>1e-10&&(r+=Math.log(a),t+=a,n++)}if(0===n)return 0;var i=Math.exp(r/n),u=t/n;return u>1e-10?i/u:0}function xe(e){for(var r=Math.floor(e.length/2),t=0,n=0,o=0;o<r;o++)t+=e[o]*e[o];for(var a=r;a<e.length;a++)n+=e[a]*e[a];var i=t+n;return i>0?n/i:0}function Ee(e){var r,t=null!==(r=null==e?void 0:e.bufferPool)&&void 0!==r?r:$("qmfAnalysisStage: bufferPool is required"),n=t.qmfDelays;return function(e){var r=Q(e,n.lowBand,t.qmfWorkBuffers);n.lowBand=r.newDelay;var o=Q(r.lowBand,n.midBand,t.qmfWorkBuffers);n.midBand=o.newDelay;var a=t.qmfWorkBuffers.highBandDelay[r.highBand.length];a.set(n.highBand),a.set(r.highBand,n.highBand.length);var i=a.slice(0,r.highBand.length);return n.highBand=a.slice(r.highBand.length),{bands:[o.lowBand,o.highBand,i]}}}function _e(e){var r,t,n=null!==(r=null==e?void 0:e.bufferPool)&&void 0!==r?r:$("blockSelectorStage: bufferPool is required"),o=null!==(t=null==e?void 0:e.options)&&void 0!==t?t:$("blockSelectorStage: options is required");return function(e){var r=e.bands,t=[128,128,256],a=r.map(function(e,r){var a=function(e,r){var t=new Float32Array(r),n=new Float32Array(r),o=Math.min(e.length,r);t.set(e.subarray(0,o)),re.fft(t,n);for(var a=new Float32Array(r/2),i=0;i<r/2;i++)a[i]=Math.sqrt(t[i]*t[i]+n[i]*n[i]);return a}(e,t[r]),i=Ie(a,n.transientDetection[r],o.transientThresholdLow);return n.transientDetection[r]=a,i*Math.max(r+1,2)});return{bands:r,blockModes:a}}}function De(e){var r,t=null!==(r=null==e?void 0:e.bufferPool)&&void 0!==r?r:$("mdctStage: bufferPool is required"),n=t.mdctOverlap,o=[be,be,pe];function a(e,r,t,n,a){var u=m[r];return 0===t?function(e,r,t,n,o,a){var u=2===r?s:l,f=a.transformBuffers[u];f.fill(0),f.set(o,t.windowStart),i(e,o,t.size),f.set(e,t.windowStart+32);var c=n.transform(f,a.mdctBuffers);r>0&&(c=K(c,a.reversalBuffers));return c}(e,r,u,o[r],n,a):function(e,r,t,n,o){for(var a=1<<(256===t.size?3:2),u=new Float32Array(t.size),f=0;f<a;f++){var c=f*w,l=e.subarray(c,c+w),s=o.transformBuffers[64];s.fill(0),s.set(n,0),i(l,n,w),s.set(l,g);var v=de.transform(s,o.mdctBuffers);r>0&&(v=K(v,o.reversalBuffers)),u.set(v,c)}return u}(e,r,u,n,a)}function i(e,r,t){for(var n=t-g,o=0;o<g;o++){var a=e[n+o];r[o]=v[o]*a,e[n+o]=a*v[31-o]}}return function(e){var r=e.bands,o=e.blockModes,i=e.originalFrame,u=new Float32Array(512);return r.forEach(function(e,r){var i=a(e,r,o[r],n[r],t),f=function(e){return 0===e?0:1===e?128:256}(r);u.set(i,f)}),{bands:r,coefficients:u,blockModes:o,originalFrame:i}}}function Ue(e){var r,t=null!==(r=null==e?void 0:e.options)&&void 0!==r?r:$("quantizationStage: options is required");return function(e){for(var r=e.coefficients,n=e.blockModes,o=function(e,r){for(var t=[],n=[],o=0,i=0,l=0;l<3;l++){for(var s=o,v=2===l?256:128,h=l<2?u[l]:a.length,y=0===r[l]?f:c;i<h;){var d=a[i],b=y[i]-s,p=b+d,m=new Float32Array(d);if(b>=0&&p<=v)m.set(e.subarray(s+b,s+p));else if(m.fill(0),b<v&&p>0){var w=Math.max(0,b),g=Math.min(v,p);m.set(e.subarray(s+w,s+g),Math.max(0,-b))}t.push(m),n.push(d),i++}o+=v}return{bfuData:t,bfuSizes:n,bfuCount:i}}(r,n),i=o.bfuData,l=o.bfuSizes,s=Oe(i,l,o.bfuCount,t.allocationBias),v=s.bfuCount,h=s.allocation,y=s.scaleFactorIndices,d=[],b=0;b<v;b++){var p=i[b].subarray(0,l[b]),m=h[b],w=O[m],g=ke(p,y[b],w);d.push(g)}return{nBfu:v,scaleFactorIndices:y,wordLengthIndices:h.slice(0,v),quantizedCoefficients:d,blockModes:n}}}function He(){return J({options:arguments.length>0&&void 0!==arguments[0]?arguments[0]:new R,bufferPool:arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ze},Ee,_e,De,Ue)}function Le(){return function(e){for(var r=new Float32Array(512),t=e.nBfu,n=e.scaleFactorIndices,o=e.wordLengthIndices,a=e.quantizedCoefficients,i=e.blockModes,l=0;l<t;l++){var s=O[o[l]],v=0;l>=u[0]&&(v=1),l>=u[1]&&(v=2);var h=0===i[v]?f[l]:c[l];if(s>0){var y=Ae(a[l],n[l],s);r.set(y,h)}}return{coefficients:r,blockModes:i}}}function We(e){var r,t=null!==(r=null==e?void 0:e.bufferPool)&&void 0!==r?r:$("imdctStage: bufferPool is required"),n=t.imdctOverlap,o=[we,we,ge];function a(e,r,t,n,a,i){return 0===t?function(e,r,t,n,o,a){var i=e;r>0&&(i=K(e,n.reversalBuffers));var u=a.transform(i,n.mdctBuffers),f=u.length/4,c=n.transformBuffers[512];c.fill(0);for(var l=0;l<o.size;l++)c[l]=u[f+l];var s=t.slice(2*o.size-S,2*o.size),h=Se(s.slice(0,S),c.slice(0,S),v);t.set(h,0);for(var y=0;y<S;y++)s[y]=c[S+y];for(var d=2===r?240:112,b=0;b<d;b++)t[32+b]=c[S+b];for(var p=0;p<S;p++)t[2*o.size-S+p]=c[o.size-S+p];return t.slice(0,o.size)}(e,r,n,a,i,o[r]):function(e,r,t,n,o){var a=1<<(256===o.size?3:2),i=n.transformBuffers[512];i.fill(0);for(var u=t.slice(2*o.size-S,2*o.size),f=0,c=0,l=0;l<a;l++){var s=e.slice(c,c+w);r>0&&(s=K(s,n.reversalBuffers));for(var h=me.transform(s,n.mdctBuffers),y=h.length/4,d=0;d<w;d++)i[f+d]=h[y+d];var b=Se(u.slice(0,S),i.slice(f,f+S),v);t.set(b,f);for(var p=0;p<S;p++)u[p]=i[f+S+p];f+=w,c+=w}for(var m=0;m<S;m++)t[2*o.size-S+m]=i[o.size-S+m];return t.slice(0,o.size)}(e,r,n,a,i)}return function(e){var r=e.coefficients,o=e.blockModes;return m.map(function(e,i){var u=function(e,r){var t=[0,128,256,512];return e.subarray(t[r],t[r+1])}(r,i);return a(u,i,o[i],n[i],t,e)})}}function Ge(e){var r,t=null!==(r=null==e?void 0:e.bufferPool)&&void 0!==r?r:$("qmfSynthesisStage: bufferPool is required"),n=t.qmfDelays;return function(e){var r=t.qmfWorkBuffers.highBandDelay[e[2].length];r.set(n.highBand),r.set(e[2],n.highBand.length);var o=r.slice(0,2*e[0].length);n.highBand=r.slice(2*e[0].length);var a=X(e[0],e[1],n.midBand,t.qmfWorkBuffers);n.midBand=a.newDelay;var i=X(a.output,o,n.lowBand,t.qmfWorkBuffers);return n.lowBand=i.newDelay,i.output}}function Ne(){return J({bufferPool:arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ze},Le,We,Ge)}function Ve(e){return Ve="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ve(e)}function Re(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=Qe(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,u=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function $e(e,r,t,n,o,a,i){try{var u=e[a](i),f=u.value}catch(e){return void t(e)}u.done?r(f):Promise.resolve(f).then(n,o)}function Je(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){$e(a,n,o,i,u,"next",e)}function u(e){$e(a,n,o,i,u,"throw",e)}i(void 0)})}}function Ke(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,u=[],f=!0,c=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=a.call(t)).done)&&(u.push(n.value),u.length!==r);f=!0);}catch(e){c=!0,o=e}finally{try{if(!f&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(c)throw o}}return u}}(e,r)||Qe(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qe(e,r){if(e){if("string"==typeof e)return Xe(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Xe(e,r):void 0}}function Xe(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function Ye(e){if(null!=e){var r=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],t=0;if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&t>=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}}}throw new TypeError(Ve(e)+" is not iterable")}function Ze(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,r,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function a(t,n,o,a){var f=n&&n.prototype instanceof u?n:u,c=Object.create(f.prototype);return er(c,"_invoke",function(t,n,o){var a,u,f,c=0,l=o||[],s=!1,v={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(r,t){return a=r,u=0,f=e,v.n=t,i}};function h(t,n){for(u=t,f=n,r=0;!s&&c&&!o&&r<l.length;r++){var o,a=l[r],h=v.p,y=a[2];t>3?(o=y===n)&&(f=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=e):a[0]<=h&&((o=t<2&&h<a[1])?(u=0,v.v=n,v.n=a[1]):h<y&&(o=t<3||a[0]>n||n>y)&&(a[4]=t,a[5]=n,v.n=y,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,l,y){if(c>1)throw TypeError("Generator is already running");for(s&&1===l&&h(l,y),u=l,f=y;(r=u<2?e:f)||!s;){a||(u?u<3?(u>1&&(v.n=-1),h(u,f)):v.n=f:v.v=f);try{if(c=2,a){if(u||(o="next"),r=a[o]){if(!(r=r.call(a,f)))throw TypeError("iterator result is not an object");if(!r.done)return r;f=r.value,u<2&&(u=0)}else 1===u&&(r=a.return)&&r.call(a),u<2&&(f=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=e}else if((r=(s=v.n<0)?f:t.call(n,v))!==i)break}catch(r){a=e,u=1,f=r}finally{c=1}}return{value:r,done:s}}}(t,o,a),!0),c}var i={};function u(){}function f(){}function c(){}r=Object.getPrototypeOf;var l=[][n]?r(r([][n]())):(er(r={},n,function(){return this}),r),s=c.prototype=u.prototype=Object.create(l);function v(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,er(e,o,"GeneratorFunction")),e.prototype=Object.create(s),e}return f.prototype=c,er(s,"constructor",c),er(c,"constructor",f),f.displayName="GeneratorFunction",er(c,o,"GeneratorFunction"),er(s),er(s,o,"Generator"),er(s,n,function(){return this}),er(s,"toString",function(){return"[object Generator]"}),(Ze=function(){return{w:a,m:v}})()}function er(e,r,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}er=function(e,r,t,n){if(r)o?o(e,r,{value:t,enumerable:!n,configurable:!n,writable:!n}):e[r]=t;else{var a=function(r,t){er(e,r,function(e){return this._invoke(r,t,e)})};a("next",0),a("throw",1),a("return",2)}},er(e,r,t,n)}function rr(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,tr(n.key),n)}}function tr(e){var r=function(e,r){if("object"!=Ve(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=Ve(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==Ve(r)?r:r+""}function nr(e){return function(){return new or(e.apply(this,arguments))}}function or(e){var r,t;function n(r,t){try{var a=e[r](t),i=a.value,u=i instanceof ur;Promise.resolve(u?i.v:i).then(function(t){if(u){var f="return"===r?"return":"next";if(!i.k||t.done)return n(f,t);t=e[f](t).value}o(a.done?"return":"normal",t)},function(e){n("throw",e)})}catch(e){o("throw",e)}}function o(e,o){switch(e){case"return":r.resolve({value:o,done:!0});break;case"throw":r.reject(o);break;default:r.resolve({value:o,done:!1})}(r=r.next)?n(r.key,r.arg):t=null}this._invoke=function(e,o){return new Promise(function(a,i){var u={key:e,arg:o,resolve:a,reject:i,next:null};t?t=t.next=u:(r=t=u,n(e,o))})},"function"!=typeof e.return&&(this.return=void 0)}function ar(e){return new ur(e,0)}function ir(e){var r={},t=!1;function n(r,n){return t=!0,n=new Promise(function(t){t(e[r](n))}),{done:!1,value:new ur(n,1)}}return r["undefined"!=typeof Symbol&&Symbol.iterator||"@@iterator"]=function(){return this},r.next=function(e){return t?(t=!1,e):n("next",e)},"function"==typeof e.throw&&(r.throw=function(e){if(t)throw t=!1,e;return n("throw",e)}),"function"==typeof e.return&&(r.return=function(e){return t?(t=!1,e):n("return",e)}),r}function ur(e,r){this.v=e,this.k=r}function fr(e){var r,t,n,o=2;for("undefined"!=typeof Symbol&&(t=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(t&&null!=(r=e[t]))return r.call(e);if(n&&null!=(r=e[n]))return new cr(r.call(e));t="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function cr(e){function r(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var r=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:r}})}return cr=function(e){this.s=e,this.n=e.next},cr.prototype={s:null,n:null,next:function(){return r(this.n.apply(this.s,arguments))},return:function(e){var t=this.s.return;return void 0===t?Promise.resolve({value:e,done:!0}):r(t.apply(this.s,arguments))},throw:function(e){var t=this.s.return;return void 0===t?Promise.reject(e):r(t.apply(this.s,arguments))}},new cr(e)}or.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},or.prototype.next=function(e){return this._invoke("next",e)},or.prototype.throw=function(e){return this._invoke("throw",e)},or.prototype.return=function(e){return this._invoke("return",e)};var lr=function(){function e(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e)}return t=e,a=null,i=[{key:"encodeStream",value:function(r){return nr(function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Ze().m(function n(){var o,a,i,u;return Ze().w(function(n){for(;;)switch(n.n){case 0:if(o=t.channelCount,a=void 0===o?1:o,i=t.onProgress,u=t.encoderOptions,1!==a){n.n=2;break}return n.d(Ye(ir(fr(e._encodeMonoStream(r,i,u)))),1);case 1:case 3:n.n=5;break;case 2:if(2!==a){n.n=4;break}return n.d(Ye(ir(fr(e._encodeStereoStream(r,i,u)))),3);case 4:throw new Error("Unsupported channel count: ".concat(a));case 5:return n.a(2)}},n)})()}).apply(this,arguments)}},{key:"_encodeMonoStream",value:function(e,r,t){return nr(Ze().m(function n(){var o,a,i,u,f,c,l,s,v,h,y;return Ze().w(function(n){for(;;)switch(n.n){case 0:o=t||new R,a=He(o),i=0,u=!1,f=!1,n.p=1,l=fr(e);case 2:return n.n=3,ar(l.next());case 3:if(!(u=!(s=n.v).done)){n.n=6;break}return v=s.value,h=a(v),n.n=4,h;case 4:r&&r(i++);case 5:u=!1,n.n=2;break;case 6:n.n=8;break;case 7:n.p=7,y=n.v,f=!0,c=y;case 8:if(n.p=8,n.p=9,!u||null==l.return){n.n=10;break}return n.n=10,ar(l.return());case 10:if(n.p=10,!f){n.n=11;break}throw c;case 11:return n.f(10);case 12:return n.f(8);case 13:return n.a(2)}},n,null,[[9,,10,12],[1,7,8,13]])}))()}},{key:"_encodeStereoStream",value:function(e,r,t){return nr(Ze().m(function n(){var o,a,i,u,f,c,l,s,v,h,y,d,b,p,m;return Ze().w(function(n){for(;;)switch(n.n){case 0:o=t||new R,a=He(o),i=He(o),u=0,f=!1,c=!1,n.p=1,s=fr(e);case 2:return n.n=3,ar(s.next());case 3:if(!(f=!(v=n.v).done)){n.n=7;break}return h=Ke(v.value,2),y=h[0],d=h[1],b=a(y),p=i(d),n.n=4,b;case 4:return n.n=5,p;case 5:r&&r(u++);case 6:f=!1,n.n=2;break;case 7:n.n=9;break;case 8:n.p=8,m=n.v,c=!0,l=m;case 9:if(n.p=9,n.p=10,!f||null==s.return){n.n=11;break}return n.n=11,ar(s.return());case 11:if(n.p=11,!c){n.n=12;break}throw l;case 12:return n.f(11);case 13:return n.f(9);case 14:return n.a(2)}},n,null,[[10,,11,13],[1,8,9,14]])}))()}},{key:"decodeStream",value:function(r){return nr(function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Ze().m(function n(){var o,a,i;return Ze().w(function(n){for(;;)switch(n.n){case 0:if(o=t.channelCount,a=void 0===o?1:o,i=t.onProgress,1!==a){n.n=2;break}return n.d(Ye(ir(fr(e._decodeMonoStream(r,i)))),1);case 1:case 3:n.n=5;break;case 2:if(2!==a){n.n=4;break}return n.d(Ye(ir(fr(e._decodeStereoStream(r,i)))),3);case 4:throw new Error("Unsupported channel count: ".concat(a));case 5:return n.a(2)}},n)})()}).apply(this,arguments)}},{key:"_decodeMonoStream",value:function(e,r){return nr(Ze().m(function t(){var n,o,a;return Ze().w(function(t){for(;;)switch(t.n){case 0:return n=Ne(),o=0,a=function(){var t=nr(Ze().m(function t(){var a,i,u,f,c,l,s,v;return Ze().w(function(t){for(;;)switch(t.n){case 0:a=!1,i=!1,t.p=1,f=fr(e);case 2:return t.n=3,ar(f.next());case 3:if(!(a=!(c=t.v).done)){t.n=6;break}return l=c.value,s=n(l),t.n=4,s;case 4:r&&r(o++);case 5:a=!1,t.n=2;break;case 6:t.n=8;break;case 7:t.p=7,v=t.v,i=!0,u=v;case 8:if(t.p=8,t.p=9,!a||null==f.return){t.n=10;break}return t.n=10,ar(f.return());case 10:if(t.p=10,!i){t.n=11;break}throw u;case 11:return t.f(10);case 12:return t.f(8);case 13:return t.a(2)}},t,null,[[9,,10,12],[1,7,8,13]])}));return function(){return t.apply(this,arguments)}}(),t.d(Ye(ir(fr(a()))),1);case 1:return t.a(2)}},t)}))()}},{key:"_decodeStereoStream",value:function(r,t){return nr(Ze().m(function n(){var o,a,i,u;return Ze().w(function(n){for(;;)switch(n.n){case 0:return o=Ne(),a=Ne(),i=0,u=function(){var n=nr(Ze().m(function n(){var u,f,c,l,s,v,h,y,d,b,p,m,w,g,S;return Ze().w(function(n){for(;;)switch(n.n){case 0:u=null,f=!0,c=!1,l=!1,n.p=1,v=fr(r);case 2:return n.n=3,ar(v.next());case 3:if(!(c=!(h=n.v).done)){n.n=8;break}if(y=h.value,!f){n.n=4;break}u=y,n.n=6;break;case 4:return d=y,b=o(u),p=a(d),n.n=5,[b,p];case 5:t&&t(i++);case 6:f=!f;case 7:c=!1,n.n=2;break;case 8:n.n=10;break;case 9:n.p=9,S=n.v,l=!0,s=S;case 10:if(n.p=10,n.p=11,!c||null==v.return){n.n=12;break}return n.n=12,ar(v.return());case 12:if(n.p=12,!l){n.n=13;break}throw s;case 13:return n.f(12);case 14:return n.f(10);case 15:if(f||!u){n.n=17;break}return m=e._createDummyFrame(),w=o(u),g=a(m),n.n=16,[w,g];case 16:t&&t(i++);case 17:return n.a(2)}},n,null,[[11,,12,14],[1,9,10,15]])}));return function(){return n.apply(this,arguments)}}(),n.d(Ye(ir(fr(u()))),1);case 1:return n.a(2)}},n)}))()}},{key:"frameBufferToFrames",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:512;return Ze().m(function t(){var n,o,a,i,u,f,c,l,s,v,h,y,d,b,p,m;return Ze().w(function(t){for(;;)switch(t.n){case 0:if(1!==(n=e.length)){t.n=4;break}o=Ke(e,1),a=o[0],i=0;case 1:if(!(i<a.length)){t.n=3;break}for(u=new Float32Array(r),f=Math.min(i+r,a.length),c=0;c<f-i;c++)u[c]=a[i+c];return t.n=2,u;case 2:i+=r,t.n=1;break;case 3:t.n=9;break;case 4:if(2!==n){t.n=8;break}l=Ke(e,2),s=l[0],v=l[1],h=Math.max(s.length,v.length),y=0;case 5:if(!(y<h)){t.n=7;break}for(d=new Float32Array(r),b=new Float32Array(r),p=Math.min(y+r,h),m=0;m<p-y;m++)d[m]=y+m<s.length?s[y+m]:0,b[m]=y+m<v.length?v[y+m]:0;return t.n=6,[d,b];case 6:y+=r,t.n=5;break;case 7:t.n=9;break;case 8:throw new Error("Unsupported channel count: ".concat(n));case 9:return t.a(2)}},t)})()}},{key:"collectFrames",value:(c=Je(Ze().m(function e(r){var t,n,o,a,i,u,f,c;return Ze().w(function(e){for(;;)switch(e.n){case 0:t=[],n=!1,o=!1,e.p=1,i=fr(r);case 2:return e.n=3,i.next();case 3:if(!(n=!(u=e.v).done)){e.n=5;break}f=u.value,t.push(f);case 4:n=!1,e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,c=e.v,o=!0,a=c;case 7:if(e.p=7,e.p=8,!n||null==i.return){e.n=9;break}return e.n=9,i.return();case 9:if(e.p=9,!o){e.n=10;break}throw a;case 10:return e.f(9);case 11:return e.f(7);case 12:return e.a(2,t)}},e,null,[[8,,9,11],[1,6,7,12]])})),function(e){return c.apply(this,arguments)})},{key:"_createDummyFrame",value:function(){return{nBfu:0,blockModes:[0,0,0],scaleFactorIndices:new Int32Array(0),wordLengthIndices:new Int32Array(0),quantizedCoefficients:[]}}},{key:"createAeaBlob",value:(f=Je(Ze().m(function e(r){var t,n,o,a,i,u,f,c,l,s,v,h,y,d,b,p,m,w,g,S,k=arguments;return Ze().w(function(e){for(;;)switch(e.n){case 0:n=(t=k.length>1&&void 0!==k[1]?k[1]:{}).title,o=void 0===n?"encoded by atrac1.js":n,a=t.channelCount,i=void 0===a?1:a,u=[],f=!1,c=!1,e.p=1,s=fr(r);case 2:return e.n=3,s.next();case 3:if(!(f=!(v=e.v).done)){e.n=5;break}h=v.value,u.push(x(h));case 4:f=!1,e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,S=e.v,c=!0,l=S;case 7:if(e.p=7,e.p=8,!f||null==s.return){e.n=9;break}return e.n=9,s.return();case 9:if(e.p=9,!c){e.n=10;break}throw l;case 10:return e.f(9);case 11:return e.f(7);case 12:for(y=_.createHeader(o,u.length,i),d=y.length+u.reduce(function(e,r){return e+r.length},0),(b=new Uint8Array(d)).set(y,0),p=y.length,m=0,w=u;m<w.length;m++)g=w[m],b.set(g,p),p+=g.length;return e.a(2,new Blob([b],{type:"application/octet-stream"}))}},e,null,[[8,,9,11],[1,6,7,12]])})),function(e){return f.apply(this,arguments)})},{key:"createWavBlob",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r,a=Array.isArray(t)?t:[t];if(1===n)return e._createMonoWavBlob(a,o);if(2===n)return e._createStereoWavBlob(a,o);throw new Error("Unsupported channel count: ".concat(n))}},{key:"_createMonoWavBlob",value:function(r,t){var n=r.reduce(function(e,r){return e+r.length},0),o=new ArrayBuffer(44+2*n),a=new DataView(o);e._writeWavHeader(a,n,1,t);var i,u=44,f=Re(r);try{for(f.s();!(i=f.n()).done;)for(var c=i.value,l=0;l<c.length;l++){var s=Math.max(-1,Math.min(1,c[l]));a.setInt16(u,s<0?s*A:s*k,!0),u+=2}}catch(e){f.e(e)}finally{f.f()}return new Blob([o],{type:"audio/wav"})}},{key:"_createStereoWavBlob",value:function(r,t){var n=r.reduce(function(e,r){var t=Ke(r,2),n=t[0],o=t[1];return e+Math.max(n.length,o.length)},0),o=new ArrayBuffer(44+2*n*2),a=new DataView(o);e._writeWavHeader(a,n,2,t);var i,u=44,f=Re(r);try{for(f.s();!(i=f.n()).done;)for(var c=Ke(i.value,2),l=c[0],s=c[1],v=Math.max(l.length,s.length),h=0;h<v;h++){var y=h<l.length?l[h]:0,d=h<s.length?s[h]:0,b=Math.max(-1,Math.min(1,y)),p=Math.max(-1,Math.min(1,d));a.setInt16(u,b<0?b*A:b*k,!0),u+=2,a.setInt16(u,p<0?p*A:p*k,!0),u+=2}}catch(e){f.e(e)}finally{f.f()}return new Blob([o],{type:"audio/wav"})}},{key:"_writeWavHeader",value:function(e,r,t,n){var o=n*t*2,a=2*t,i=r*a,u=36+i,f=0,c=function(r,t){for(var n=0;n<t.length;n++)e.setUint8(r+n,t.charCodeAt(n))};c(f,"RIFF"),f+=4,e.setUint32(f,u,!0),c(f+=4,"WAVE"),c(f+=4,"fmt "),f+=4,e.setUint32(f,16,!0),f+=4,e.setUint16(f,1,!0),f+=2,e.setUint16(f,t,!0),f+=2,e.setUint32(f,n,!0),f+=4,e.setUint32(f,o,!0),f+=4,e.setUint16(f,a,!0),f+=2,e.setUint16(f,16,!0),c(f+=2,"data"),f+=4,e.setUint32(f,i,!0)}},{key:"parseAeaBlob",value:(u=Je(Ze().m(function e(r){var t,a,i,u,f,c;return Ze().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,r.arrayBuffer();case 1:for(t=e.v,a=new Uint8Array(t.slice(0,n)),i=_.parseHeader(a),u=[],f=n;f<t.byteLength;f+=o)(c=new Uint8Array(t.slice(f,f+o))).length===o&&u.push(c);return e.a(2,{info:i,frameData:u})}},e)})),function(e){return u.apply(this,arguments)})},{key:"deserializedFrameStream",value:Ze().m(function e(r){var t,n,o,a;return Ze().w(function(e){for(;;)switch(e.n){case 0:t=Re(r),e.p=1,t.s();case 2:if((n=t.n()).done){e.n=4;break}return o=n.value,e.n=3,E(o);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,a=e.v,t.e(a);case 6:return e.p=6,t.f(),e.f(6);case 7:return e.a(2)}},e,null,[[1,5,6,7]])})},{key:"assemblePcmFrames",value:function(e,r){if(1===r){var t,n=e.reduce(function(e,r){return e+r.length},0),o=new Float32Array(n),a=0,i=Re(e);try{for(i.s();!(t=i.n()).done;){var u=t.value;o.set(u,a),a+=u.length}}catch(e){i.e(e)}finally{i.f()}return o}if(2===r){var f,c=e.reduce(function(e,r){var t=Ke(r,2),n=t[0],o=t[1];return e+Math.max(n.length,o.length)},0),l=new Float32Array(2*c),s=0,v=Re(e);try{for(v.s();!(f=v.n()).done;)for(var h=Ke(f.value,2),y=h[0],d=h[1],b=Math.max(y.length,d.length),p=0;p<b;p++)l[2*s]=p<y.length?y[p]:0,l[2*s+1]=p<d.length?d[p]:0,s++}catch(e){v.e(e)}finally{v.f()}return l}throw new Error("Unsupported channel count: ".concat(r))}}],a&&rr(t.prototype,a),i&&rr(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,a,i,u,f,c}();function sr(e){return sr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},sr(e)}function vr(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function hr(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?vr(Object(t),!0).forEach(function(r){yr(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):vr(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function yr(e,r,t){return(r=function(e){var r=function(e,r){if("object"!=sr(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=sr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==sr(r)?r:r+""}(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function dr(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,r,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function a(t,n,o,a){var f=n&&n.prototype instanceof u?n:u,c=Object.create(f.prototype);return br(c,"_invoke",function(t,n,o){var a,u,f,c=0,l=o||[],s=!1,v={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(r,t){return a=r,u=0,f=e,v.n=t,i}};function h(t,n){for(u=t,f=n,r=0;!s&&c&&!o&&r<l.length;r++){var o,a=l[r],h=v.p,y=a[2];t>3?(o=y===n)&&(f=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=e):a[0]<=h&&((o=t<2&&h<a[1])?(u=0,v.v=n,v.n=a[1]):h<y&&(o=t<3||a[0]>n||n>y)&&(a[4]=t,a[5]=n,v.n=y,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,l,y){if(c>1)throw TypeError("Generator is already running");for(s&&1===l&&h(l,y),u=l,f=y;(r=u<2?e:f)||!s;){a||(u?u<3?(u>1&&(v.n=-1),h(u,f)):v.n=f:v.v=f);try{if(c=2,a){if(u||(o="next"),r=a[o]){if(!(r=r.call(a,f)))throw TypeError("iterator result is not an object");if(!r.done)return r;f=r.value,u<2&&(u=0)}else 1===u&&(r=a.return)&&r.call(a),u<2&&(f=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=e}else if((r=(s=v.n<0)?f:t.call(n,v))!==i)break}catch(r){a=e,u=1,f=r}finally{c=1}}return{value:r,done:s}}}(t,o,a),!0),c}var i={};function u(){}function f(){}function c(){}r=Object.getPrototypeOf;var l=[][n]?r(r([][n]())):(br(r={},n,function(){return this}),r),s=c.prototype=u.prototype=Object.create(l);function v(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,br(e,o,"GeneratorFunction")),e.prototype=Object.create(s),e}return f.prototype=c,br(s,"constructor",c),br(c,"constructor",f),f.displayName="GeneratorFunction",br(c,o,"GeneratorFunction"),br(s),br(s,o,"Generator"),br(s,n,function(){return this}),br(s,"toString",function(){return"[object Generator]"}),(dr=function(){return{w:a,m:v}})()}function br(e,r,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}br=function(e,r,t,n){if(r)o?o(e,r,{value:t,enumerable:!n,configurable:!n,writable:!n}):e[r]=t;else{var a=function(r,t){br(e,r,function(e){return this._invoke(r,t,e)})};a("next",0),a("throw",1),a("return",2)}},br(e,r,t,n)}function pr(e,r,t,n,o,a,i){try{var u=e[a](i),f=u.value}catch(e){return void t(e)}u.done?r(f):Promise.resolve(f).then(n,o)}function mr(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){pr(a,n,o,i,u,"next",e)}function u(e){pr(a,n,o,i,u,"throw",e)}i(void 0)})}}function wr(e,r,t){return gr.apply(this,arguments)}function gr(){return(gr=mr(dr().m(function e(r,t,n){var o,a,i,u,f,c,l;return dr().w(function(e){for(;;)switch(e.n){case 0:return n=null!=n?n:"encoded by carta1",e.p=1,o=lr.frameBufferToFrames(r),a=r.length,i=new R(t),u=lr.encodeStream(o,{channelCount:a,encoderOptions:i}),e.n=2,lr.collectFrames(u);case 2:return f=e.v,e.n=3,lr.createAeaBlob(f,{title:n,channelCount:a});case 3:return c=e.v,e.a(2,{aeaBlob:c});case 4:throw e.p=4,l=e.v,console.error("Worker encode error:",l),l;case 5:return e.a(2)}},e,null,[[1,4]])}))).apply(this,arguments)}function Sr(){return(new R).toObject()}function kr(e){return Ar.apply(this,arguments)}function Ar(){return(Ar=mr(dr().m(function e(t){var n,o,a,i,u,f,c,l,s;return dr().w(function(e){for(;;)switch(e.n){case 0:return n=t.header,o=t.aeaData,(a=t.info)?i=hr({sampleRate:r},a):n?(u=_.parseHeader(n),i=hr({sampleRate:r},u)):i={channelCount:2,sampleRate:r},f=lr.deserializedFrameStream(o),c=lr.decodeStream(f,{channelCount:i.channelCount}),e.n=1,lr.collectFrames(c);case 1:return l=e.v,s=lr.createWavBlob(l,i.channelCount,i.sampleRate),e.a(2,{wavBlob:s,info:i})}},e)}))).apply(this,arguments)}self.onmessage=function(){var e=mr(dr().m(function e(r){var t,n,o,a,i,u,f,c,l,s,v;return dr().w(function(e){for(;;)switch(e.n){case 0:t=r.data,n=t.jobId,o=t.type,a=t.pcmData,i=t.aea,u=t.options,f=t.title,c=t.blob,e.p=1,s=o,e.n="encode"===s?2:"decode"===s?4:"parseAea"===s?6:"getEncoderOptions"===s?8:9;break;case 2:return e.n=3,wr(a,u,f);case 3:return l=e.v,e.a(3,10);case 4:return e.n=5,kr(i);case 5:return l=e.v,e.a(3,10);case 6:return e.n=7,lr.parseAeaBlob(c);case 7:return l=e.v,e.a(3,10);case 8:return l=Sr(),e.a(3,10);case 9:throw new Error("Unknown worker message type: ".concat(o));case 10:self.postMessage({jobId:n,result:l}),e.n=12;break;case 11:e.p=11,v=e.v,console.error("Worker error:",v),self.postMessage({jobId:n,error:v.message});case 12:return e.a(2)}},e,null,[[1,11]])}));return function(r){return e.apply(this,arguments)}}();var Or=self;for(var jr in e)Or[jr]=e[jr];e.__esModule&&Object.defineProperty(Or,"__esModule",{value:!0});
|
|
1
|
+
var e={},r=44100,t=new Uint8Array([0,8,0,0]),n=2048,o=212,a=new Int32Array([8,8,8,8,4,4,4,4,8,8,8,8,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,9,9,9,9,10,10,10,10,12,12,12,12,12,12,12,12,20,20,20,20,20,20,20,20]),i=new Int32Array([20,28,32,36,40,44,48,52]),u=new Int32Array([20,36,52]),f=new Int32Array([0,8,16,24,32,36,40,44,48,56,64,72,80,86,92,98,104,110,116,122,128,134,140,146,152,159,166,173,180,189,198,207,216,226,236,246,256,268,280,292,304,316,328,340,352,372,392,412,432,452,472,492]),c=new Int32Array([0,32,64,96,8,40,72,104,12,44,76,108,20,52,84,116,26,58,90,122,128,160,192,224,134,166,198,230,141,173,205,237,150,182,214,246,256,288,320,352,384,416,448,480,268,300,332,364,396,428,460,492]),l=256,s=512,v=function(){for(var e=new Float64Array(32),r=0;r<32;r++)e[r]=Math.sin((r+.5)*Math.PI/64);return e}(),h=46,y=new Float32Array([-1461907e-11,-9205479e-11,-56157569e-12,.00030117269,.0002422519,-.00085293897,-.0005205574,.0020340169,.00078333891,-.0042153862,-.00075614988,.0078402944,-61169922e-12,-.01344162,.0024626821,.021736089,-.007801671,-.034090221,.01880949,.054326009,-.043596379,-.099384367,.13207909,.46424159]),d=function(){for(var e=new Float32Array(48),r=0;r<24;r++)e[r]=2*y[r],e[47-r]=2*y[r];return e}(),b=function(){for(var e=new Float32Array(24),r=0;r<24;r++)e[r]=d[2*r];return e}(),p=function(){for(var e=new Float32Array(24),r=0;r<24;r++)e[r]=d[2*r+1];return e}(),m=[{size:128,windowStart:48},{size:128,windowStart:48},{size:256,windowStart:112}],w=32,g=32,k=16,S=32767,A=32768,O=new Int32Array([0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),M=function(){for(var e=new Float64Array(64),r=0;r<64;r++)e[r]=Math.pow(2,r/3-21);return e}(),B=function(){for(var e=O[15],r=new Float64Array(e+1),t=0;t<=e;t++)r[t]=Math.pow(2,-t);return r}();function j(e,r,t,n){if(0!==n){var o=Math.floor(r/8),a=r%8;t&=(1<<n)-1;for(var i=0;i<n&&o<e.length;){var u=8-a,f=Math.min(n-i,u),c=t>>n-i-f&(1<<f)-1,l=(1<<f)-1<<u-f;e[o]=e[o]&~l|c<<u-f,i+=f,o++,a=0}}}function F(e,r,t){if(0===t)return 0;for(var n=Math.floor(r/8),o=r%8,a=0,i=0;i<t&&n<e.length;){var u=8-o,f=Math.min(t-i,u),c=(1<<f)-1;a=a<<f|e[n]>>u-f&c,i+=f,n++,o=0}return a}function P(e,r,t){var n=F(e,r,t);return n>=1<<t-1?n-(1<<t):n}function T(e){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},T(e)}function C(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,x(n.key),n)}}function x(e){var r=function(e,r){if("object"!=T(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=T(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==T(r)?r:r+""}function z(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return I(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?I(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,u=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function I(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function q(e){var r=new Uint8Array(o),t=new DataView(r.buffer),n=i.indexOf(e.nBfu),a=2-e.blockModes[0]<<14|2-e.blockModes[1]<<12|3-e.blockModes[2]<<10|n<<5;t.setUint16(0,a,!1);for(var u=16,f=0;f<e.nBfu;f++)j(r,u,e.wordLengthIndices[f],4),u+=4;for(var c=0;c<e.nBfu;c++)j(r,u,e.scaleFactorIndices[c],6),u+=6;for(var l=0;l<e.nBfu;l++){var s=O[e.wordLengthIndices[l]];if(s>0){var v,h=z(e.quantizedCoefficients[l]);try{for(h.s();!(v=h.n()).done;){var y=v.value;j(r,u,y<0?y+(1<<s):y,s),u+=s}}catch(e){h.e(e)}finally{h.f()}}}return r[209]=0,r[210]=0,r[211]=0,r}function E(e){if(e.length!==o)throw new Error("Frame must be ".concat(o," bytes"));for(var r=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,!1),t=[2-(r>>14&3),2-(r>>12&3),3-(r>>10&3)],n=i[r>>5&7],u=16,f=new Int32Array(n),c=0;c<n;c++)f[c]=F(e,u,4),u+=4;for(var l=new Int32Array(n),s=0;s<n;s++)l[s]=F(e,u,6),u+=6;for(var v=[],h=0;h<n;h++){var y=O[f[h]],d=a[h],b=new Int32Array(d);if(y>0)for(var p=0;p<d;p++)b[p]=P(e,u,y),u+=y;v.push(b)}return{nBfu:n,scaleFactorIndices:l,wordLengthIndices:f,quantizedCoefficients:v,blockModes:t}}var _=function(){return e=function e(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e)},o=[{key:"createHeader",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=new Uint8Array(n),i=new DataView(a.buffer);a.set(t,0);var u=(new TextEncoder).encode(e);return a.set(u.subarray(0,Math.min(u.length,255)),4),i.setUint32(260,r,!0),a[264]=o,a}},{key:"parseHeader",value:function(e){if(e.length!==n)throw new Error("Header must be ".concat(n," bytes"));for(var r=0;r<t.length;r++)if(e[r]!==t[r])throw new Error("Invalid AEA file");var o=new DataView(e.buffer,e.byteOffset,e.byteLength),a=e.indexOf(0,4),i=-1===a?256:a-4;return{title:(new TextDecoder).decode(e.subarray(4,4+i)),frameCount:o.getUint32(260,!0),channelCount:e[264]}}}],(r=null)&&C(e.prototype,r),o&&C(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,o}();function D(e){return D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},D(e)}function U(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function H(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?U(Object(t),!0).forEach(function(r){W(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):U(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function W(e,r,t){return(r=V(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function L(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,u=[],f=!0,c=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=a.call(t)).done)&&(u.push(n.value),u.length!==r);f=!0);}catch(e){c=!0,o=e}finally{try{if(!f&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(c)throw o}}return u}}(e,r)||function(e,r){if(e){if("string"==typeof e)return G(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?G(e,r):void 0}}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function G(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function N(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,V(n.key),n)}}function V(e){var r=function(e,r){if("object"!=D(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=D(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==D(r)?r:r+""}var R=function(){return e=function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.values={transientThresholdLow:1,transientThresholdMid:1.5,transientThresholdHigh:2,allocationBias:1,fixedBlockModes:null},this.metadata={transientThresholdLow:{default:this.values.transientThresholdLow,name:"Low Band Transient Threshold",description:"Controls the transient detection threshold for the low frequency band (0-5.5kHz). Lower values make detection more sensitive, triggering short blocks more easily. Higher values require stronger transients.",range:[.01,2],step:.01},transientThresholdMid:{default:this.values.transientThresholdMid,name:"Mid Band Transient Threshold",description:"Controls the transient detection threshold for the mid frequency band (5.5-11kHz). Lower values make detection more sensitive, triggering short blocks more easily. Higher values require stronger transients.",range:[.01,3],step:.01},transientThresholdHigh:{default:this.values.transientThresholdHigh,name:"High Band Transient Threshold",description:"Controls the transient detection threshold for the high frequency band (11-22kHz). Lower values make detection more sensitive, triggering short blocks more easily. Higher values require stronger transients.",range:[.01,4],step:.01},allocationBias:{default:this.values.allocationBias,name:"Bit allocation bias",description:"Controls how bits are distributed across the frequency spectrum during allocation. Higher values focus more bits on loud spectral components, while lower values spread bits more evenly across frequencies.",range:[.5,3],step:.01},fixedBlockModes:{default:this.values.fixedBlockModes,name:"Fixed block modes",description:"Override transient detection and use fixed block modes. Format: [low, mid, high] where low/mid can be 0 or 2, high can be 0 or 3. When set, transient detection is skipped.",type:"array"}},r&&this.setOptions(r)},(r=[{key:"setOptions",value:function(e){for(var r=0,t=Object.entries(e);r<t.length;r++){var n=L(t[r],2),o=n[0],a=n[1];o in this.values&&this.setValue(o,a)}}},{key:"setValue",value:function(e,r){if(!(e in this.metadata))throw new Error("Unknown option: ".concat(e));var t=this.metadata[e];if("array"!==t.type){var n=L(t.range,2),o=n[0],a=n[1];if(r<o||r>a)throw new Error("Value for ".concat(e," must be between ").concat(o," and ").concat(a,", got ").concat(r))}this.values[e]=r}},{key:"getValue",value:function(e){if(!(e in this.values))throw new Error("Unknown option: ".concat(e));return this.values[e]}},{key:"transientThresholdLow",get:function(){return this.values.transientThresholdLow}},{key:"transientThresholdMid",get:function(){return this.values.transientThresholdMid}},{key:"transientThresholdHigh",get:function(){return this.values.transientThresholdHigh}},{key:"allocationBias",get:function(){return this.values.allocationBias}},{key:"fixedBlockModes",get:function(){return this.values.fixedBlockModes}},{key:"getMetadata",value:function(e){return this.metadata[e]}},{key:"getAllMetadata",value:function(){return H({},this.metadata)}},{key:"reset",value:function(){for(var e=0,r=Object.entries(this.metadata);e<r.length;e++){var t=L(r[e],2),n=t[0],o=t[1];this.values[n]=o.default}}},{key:"toObject",value:function(){return{values:H({},this.values),metadata:H({},this.metadata)}}}])&&N(e.prototype,r),t&&N(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,t}();function $(e){throw new Error(e)}function J(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];var o=t.map(function(r){return r(e)});return function(e){return o.reduce(function(e,r){return r(e)},e)}}function K(e,r){for(var t=r[e.length],n=0;n<e.length;n++)t[n]=e[e.length-1-n];return t}function Q(e,r){var t,n,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=e.length,i=a>>1,u=null!==(t=null==o||null===(n=o.delay)||void 0===n?void 0:n[a])&&void 0!==t?t:$("qmfAnalysis: qmfWorkBuffers.delay[".concat(a,"] is required"));u.set(r),u.set(e,r.length);for(var f=new Float32Array(i),c=new Float32Array(i),l=0;l<i;l++){for(var s=0,v=0,h=2*l,y=0;y<24;y++)s+=u[h+47-2*y]*b[y],v+=u[h+46-2*y]*p[y];f[l]=s+v,c[l]=s-v}return{lowBand:f,highBand:c,newDelay:u.slice(-46)}}function X(e,r,t){var n,o,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=e.length,u=2*i,f=null!==(n=null==a||null===(o=a.delay)||void 0===o?void 0:o[u])&&void 0!==n?n:$("qmfSynthesis: qmfWorkBuffers.delay[".concat(u,"] is required"));f.set(t);for(var c=0;c<i;c++){var l=e[c],s=r[c],v=h+2*c;f[v]=.5*(l+s),f[v+1]=.5*(l-s)}for(var y=new Float32Array(u),d=0;d<i;d++){for(var m=2*d,w=0,g=0,k=0;k<24;k++){var S=m+2*k;w+=f[S]*b[k],g+=f[S+1]*p[k]}y[2*d]=g,y[2*d+1]=w}return{output:y,newDelay:f.slice(-46)}}function Y(e){return Y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Y(e)}function Z(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,ee(n.key),n)}}function ee(e){var r=function(e,r){if("object"!=Y(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=Y(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==Y(r)?r:r+""}var re=function(){return e=function e(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e)},t=[{key:"fft",value:function(e,r){var t=e.length;if(1!==t){for(var n=Math.log2(t),o=0;o<t;o++){for(var a=0,i=o,u=0;u<n;u++)a=a<<1|1&i,i>>=1;if(a>o){var f=[e[a],e[o]];e[o]=f[0],e[a]=f[1];var c=[r[a],r[o]];r[o]=c[0],r[a]=c[1]}}for(var l=2;l<=t;l<<=1)for(var s=l>>1,v=-2*Math.PI/l,h=Math.cos(v),y=Math.sin(v),d=0;d<t;d+=l)for(var b=1,p=0,m=0;m<s;m++){var w=d+m,g=w+s,k=e[w],S=r[w],A=e[g],O=r[g],M=A*b-O*p,B=A*p+O*b;e[w]=k+M,r[w]=S+B,e[g]=k-M,r[g]=S-B;var j=b*h-p*y;p=b*y+p*h,b=j}}}}],(r=null)&&Z(e.prototype,r),t&&Z(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,t}();function te(e){return te="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},te(e)}function ne(e,r,t){return r=ae(r),function(e,r){if(r&&("object"==te(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,oe()?Reflect.construct(r,t||[],ae(e).constructor):r.apply(e,t))}function oe(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(oe=function(){return!!e})()}function ae(e){return ae=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},ae(e)}function ie(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&ue(e,r)}function ue(e,r){return ue=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,r){return e.__proto__=r,e},ue(e,r)}function fe(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,le(n.key),n)}}function ce(e,r,t){return r&&fe(e.prototype,r),t&&fe(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function le(e){var r=function(e,r){if("object"!=te(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=te(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==te(r)?r:r+""}function se(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}var ve=ce(function e(r,t){se(this,e),this.size=r,this.halfSize=r>>1,this.quarterSize=r>>2,this.fftSize=this.halfSize>>1;var n=2*Math.PI/(8*r),o=2*Math.PI/r,a=Math.sqrt(t/r);this.sinCosTable=new Float64Array(this.halfSize);for(var i=0;i<this.quarterSize;i++){var u=o*i+n;this.sinCosTable[2*i]=a*Math.cos(u),this.sinCosTable[2*i+1]=a*Math.sin(u)}}),he=function(){function e(r,t){return se(this,e),ne(this,e,[r,t])}return ie(e,ve),ce(e,[{key:"transform",value:function(e){var r,t,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=null!==(r=null==o?void 0:o[this.fftSize])&&void 0!==r?r:$("MDCT.transform: mdctBuffers[".concat(this.fftSize,"] is required")),i=null!==(t=null==a?void 0:a.real)&&void 0!==t?t:$("MDCT.transform: mdctBuffers[".concat(this.fftSize,"].real is required")),u=null!==(n=null==a?void 0:a.imag)&&void 0!==n?n:$("MDCT.transform: mdctBuffers[".concat(this.fftSize,"].imag is required")),f=this.quarterSize,c=3*f;i.fill(0),u.fill(0);for(var l=0;l<f;l+=2){var s=c+l,v=f+l,h=f-1-l,y=e[c-1-l]+e[s],d=e[v]-e[h],b=this.sinCosTable[l],p=this.sinCosTable[l+1];i[l>>1]=y*b+d*p,u[l>>1]=d*b-y*p}for(var m=f;m<this.halfSize;m+=2){var w=m>>1,g=m-f,k=f+m,S=5*f-1-m,A=e[c-1-m]-e[g],O=e[k]+e[S],M=this.sinCosTable[m],B=this.sinCosTable[m+1];i[w]=A*M+O*B,u[w]=O*M-A*B}re.fft(i,u);for(var j=new Float32Array(this.halfSize),F=0;F<this.fftSize;F++){var P=this.sinCosTable[2*F],T=this.sinCosTable[2*F+1],C=i[F],x=u[F];j[2*F]=-C*P-x*T,j[this.halfSize-1-2*F]=-C*T+x*P}return j}}])}(),ye=function(){function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return se(this,e),ne(this,e,[r,t||r])}return ie(e,ve),ce(e,[{key:"transform",value:function(e){var r,t,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=null!==(r=null==o?void 0:o[this.fftSize])&&void 0!==r?r:$("IMDCT.transform: mdctBuffers[".concat(this.fftSize,"] is required")),i=null!==(t=null==a?void 0:a.real)&&void 0!==t?t:$("IMDCT.transform: mdctBuffers[".concat(this.fftSize,"].real is required")),u=null!==(n=null==a?void 0:a.imag)&&void 0!==n?n:$("IMDCT.transform: mdctBuffers[".concat(this.fftSize,"].imag is required")),f=this.quarterSize,c=3*f;i.fill(0),u.fill(0);for(var l=0;l<this.fftSize;l++){var s=2*l,v=-e[s],h=-e[this.halfSize-1-s],y=this.sinCosTable[s],d=this.sinCosTable[s+1];i[l]=h*d+v*y,u[l]=h*y-v*d}re.fft(i,u);for(var b=new Float32Array(this.size),p=0;p<this.fftSize/2;p++){var m=2*p,w=this.sinCosTable[m],g=this.sinCosTable[m+1],k=i[p],S=u[p],A=k*w+S*g,O=k*g-S*w;b[c-1-m]=A,b[c+m]=A,b[f+m]=O,b[f-1-m]=-O}for(var M=this.fftSize/2;M<this.fftSize;M++){var B=2*(M-this.fftSize/2)+f,j=2*M,F=this.sinCosTable[j],P=this.sinCosTable[j+1],T=i[M],C=u[M],x=T*F+C*P,z=T*P-C*F;b[c-1-B]=x,b[B-f]=-x,b[f+B]=z,b[5*f-1-B]=z}return b}}])}(),de=new he(64,.5),be=new he(l,.5),pe=new he(s,1),me=new ye(64,512),we=new ye(l,2048),ge=new ye(s,2048);function ke(e,r,t){for(var n=e.length,o=new Float32Array(2*n),a=0;a<n;a++){var i=t[a],u=t[2*n-1-a],f=e[a],c=r[n-1-a];o[a]=f*u-c*i,o[2*n-1-a]=f*i+c*u}return o}function Se(e,r,t){var n=e.length,o=new Int32Array(n);if(0===t||0===r)return o.fill(0,0,n),o;for(var a=(1<<t-1)-1,i=a/M[r],u=a,f=-a,c=0;c<n;c++){var l=e[c]*i,s=l+(l>=0?.5:-.5)|0;o[c]=s>u?u:s<f?f:s}return o}function Ae(e,r,t){if(0===t||0===r)return new Float32Array(e.length);for(var n=M[r],o=(1<<t-1)-1,a=new Float32Array(e.length),i=0;i<e.length;i++)a[i]=e[i]*n/o;return a}function Oe(e,r,t,n){var o=t,a=function(e,r,t,n,o){for(var a=new Int32Array(52),i=new Int32Array(e),u=[],f=[],c=function(e,r,t){var n=a[e],i=M[n];if(0===i)return 0;var u=Math.pow(i,o),f=0|O[r],c=0|O[t];return u*((0===f?2:B[f])-B[c])},l=0;l<e;l++){var s=0|t[l];if(0!==s){var v=Me(r[l].subarray(0,s));if(a[l]=v,0!==v){var h=0,y=1,d=O[y]-O[h]|0;if(!(d<=0)){var b=c(l,h,y);u.push(l),f.push(b/d)}}}}for(var p=(u.length>>1)-1;p>=0;p--)je(u,f,p);for(;n>0&&u.length>0;){var m=u[0],w=0|i[m],g=w+1,k=0|t[m],S=(O[g]-O[w]|0)*k;if(S>n||S<=0)Be(u,f);else if(n-=S,i[m]=g,g<15){var A=g+1,j=O[A]-O[g]|0;j>0?(f[0]=c(m,g,A)/j,je(u,f,0)):Be(u,f)}else Be(u,f)}return{wordLengths:i,scaleFactorIndices:a}}(o,e,r,1656-10*o,n);return{bfuCount:o,allocation:a.wordLengths,scaleFactorIndices:a.scaleFactorIndices}}function Me(e){for(var r=0,t=0;t<e.length;t++){var n=Math.abs(e[t]);n>r&&(r=n)}if(0===r)return 0;var o=Math.ceil(3*(Math.log2(r)+21));return Math.max(0,Math.min(63,o))}function Be(e,r){var t=e.length-1;e[0]=e[t],r[0]=r[t],e.pop(),r.pop(),e.length&&je(e,r,0)}function je(e,r,t){for(var n=e.length,o=t,a=e[o],i=r[o];;){var u=1+(o<<1),f=u+1,c=o,l=i;if(u<n&&r[u]>l&&(c=u,l=r[u]),f<n&&r[f]>l&&(c=f),c===o)break;e[o]=e[c],r[o]=r[c],o=c}e[o]=a,r[o]=i}function Fe(e){return Fe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fe(e)}function Pe(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Ce(n.key),n)}}function Te(e,r,t){return r&&Pe(e.prototype,r),t&&Pe(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ce(e){var r=function(e,r){if("object"!=Fe(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=Fe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==Fe(r)?r:r+""}var xe=Te(function e(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.transformBuffers={64:new Float32Array(64),128:new Float32Array(128),256:new Float32Array(256),512:new Float32Array(512)},this.qmfWorkBuffers={delay:{128:new Float32Array(174),256:new Float32Array(302),512:new Float32Array(558)},highBandDelay:{128:new Float32Array(167),256:new Float32Array(295)}},this.qmfDelays={lowBand:new Float32Array(h),midBand:new Float32Array(h),highBand:new Float32Array(39)},this.transientDetection=[new Float32Array(64),new Float32Array(64),new Float32Array(128)],this.mdctBuffers={16:{real:new Float32Array(16),imag:new Float32Array(16)},64:{real:new Float32Array(64),imag:new Float32Array(64)},128:{real:new Float32Array(128),imag:new Float32Array(128)}},this.mdctOverlap=[new Float32Array(32),new Float32Array(32),new Float32Array(32)],this.imdctOverlap=[new Float32Array(256),new Float32Array(256),new Float32Array(512)],this.reversalBuffers={32:new Float32Array(32),128:new Float32Array(128),256:new Float32Array(256)}});function ze(e,r,t){if(!r)return!1;var n=function(e,r){var t=function(e,r){for(var t=0,n=0,o=0;o<e.length;o++){var a=Math.abs(e[o]),i=a-Math.abs(r[o]);i>0&&(t+=i),n+=a*a}var u=Math.sqrt(n)||1e-6;return t/u}(e,r),n=Ie(e),o=Ie(r),a=Math.abs(n-o),i=qe(e),u=qe(r),f=Math.abs(i-u),c=function(e,r){for(var t=0,n=0,o=0;o<e.length;o++)t+=e[o]*e[o],n+=r[o]*r[o];t=Math.max(t,1e-10),n=Math.max(n,1e-10);var a=10*Math.log10(t/n);return Math.max(0,a)}(e,r);return{spectralFlux:t,flatnessChange:a,hfChange:f,energyChange:c}}(e,r),o=function(e){var r=e.spectralFlux,t=e.flatnessChange,n=e.hfChange,o=e.energyChange,a=r,i=Math.sqrt(t),u=Math.log1p(10*n)/Math.log1p(10),f=Math.min(o/30,1);return(a+i+u+f)/4}(n);return o>t}function Ie(e){for(var r=0,t=0,n=0,o=0;o<e.length;o++){var a=Math.abs(e[o]);a>1e-10&&(r+=Math.log(a),t+=a,n++)}if(0===n)return 0;var i=Math.exp(r/n),u=t/n;return u>1e-10?i/u:0}function qe(e){for(var r=Math.floor(e.length/2),t=0,n=0,o=0;o<r;o++)t+=e[o]*e[o];for(var a=r;a<e.length;a++)n+=e[a]*e[a];var i=t+n;return i>0?n/i:0}function Ee(e){var r,t=null!==(r=null==e?void 0:e.bufferPool)&&void 0!==r?r:$("qmfAnalysisStage: bufferPool is required"),n=t.qmfDelays;return function(e){var r=Q(e,n.lowBand,t.qmfWorkBuffers);n.lowBand=r.newDelay;var o=Q(r.lowBand,n.midBand,t.qmfWorkBuffers);n.midBand=o.newDelay;var a=t.qmfWorkBuffers.highBandDelay[r.highBand.length];a.set(n.highBand),a.set(r.highBand,n.highBand.length);var i=a.slice(0,r.highBand.length);return n.highBand=a.slice(r.highBand.length),{bands:[o.lowBand,o.highBand,i]}}}function _e(e){var r,t,n=null!==(r=null==e?void 0:e.bufferPool)&&void 0!==r?r:$("blockSelectorStage: bufferPool is required"),o=null!==(t=null==e?void 0:e.options)&&void 0!==t?t:$("blockSelectorStage: options is required");return function(e){var r,t=e.bands;if(o.fixedBlockModes)r=o.fixedBlockModes;else{var a=[128,128,256];r=t.map(function(e,r){var t=function(e,r){var t=new Float32Array(r),n=new Float32Array(r),o=Math.min(e.length,r);t.set(e.subarray(0,o)),re.fft(t,n);for(var a=new Float32Array(r/2),i=0;i<r/2;i++)a[i]=Math.sqrt(t[i]*t[i]+n[i]*n[i]);return a}(e,a[r]),i=ze(t,n.transientDetection[r],o.transientThresholdLow);return n.transientDetection[r]=t,i*Math.max(r+1,2)})}return{bands:t,blockModes:r}}}function De(e){var r,t=null!==(r=null==e?void 0:e.bufferPool)&&void 0!==r?r:$("mdctStage: bufferPool is required"),n=t.mdctOverlap,o=[be,be,pe];function a(e,r,t,n,a){var u=m[r];return 0===t?function(e,r,t,n,o,a){var u=2===r?s:l,f=a.transformBuffers[u];f.fill(0),f.set(o,t.windowStart),i(e,o,t.size),f.set(e,t.windowStart+32);var c=n.transform(f,a.mdctBuffers);r>0&&(c=K(c,a.reversalBuffers));return c}(e,r,u,o[r],n,a):function(e,r,t,n,o){for(var a=1<<(256===t.size?3:2),u=new Float32Array(t.size),f=0;f<a;f++){var c=f*w,l=e.subarray(c,c+w),s=o.transformBuffers[64];s.fill(0),s.set(n,0),i(l,n,w),s.set(l,g);var v=de.transform(s,o.mdctBuffers);r>0&&(v=K(v,o.reversalBuffers)),u.set(v,c)}return u}(e,r,u,n,a)}function i(e,r,t){for(var n=t-g,o=0;o<g;o++){var a=e[n+o];r[o]=v[o]*a,e[n+o]=a*v[31-o]}}return function(e){var r=e.bands,o=e.blockModes,i=e.originalFrame,u=new Float32Array(512);return r.forEach(function(e,r){var i=a(e,r,o[r],n[r],t),f=function(e){return 0===e?0:1===e?128:256}(r);u.set(i,f)}),{bands:r,coefficients:u,blockModes:o,originalFrame:i}}}function Ue(e){var r,t=null!==(r=null==e?void 0:e.options)&&void 0!==r?r:$("quantizationStage: options is required");return function(e){for(var r=e.coefficients,n=e.blockModes,o=function(e,r){for(var t=[],n=[],o=0,i=0,l=0;l<3;l++){for(var s=o,v=2===l?256:128,h=l<2?u[l]:a.length,y=0===r[l]?f:c;i<h;){var d=a[i],b=y[i]-s,p=b+d,m=new Float32Array(d);if(b>=0&&p<=v)m.set(e.subarray(s+b,s+p));else if(m.fill(0),b<v&&p>0){var w=Math.max(0,b),g=Math.min(v,p);m.set(e.subarray(s+w,s+g),Math.max(0,-b))}t.push(m),n.push(d),i++}o+=v}return{bfuData:t,bfuSizes:n,bfuCount:i}}(r,n),i=o.bfuData,l=o.bfuSizes,s=Oe(i,l,o.bfuCount,t.allocationBias),v=s.bfuCount,h=s.allocation,y=s.scaleFactorIndices,d=[],b=0;b<v;b++){var p=i[b].subarray(0,l[b]),m=h[b],w=O[m],g=Se(p,y[b],w);d.push(g)}return{nBfu:v,scaleFactorIndices:y,wordLengthIndices:h.slice(0,v),quantizedCoefficients:d,blockModes:n}}}function He(){return J({options:arguments.length>0&&void 0!==arguments[0]?arguments[0]:new R,bufferPool:arguments.length>1&&void 0!==arguments[1]?arguments[1]:new xe},Ee,_e,De,Ue)}function We(){return function(e){for(var r=new Float32Array(512),t=e.nBfu,n=e.scaleFactorIndices,o=e.wordLengthIndices,a=e.quantizedCoefficients,i=e.blockModes,l=0;l<t;l++){var s=O[o[l]],v=0;l>=u[0]&&(v=1),l>=u[1]&&(v=2);var h=0===i[v]?f[l]:c[l];if(s>0){var y=Ae(a[l],n[l],s);r.set(y,h)}}return{coefficients:r,blockModes:i}}}function Le(e){var r,t=null!==(r=null==e?void 0:e.bufferPool)&&void 0!==r?r:$("imdctStage: bufferPool is required"),n=t.imdctOverlap,o=[we,we,ge];function a(e,r,t,n,a,i){return 0===t?function(e,r,t,n,o,a){var i=e;r>0&&(i=K(e,n.reversalBuffers));var u=a.transform(i,n.mdctBuffers),f=u.length/4,c=n.transformBuffers[512];c.fill(0);for(var l=0;l<o.size;l++)c[l]=u[f+l];var s=t.slice(2*o.size-k,2*o.size),h=ke(s.slice(0,k),c.slice(0,k),v);t.set(h,0);for(var y=0;y<k;y++)s[y]=c[k+y];for(var d=2===r?240:112,b=0;b<d;b++)t[32+b]=c[k+b];for(var p=0;p<k;p++)t[2*o.size-k+p]=c[o.size-k+p];return t.slice(0,o.size)}(e,r,n,a,i,o[r]):function(e,r,t,n,o){var a=1<<(256===o.size?3:2),i=n.transformBuffers[512];i.fill(0);for(var u=t.slice(2*o.size-k,2*o.size),f=0,c=0,l=0;l<a;l++){var s=e.slice(c,c+w);r>0&&(s=K(s,n.reversalBuffers));for(var h=me.transform(s,n.mdctBuffers),y=h.length/4,d=0;d<w;d++)i[f+d]=h[y+d];var b=ke(u.slice(0,k),i.slice(f,f+k),v);t.set(b,f);for(var p=0;p<k;p++)u[p]=i[f+k+p];f+=w,c+=w}for(var m=0;m<k;m++)t[2*o.size-k+m]=i[o.size-k+m];return t.slice(0,o.size)}(e,r,n,a,i)}return function(e){var r=e.coefficients,o=e.blockModes;return m.map(function(e,i){var u=function(e,r){var t=[0,128,256,512];return e.subarray(t[r],t[r+1])}(r,i);return a(u,i,o[i],n[i],t,e)})}}function Ge(e){var r,t=null!==(r=null==e?void 0:e.bufferPool)&&void 0!==r?r:$("qmfSynthesisStage: bufferPool is required"),n=t.qmfDelays;return function(e){var r=t.qmfWorkBuffers.highBandDelay[e[2].length];r.set(n.highBand),r.set(e[2],n.highBand.length);var o=r.slice(0,2*e[0].length);n.highBand=r.slice(2*e[0].length);var a=X(e[0],e[1],n.midBand,t.qmfWorkBuffers);n.midBand=a.newDelay;var i=X(a.output,o,n.lowBand,t.qmfWorkBuffers);return n.lowBand=i.newDelay,i.output}}function Ne(){return J({bufferPool:arguments.length>0&&void 0!==arguments[0]?arguments[0]:new xe},We,Le,Ge)}function Ve(e){return Ve="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ve(e)}function Re(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=Qe(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,u=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function $e(e,r,t,n,o,a,i){try{var u=e[a](i),f=u.value}catch(e){return void t(e)}u.done?r(f):Promise.resolve(f).then(n,o)}function Je(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){$e(a,n,o,i,u,"next",e)}function u(e){$e(a,n,o,i,u,"throw",e)}i(void 0)})}}function Ke(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,u=[],f=!0,c=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=a.call(t)).done)&&(u.push(n.value),u.length!==r);f=!0);}catch(e){c=!0,o=e}finally{try{if(!f&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(c)throw o}}return u}}(e,r)||Qe(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qe(e,r){if(e){if("string"==typeof e)return Xe(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Xe(e,r):void 0}}function Xe(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function Ye(e){if(null!=e){var r=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],t=0;if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&t>=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}}}throw new TypeError(Ve(e)+" is not iterable")}function Ze(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,r,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function a(t,n,o,a){var f=n&&n.prototype instanceof u?n:u,c=Object.create(f.prototype);return er(c,"_invoke",function(t,n,o){var a,u,f,c=0,l=o||[],s=!1,v={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(r,t){return a=r,u=0,f=e,v.n=t,i}};function h(t,n){for(u=t,f=n,r=0;!s&&c&&!o&&r<l.length;r++){var o,a=l[r],h=v.p,y=a[2];t>3?(o=y===n)&&(f=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=e):a[0]<=h&&((o=t<2&&h<a[1])?(u=0,v.v=n,v.n=a[1]):h<y&&(o=t<3||a[0]>n||n>y)&&(a[4]=t,a[5]=n,v.n=y,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,l,y){if(c>1)throw TypeError("Generator is already running");for(s&&1===l&&h(l,y),u=l,f=y;(r=u<2?e:f)||!s;){a||(u?u<3?(u>1&&(v.n=-1),h(u,f)):v.n=f:v.v=f);try{if(c=2,a){if(u||(o="next"),r=a[o]){if(!(r=r.call(a,f)))throw TypeError("iterator result is not an object");if(!r.done)return r;f=r.value,u<2&&(u=0)}else 1===u&&(r=a.return)&&r.call(a),u<2&&(f=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=e}else if((r=(s=v.n<0)?f:t.call(n,v))!==i)break}catch(r){a=e,u=1,f=r}finally{c=1}}return{value:r,done:s}}}(t,o,a),!0),c}var i={};function u(){}function f(){}function c(){}r=Object.getPrototypeOf;var l=[][n]?r(r([][n]())):(er(r={},n,function(){return this}),r),s=c.prototype=u.prototype=Object.create(l);function v(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,er(e,o,"GeneratorFunction")),e.prototype=Object.create(s),e}return f.prototype=c,er(s,"constructor",c),er(c,"constructor",f),f.displayName="GeneratorFunction",er(c,o,"GeneratorFunction"),er(s),er(s,o,"Generator"),er(s,n,function(){return this}),er(s,"toString",function(){return"[object Generator]"}),(Ze=function(){return{w:a,m:v}})()}function er(e,r,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}er=function(e,r,t,n){if(r)o?o(e,r,{value:t,enumerable:!n,configurable:!n,writable:!n}):e[r]=t;else{var a=function(r,t){er(e,r,function(e){return this._invoke(r,t,e)})};a("next",0),a("throw",1),a("return",2)}},er(e,r,t,n)}function rr(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,tr(n.key),n)}}function tr(e){var r=function(e,r){if("object"!=Ve(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=Ve(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==Ve(r)?r:r+""}function nr(e){return function(){return new or(e.apply(this,arguments))}}function or(e){var r,t;function n(r,t){try{var a=e[r](t),i=a.value,u=i instanceof ur;Promise.resolve(u?i.v:i).then(function(t){if(u){var f="return"===r?"return":"next";if(!i.k||t.done)return n(f,t);t=e[f](t).value}o(a.done?"return":"normal",t)},function(e){n("throw",e)})}catch(e){o("throw",e)}}function o(e,o){switch(e){case"return":r.resolve({value:o,done:!0});break;case"throw":r.reject(o);break;default:r.resolve({value:o,done:!1})}(r=r.next)?n(r.key,r.arg):t=null}this._invoke=function(e,o){return new Promise(function(a,i){var u={key:e,arg:o,resolve:a,reject:i,next:null};t?t=t.next=u:(r=t=u,n(e,o))})},"function"!=typeof e.return&&(this.return=void 0)}function ar(e){return new ur(e,0)}function ir(e){var r={},t=!1;function n(r,n){return t=!0,n=new Promise(function(t){t(e[r](n))}),{done:!1,value:new ur(n,1)}}return r["undefined"!=typeof Symbol&&Symbol.iterator||"@@iterator"]=function(){return this},r.next=function(e){return t?(t=!1,e):n("next",e)},"function"==typeof e.throw&&(r.throw=function(e){if(t)throw t=!1,e;return n("throw",e)}),"function"==typeof e.return&&(r.return=function(e){return t?(t=!1,e):n("return",e)}),r}function ur(e,r){this.v=e,this.k=r}function fr(e){var r,t,n,o=2;for("undefined"!=typeof Symbol&&(t=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(t&&null!=(r=e[t]))return r.call(e);if(n&&null!=(r=e[n]))return new cr(r.call(e));t="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function cr(e){function r(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var r=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:r}})}return cr=function(e){this.s=e,this.n=e.next},cr.prototype={s:null,n:null,next:function(){return r(this.n.apply(this.s,arguments))},return:function(e){var t=this.s.return;return void 0===t?Promise.resolve({value:e,done:!0}):r(t.apply(this.s,arguments))},throw:function(e){var t=this.s.return;return void 0===t?Promise.reject(e):r(t.apply(this.s,arguments))}},new cr(e)}or.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},or.prototype.next=function(e){return this._invoke("next",e)},or.prototype.throw=function(e){return this._invoke("throw",e)},or.prototype.return=function(e){return this._invoke("return",e)};var lr=function(){function e(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e)}return t=e,a=null,i=[{key:"encodeStream",value:function(r){return nr(function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Ze().m(function n(){var o,a,i,u;return Ze().w(function(n){for(;;)switch(n.n){case 0:if(o=t.channelCount,a=void 0===o?1:o,i=t.onProgress,u=t.encoderOptions,1!==a){n.n=2;break}return n.d(Ye(ir(fr(e._encodeMonoStream(r,i,u)))),1);case 1:case 3:n.n=5;break;case 2:if(2!==a){n.n=4;break}return n.d(Ye(ir(fr(e._encodeStereoStream(r,i,u)))),3);case 4:throw new Error("Unsupported channel count: ".concat(a));case 5:return n.a(2)}},n)})()}).apply(this,arguments)}},{key:"_encodeMonoStream",value:function(e,r,t){return nr(Ze().m(function n(){var o,a,i,u,f,c,l,s,v,h,y;return Ze().w(function(n){for(;;)switch(n.n){case 0:o=t||new R,a=He(o),i=0,u=!1,f=!1,n.p=1,l=fr(e);case 2:return n.n=3,ar(l.next());case 3:if(!(u=!(s=n.v).done)){n.n=6;break}return v=s.value,h=a(v),n.n=4,h;case 4:r&&r(i++);case 5:u=!1,n.n=2;break;case 6:n.n=8;break;case 7:n.p=7,y=n.v,f=!0,c=y;case 8:if(n.p=8,n.p=9,!u||null==l.return){n.n=10;break}return n.n=10,ar(l.return());case 10:if(n.p=10,!f){n.n=11;break}throw c;case 11:return n.f(10);case 12:return n.f(8);case 13:return n.a(2)}},n,null,[[9,,10,12],[1,7,8,13]])}))()}},{key:"_encodeStereoStream",value:function(e,r,t){return nr(Ze().m(function n(){var o,a,i,u,f,c,l,s,v,h,y,d,b,p,m;return Ze().w(function(n){for(;;)switch(n.n){case 0:o=t||new R,a=He(o),i=He(o),u=0,f=!1,c=!1,n.p=1,s=fr(e);case 2:return n.n=3,ar(s.next());case 3:if(!(f=!(v=n.v).done)){n.n=7;break}return h=Ke(v.value,2),y=h[0],d=h[1],b=a(y),p=i(d),n.n=4,b;case 4:return n.n=5,p;case 5:r&&r(u++);case 6:f=!1,n.n=2;break;case 7:n.n=9;break;case 8:n.p=8,m=n.v,c=!0,l=m;case 9:if(n.p=9,n.p=10,!f||null==s.return){n.n=11;break}return n.n=11,ar(s.return());case 11:if(n.p=11,!c){n.n=12;break}throw l;case 12:return n.f(11);case 13:return n.f(9);case 14:return n.a(2)}},n,null,[[10,,11,13],[1,8,9,14]])}))()}},{key:"decodeStream",value:function(r){return nr(function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Ze().m(function n(){var o,a,i;return Ze().w(function(n){for(;;)switch(n.n){case 0:if(o=t.channelCount,a=void 0===o?1:o,i=t.onProgress,1!==a){n.n=2;break}return n.d(Ye(ir(fr(e._decodeMonoStream(r,i)))),1);case 1:case 3:n.n=5;break;case 2:if(2!==a){n.n=4;break}return n.d(Ye(ir(fr(e._decodeStereoStream(r,i)))),3);case 4:throw new Error("Unsupported channel count: ".concat(a));case 5:return n.a(2)}},n)})()}).apply(this,arguments)}},{key:"_decodeMonoStream",value:function(e,r){return nr(Ze().m(function t(){var n,o,a;return Ze().w(function(t){for(;;)switch(t.n){case 0:return n=Ne(),o=0,a=function(){var t=nr(Ze().m(function t(){var a,i,u,f,c,l,s,v;return Ze().w(function(t){for(;;)switch(t.n){case 0:a=!1,i=!1,t.p=1,f=fr(e);case 2:return t.n=3,ar(f.next());case 3:if(!(a=!(c=t.v).done)){t.n=6;break}return l=c.value,s=n(l),t.n=4,s;case 4:r&&r(o++);case 5:a=!1,t.n=2;break;case 6:t.n=8;break;case 7:t.p=7,v=t.v,i=!0,u=v;case 8:if(t.p=8,t.p=9,!a||null==f.return){t.n=10;break}return t.n=10,ar(f.return());case 10:if(t.p=10,!i){t.n=11;break}throw u;case 11:return t.f(10);case 12:return t.f(8);case 13:return t.a(2)}},t,null,[[9,,10,12],[1,7,8,13]])}));return function(){return t.apply(this,arguments)}}(),t.d(Ye(ir(fr(a()))),1);case 1:return t.a(2)}},t)}))()}},{key:"_decodeStereoStream",value:function(r,t){return nr(Ze().m(function n(){var o,a,i,u;return Ze().w(function(n){for(;;)switch(n.n){case 0:return o=Ne(),a=Ne(),i=0,u=function(){var n=nr(Ze().m(function n(){var u,f,c,l,s,v,h,y,d,b,p,m,w,g,k;return Ze().w(function(n){for(;;)switch(n.n){case 0:u=null,f=!0,c=!1,l=!1,n.p=1,v=fr(r);case 2:return n.n=3,ar(v.next());case 3:if(!(c=!(h=n.v).done)){n.n=8;break}if(y=h.value,!f){n.n=4;break}u=y,n.n=6;break;case 4:return d=y,b=o(u),p=a(d),n.n=5,[b,p];case 5:t&&t(i++);case 6:f=!f;case 7:c=!1,n.n=2;break;case 8:n.n=10;break;case 9:n.p=9,k=n.v,l=!0,s=k;case 10:if(n.p=10,n.p=11,!c||null==v.return){n.n=12;break}return n.n=12,ar(v.return());case 12:if(n.p=12,!l){n.n=13;break}throw s;case 13:return n.f(12);case 14:return n.f(10);case 15:if(f||!u){n.n=17;break}return m=e._createDummyFrame(),w=o(u),g=a(m),n.n=16,[w,g];case 16:t&&t(i++);case 17:return n.a(2)}},n,null,[[11,,12,14],[1,9,10,15]])}));return function(){return n.apply(this,arguments)}}(),n.d(Ye(ir(fr(u()))),1);case 1:return n.a(2)}},n)}))()}},{key:"frameBufferToFrames",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:512;return Ze().m(function t(){var n,o,a,i,u,f,c,l,s,v,h,y,d,b,p,m;return Ze().w(function(t){for(;;)switch(t.n){case 0:if(1!==(n=e.length)){t.n=4;break}o=Ke(e,1),a=o[0],i=0;case 1:if(!(i<a.length)){t.n=3;break}for(u=new Float32Array(r),f=Math.min(i+r,a.length),c=0;c<f-i;c++)u[c]=a[i+c];return t.n=2,u;case 2:i+=r,t.n=1;break;case 3:t.n=9;break;case 4:if(2!==n){t.n=8;break}l=Ke(e,2),s=l[0],v=l[1],h=Math.max(s.length,v.length),y=0;case 5:if(!(y<h)){t.n=7;break}for(d=new Float32Array(r),b=new Float32Array(r),p=Math.min(y+r,h),m=0;m<p-y;m++)d[m]=y+m<s.length?s[y+m]:0,b[m]=y+m<v.length?v[y+m]:0;return t.n=6,[d,b];case 6:y+=r,t.n=5;break;case 7:t.n=9;break;case 8:throw new Error("Unsupported channel count: ".concat(n));case 9:return t.a(2)}},t)})()}},{key:"collectFrames",value:(c=Je(Ze().m(function e(r){var t,n,o,a,i,u,f,c;return Ze().w(function(e){for(;;)switch(e.n){case 0:t=[],n=!1,o=!1,e.p=1,i=fr(r);case 2:return e.n=3,i.next();case 3:if(!(n=!(u=e.v).done)){e.n=5;break}f=u.value,t.push(f);case 4:n=!1,e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,c=e.v,o=!0,a=c;case 7:if(e.p=7,e.p=8,!n||null==i.return){e.n=9;break}return e.n=9,i.return();case 9:if(e.p=9,!o){e.n=10;break}throw a;case 10:return e.f(9);case 11:return e.f(7);case 12:return e.a(2,t)}},e,null,[[8,,9,11],[1,6,7,12]])})),function(e){return c.apply(this,arguments)})},{key:"_createDummyFrame",value:function(){return{nBfu:0,blockModes:[0,0,0],scaleFactorIndices:new Int32Array(0),wordLengthIndices:new Int32Array(0),quantizedCoefficients:[]}}},{key:"createAeaBlob",value:(f=Je(Ze().m(function e(r){var t,n,o,a,i,u,f,c,l,s,v,h,y,d,b,p,m,w,g,k,S=arguments;return Ze().w(function(e){for(;;)switch(e.n){case 0:n=(t=S.length>1&&void 0!==S[1]?S[1]:{}).title,o=void 0===n?"encoded by atrac1.js":n,a=t.channelCount,i=void 0===a?1:a,u=[],f=!1,c=!1,e.p=1,s=fr(r);case 2:return e.n=3,s.next();case 3:if(!(f=!(v=e.v).done)){e.n=5;break}h=v.value,u.push(q(h));case 4:f=!1,e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,k=e.v,c=!0,l=k;case 7:if(e.p=7,e.p=8,!f||null==s.return){e.n=9;break}return e.n=9,s.return();case 9:if(e.p=9,!c){e.n=10;break}throw l;case 10:return e.f(9);case 11:return e.f(7);case 12:for(y=_.createHeader(o,u.length,i),d=y.length+u.reduce(function(e,r){return e+r.length},0),(b=new Uint8Array(d)).set(y,0),p=y.length,m=0,w=u;m<w.length;m++)g=w[m],b.set(g,p),p+=g.length;return e.a(2,new Blob([b],{type:"application/octet-stream"}))}},e,null,[[8,,9,11],[1,6,7,12]])})),function(e){return f.apply(this,arguments)})},{key:"createWavBlob",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r,a=Array.isArray(t)?t:[t];if(1===n)return e._createMonoWavBlob(a,o);if(2===n)return e._createStereoWavBlob(a,o);throw new Error("Unsupported channel count: ".concat(n))}},{key:"_createMonoWavBlob",value:function(r,t){var n=r.reduce(function(e,r){return e+r.length},0),o=new ArrayBuffer(44+2*n),a=new DataView(o);e._writeWavHeader(a,n,1,t);var i,u=44,f=Re(r);try{for(f.s();!(i=f.n()).done;)for(var c=i.value,l=0;l<c.length;l++){var s=Math.max(-1,Math.min(1,c[l]));a.setInt16(u,s<0?s*A:s*S,!0),u+=2}}catch(e){f.e(e)}finally{f.f()}return new Blob([o],{type:"audio/wav"})}},{key:"_createStereoWavBlob",value:function(r,t){var n=r.reduce(function(e,r){var t=Ke(r,2),n=t[0],o=t[1];return e+Math.max(n.length,o.length)},0),o=new ArrayBuffer(44+2*n*2),a=new DataView(o);e._writeWavHeader(a,n,2,t);var i,u=44,f=Re(r);try{for(f.s();!(i=f.n()).done;)for(var c=Ke(i.value,2),l=c[0],s=c[1],v=Math.max(l.length,s.length),h=0;h<v;h++){var y=h<l.length?l[h]:0,d=h<s.length?s[h]:0,b=Math.max(-1,Math.min(1,y)),p=Math.max(-1,Math.min(1,d));a.setInt16(u,b<0?b*A:b*S,!0),u+=2,a.setInt16(u,p<0?p*A:p*S,!0),u+=2}}catch(e){f.e(e)}finally{f.f()}return new Blob([o],{type:"audio/wav"})}},{key:"_writeWavHeader",value:function(e,r,t,n){var o=n*t*2,a=2*t,i=r*a,u=36+i,f=0,c=function(r,t){for(var n=0;n<t.length;n++)e.setUint8(r+n,t.charCodeAt(n))};c(f,"RIFF"),f+=4,e.setUint32(f,u,!0),c(f+=4,"WAVE"),c(f+=4,"fmt "),f+=4,e.setUint32(f,16,!0),f+=4,e.setUint16(f,1,!0),f+=2,e.setUint16(f,t,!0),f+=2,e.setUint32(f,n,!0),f+=4,e.setUint32(f,o,!0),f+=4,e.setUint16(f,a,!0),f+=2,e.setUint16(f,16,!0),c(f+=2,"data"),f+=4,e.setUint32(f,i,!0)}},{key:"parseAeaBlob",value:(u=Je(Ze().m(function e(r){var t,a,i,u,f,c;return Ze().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,r.arrayBuffer();case 1:for(t=e.v,a=new Uint8Array(t.slice(0,n)),i=_.parseHeader(a),u=[],f=n;f<t.byteLength;f+=o)(c=new Uint8Array(t.slice(f,f+o))).length===o&&u.push(c);return e.a(2,{info:i,frameData:u})}},e)})),function(e){return u.apply(this,arguments)})},{key:"deserializedFrameStream",value:Ze().m(function e(r){var t,n,o,a;return Ze().w(function(e){for(;;)switch(e.n){case 0:t=Re(r),e.p=1,t.s();case 2:if((n=t.n()).done){e.n=4;break}return o=n.value,e.n=3,E(o);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,a=e.v,t.e(a);case 6:return e.p=6,t.f(),e.f(6);case 7:return e.a(2)}},e,null,[[1,5,6,7]])})},{key:"assemblePcmFrames",value:function(e,r){if(1===r){var t,n=e.reduce(function(e,r){return e+r.length},0),o=new Float32Array(n),a=0,i=Re(e);try{for(i.s();!(t=i.n()).done;){var u=t.value;o.set(u,a),a+=u.length}}catch(e){i.e(e)}finally{i.f()}return o}if(2===r){var f,c=e.reduce(function(e,r){var t=Ke(r,2),n=t[0],o=t[1];return e+Math.max(n.length,o.length)},0),l=new Float32Array(2*c),s=0,v=Re(e);try{for(v.s();!(f=v.n()).done;)for(var h=Ke(f.value,2),y=h[0],d=h[1],b=Math.max(y.length,d.length),p=0;p<b;p++)l[2*s]=p<y.length?y[p]:0,l[2*s+1]=p<d.length?d[p]:0,s++}catch(e){v.e(e)}finally{v.f()}return l}throw new Error("Unsupported channel count: ".concat(r))}}],a&&rr(t.prototype,a),i&&rr(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,a,i,u,f,c}();function sr(e){return sr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},sr(e)}function vr(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function hr(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?vr(Object(t),!0).forEach(function(r){yr(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):vr(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function yr(e,r,t){return(r=function(e){var r=function(e,r){if("object"!=sr(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=sr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==sr(r)?r:r+""}(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function dr(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,r,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function a(t,n,o,a){var f=n&&n.prototype instanceof u?n:u,c=Object.create(f.prototype);return br(c,"_invoke",function(t,n,o){var a,u,f,c=0,l=o||[],s=!1,v={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(r,t){return a=r,u=0,f=e,v.n=t,i}};function h(t,n){for(u=t,f=n,r=0;!s&&c&&!o&&r<l.length;r++){var o,a=l[r],h=v.p,y=a[2];t>3?(o=y===n)&&(f=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=e):a[0]<=h&&((o=t<2&&h<a[1])?(u=0,v.v=n,v.n=a[1]):h<y&&(o=t<3||a[0]>n||n>y)&&(a[4]=t,a[5]=n,v.n=y,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,l,y){if(c>1)throw TypeError("Generator is already running");for(s&&1===l&&h(l,y),u=l,f=y;(r=u<2?e:f)||!s;){a||(u?u<3?(u>1&&(v.n=-1),h(u,f)):v.n=f:v.v=f);try{if(c=2,a){if(u||(o="next"),r=a[o]){if(!(r=r.call(a,f)))throw TypeError("iterator result is not an object");if(!r.done)return r;f=r.value,u<2&&(u=0)}else 1===u&&(r=a.return)&&r.call(a),u<2&&(f=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=e}else if((r=(s=v.n<0)?f:t.call(n,v))!==i)break}catch(r){a=e,u=1,f=r}finally{c=1}}return{value:r,done:s}}}(t,o,a),!0),c}var i={};function u(){}function f(){}function c(){}r=Object.getPrototypeOf;var l=[][n]?r(r([][n]())):(br(r={},n,function(){return this}),r),s=c.prototype=u.prototype=Object.create(l);function v(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,br(e,o,"GeneratorFunction")),e.prototype=Object.create(s),e}return f.prototype=c,br(s,"constructor",c),br(c,"constructor",f),f.displayName="GeneratorFunction",br(c,o,"GeneratorFunction"),br(s),br(s,o,"Generator"),br(s,n,function(){return this}),br(s,"toString",function(){return"[object Generator]"}),(dr=function(){return{w:a,m:v}})()}function br(e,r,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}br=function(e,r,t,n){if(r)o?o(e,r,{value:t,enumerable:!n,configurable:!n,writable:!n}):e[r]=t;else{var a=function(r,t){br(e,r,function(e){return this._invoke(r,t,e)})};a("next",0),a("throw",1),a("return",2)}},br(e,r,t,n)}function pr(e,r,t,n,o,a,i){try{var u=e[a](i),f=u.value}catch(e){return void t(e)}u.done?r(f):Promise.resolve(f).then(n,o)}function mr(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){pr(a,n,o,i,u,"next",e)}function u(e){pr(a,n,o,i,u,"throw",e)}i(void 0)})}}function wr(e,r,t){return gr.apply(this,arguments)}function gr(){return(gr=mr(dr().m(function e(r,t,n){var o,a,i,u,f,c,l;return dr().w(function(e){for(;;)switch(e.n){case 0:return n=null!=n?n:"encoded by carta1",e.p=1,o=lr.frameBufferToFrames(r),a=r.length,i=new R(t),u=lr.encodeStream(o,{channelCount:a,encoderOptions:i}),e.n=2,lr.collectFrames(u);case 2:return f=e.v,e.n=3,lr.createAeaBlob(f,{title:n,channelCount:a});case 3:return c=e.v,e.a(2,{aeaBlob:c});case 4:throw e.p=4,l=e.v,console.error("Worker encode error:",l),l;case 5:return e.a(2)}},e,null,[[1,4]])}))).apply(this,arguments)}function kr(){return(new R).toObject()}function Sr(e){return Ar.apply(this,arguments)}function Ar(){return(Ar=mr(dr().m(function e(t){var n,o,a,i,u,f,c,l,s;return dr().w(function(e){for(;;)switch(e.n){case 0:return n=t.header,o=t.aeaData,(a=t.info)?i=hr({sampleRate:r},a):n?(u=_.parseHeader(n),i=hr({sampleRate:r},u)):i={channelCount:2,sampleRate:r},f=lr.deserializedFrameStream(o),c=lr.decodeStream(f,{channelCount:i.channelCount}),e.n=1,lr.collectFrames(c);case 1:return l=e.v,s=lr.createWavBlob(l,i.channelCount,i.sampleRate),e.a(2,{wavBlob:s,info:i})}},e)}))).apply(this,arguments)}self.onmessage=function(){var e=mr(dr().m(function e(r){var t,n,o,a,i,u,f,c,l,s,v;return dr().w(function(e){for(;;)switch(e.n){case 0:t=r.data,n=t.jobId,o=t.type,a=t.pcmData,i=t.aea,u=t.options,f=t.title,c=t.blob,e.p=1,s=o,e.n="encode"===s?2:"decode"===s?4:"parseAea"===s?6:"getEncoderOptions"===s?8:9;break;case 2:return e.n=3,wr(a,u,f);case 3:return l=e.v,e.a(3,10);case 4:return e.n=5,Sr(i);case 5:return l=e.v,e.a(3,10);case 6:return e.n=7,lr.parseAeaBlob(c);case 7:return l=e.v,e.a(3,10);case 8:return l=kr(),e.a(3,10);case 9:throw new Error("Unknown worker message type: ".concat(o));case 10:self.postMessage({jobId:n,result:l}),e.n=12;break;case 11:e.p=11,v=e.v,console.error("Worker error:",v),self.postMessage({jobId:n,error:v.message});case 12:return e.a(2)}},e,null,[[1,11]])}));return function(r){return e.apply(this,arguments)}}();var Or=self;for(var Mr in e)Or[Mr]=e[Mr];e.__esModule&&Object.defineProperty(Or,"__esModule",{value:!0});
|
|
2
2
|
//# sourceMappingURL=carta1-worker.min.js.map
|