carta1 1.1.4 → 1.1.5
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 +17 -1
- package/codec/coding/bitallocation.js +20 -4
- package/codec/core/options.js +13 -0
- package/codec/pipeline/encoder.js +5 -2
- 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
|
@@ -22,6 +22,7 @@ import wav from 'wav'
|
|
|
22
22
|
import { AudioProcessor } from '../codec/io/processor.js'
|
|
23
23
|
import { AeaReader } from '../codec/io/readers.js'
|
|
24
24
|
import { deserializeFrame, AeaFile } from '../codec/io/serialization.js'
|
|
25
|
+
import { EncoderOptions } from '../codec/core/options.js'
|
|
25
26
|
import {
|
|
26
27
|
SAMPLE_RATE,
|
|
27
28
|
SAMPLES_PER_FRAME,
|
|
@@ -402,9 +403,16 @@ async function encodeFile(inputFile, outputFile, options) {
|
|
|
402
403
|
progress.update(reader.sampleRate)
|
|
403
404
|
}
|
|
404
405
|
|
|
406
|
+
// Create encoder options with spectrum focus if provided
|
|
407
|
+
const encoderOptions = new EncoderOptions()
|
|
408
|
+
if (options.allocationBias !== undefined) {
|
|
409
|
+
encoderOptions.setValue('allocationBias', options.allocationBias)
|
|
410
|
+
}
|
|
411
|
+
|
|
405
412
|
const encodedFrames = AudioProcessor.encodeStream(reader, {
|
|
406
413
|
channelCount: reader.channels,
|
|
407
414
|
onProgress,
|
|
415
|
+
encoderOptions,
|
|
408
416
|
})
|
|
409
417
|
|
|
410
418
|
const title = options.title || path.basename(outputFile, '.aea')
|
|
@@ -613,10 +621,13 @@ async function dumpFile(inputFile, outputFile, options) {
|
|
|
613
621
|
* @returns {Promise<void>} Resolves when operation is complete
|
|
614
622
|
*/
|
|
615
623
|
async function main() {
|
|
624
|
+
const { version } = JSON.parse(
|
|
625
|
+
fs.readFileSync(new URL('../package.json', import.meta.url))
|
|
626
|
+
)
|
|
616
627
|
program
|
|
617
628
|
.name('carta1')
|
|
618
629
|
.description('ATRAC1 Audio Codec')
|
|
619
|
-
.version(
|
|
630
|
+
.version(version)
|
|
620
631
|
.option('-e, --encode', 'Encode WAV to AEA')
|
|
621
632
|
.option('-d, --decode', 'Decode AEA to WAV')
|
|
622
633
|
.option('-j, --json', 'Dump AEA file structure to JSON')
|
|
@@ -626,6 +637,11 @@ async function main() {
|
|
|
626
637
|
'-t, --title <title>',
|
|
627
638
|
'Custom title for AEA file metadata (encoding only)'
|
|
628
639
|
)
|
|
640
|
+
.option(
|
|
641
|
+
'-b, --bias <value>',
|
|
642
|
+
'Bit allocation bias (default: 1.0)',
|
|
643
|
+
parseFloat
|
|
644
|
+
)
|
|
629
645
|
.argument('<input>', 'Input file path')
|
|
630
646
|
.argument('<output>', 'Output file path')
|
|
631
647
|
.parse()
|
|
@@ -38,14 +38,21 @@ import {
|
|
|
38
38
|
* @param {Array<Float32Array>} bfuData
|
|
39
39
|
* @param {Int32Array} bfuSizes
|
|
40
40
|
* @param {number} maxBfuCount
|
|
41
|
+
* @param {number} allocationBias
|
|
41
42
|
* @returns {{bfuCount:number, allocation:Int32Array, scaleFactorIndices:Int32Array}}
|
|
42
43
|
*/
|
|
43
|
-
export function allocateBits(bfuData, bfuSizes, maxBfuCount) {
|
|
44
|
+
export function allocateBits(bfuData, bfuSizes, maxBfuCount, allocationBias) {
|
|
44
45
|
const usedBFU = maxBfuCount
|
|
45
46
|
const avail =
|
|
46
47
|
FRAME_BITS - FRAME_OVERHEAD_BITS - usedBFU * BITS_PER_BFU_METADATA
|
|
47
48
|
|
|
48
|
-
const rdoResult = distributeBitsRDO(
|
|
49
|
+
const rdoResult = distributeBitsRDO(
|
|
50
|
+
usedBFU,
|
|
51
|
+
bfuData,
|
|
52
|
+
bfuSizes,
|
|
53
|
+
avail,
|
|
54
|
+
allocationBias
|
|
55
|
+
)
|
|
49
56
|
|
|
50
57
|
return {
|
|
51
58
|
bfuCount: usedBFU,
|
|
@@ -65,9 +72,16 @@ export function allocateBits(bfuData, bfuSizes, maxBfuCount) {
|
|
|
65
72
|
* @param {Array<Float32Array>} bfuData
|
|
66
73
|
* @param {Int32Array} bfuSizes
|
|
67
74
|
* @param {number} remainingBits
|
|
75
|
+
* @param {number} allocationBias
|
|
68
76
|
* @returns {{wordLengths: Int32Array, scaleFactorIndices: Int32Array}}
|
|
69
77
|
*/
|
|
70
|
-
function distributeBitsRDO(
|
|
78
|
+
function distributeBitsRDO(
|
|
79
|
+
activeBfuCount,
|
|
80
|
+
bfuData,
|
|
81
|
+
bfuSizes,
|
|
82
|
+
remainingBits,
|
|
83
|
+
allocationBias
|
|
84
|
+
) {
|
|
71
85
|
const scaleFactorTable = new Int32Array(NUM_BFUS)
|
|
72
86
|
const wordLengths = new Int32Array(activeBfuCount)
|
|
73
87
|
|
|
@@ -79,13 +93,15 @@ function distributeBitsRDO(activeBfuCount, bfuData, bfuSizes, remainingBits) {
|
|
|
79
93
|
const scaleFactor = SCALE_FACTORS[sfi]
|
|
80
94
|
if (scaleFactor === 0) return 0
|
|
81
95
|
|
|
96
|
+
const effectiveScaleFactor = Math.pow(scaleFactor, allocationBias)
|
|
97
|
+
|
|
82
98
|
const bits1 = WORD_LENGTH_BITS[currentWl] | 0
|
|
83
99
|
const bits2 = WORD_LENGTH_BITS[nextWl] | 0
|
|
84
100
|
|
|
85
101
|
const f1 = bits1 === 0 ? 2.0 : INV_POWER_OF_TWO[bits1]
|
|
86
102
|
const f2 = INV_POWER_OF_TWO[bits2]
|
|
87
103
|
|
|
88
|
-
return
|
|
104
|
+
return effectiveScaleFactor * (f1 - f2)
|
|
89
105
|
}
|
|
90
106
|
|
|
91
107
|
for (let bfuIndex = 0; bfuIndex < activeBfuCount; bfuIndex++) {
|
package/codec/core/options.js
CHANGED
|
@@ -18,6 +18,7 @@ class EncoderOptions {
|
|
|
18
18
|
transientThresholdLow: 1.0,
|
|
19
19
|
transientThresholdMid: 1.5,
|
|
20
20
|
transientThresholdHigh: 2.0,
|
|
21
|
+
allocationBias: 1.0,
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
this.metadata = {
|
|
@@ -45,6 +46,14 @@ class EncoderOptions {
|
|
|
45
46
|
range: [0.01, 4],
|
|
46
47
|
step: 0.01,
|
|
47
48
|
},
|
|
49
|
+
allocationBias: {
|
|
50
|
+
default: this.values.allocationBias,
|
|
51
|
+
name: 'Bit allocation bias',
|
|
52
|
+
description:
|
|
53
|
+
'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.',
|
|
54
|
+
range: [0.5, 3.0],
|
|
55
|
+
step: 0.01,
|
|
56
|
+
},
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
// Apply user-provided options
|
|
@@ -113,6 +122,10 @@ class EncoderOptions {
|
|
|
113
122
|
return this.values.transientThresholdHigh
|
|
114
123
|
}
|
|
115
124
|
|
|
125
|
+
get allocationBias() {
|
|
126
|
+
return this.values.allocationBias
|
|
127
|
+
}
|
|
128
|
+
|
|
116
129
|
getMetadata(key) {
|
|
117
130
|
return this.metadata[key]
|
|
118
131
|
}
|
|
@@ -355,7 +355,10 @@ export function mdctStage(context) {
|
|
|
355
355
|
* @returns {Function} Stage function that processes MDCT results
|
|
356
356
|
* @throws {Error} If bufferPool is not provided in context
|
|
357
357
|
*/
|
|
358
|
-
export function quantizationStage() {
|
|
358
|
+
export function quantizationStage(context) {
|
|
359
|
+
const options =
|
|
360
|
+
context?.options ?? throwError('quantizationStage: options is required')
|
|
361
|
+
|
|
359
362
|
/**
|
|
360
363
|
* Perform RDO bit allocation and quantization
|
|
361
364
|
* @param {Object} input - MDCT transform results
|
|
@@ -380,7 +383,7 @@ export function quantizationStage() {
|
|
|
380
383
|
bfuCount: selectedBfuCount,
|
|
381
384
|
allocation,
|
|
382
385
|
scaleFactorIndices,
|
|
383
|
-
} = allocateBits(bfuData, bfuSizes, bfuCount)
|
|
386
|
+
} = allocateBits(bfuData, bfuSizes, bfuCount, options.allocationBias)
|
|
384
387
|
|
|
385
388
|
const quantizedCoefficients = []
|
|
386
389
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var r={},e=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 r=new Float64Array(32),e=0;e<32;e++)r[e]=Math.sin((e+.5)*Math.PI/64);return r}(),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 r=new Float32Array(48),e=0;e<24;e++)r[e]=2*y[e],r[47-e]=2*y[e];return r}(),b=function(){for(var r=new Float32Array(24),e=0;e<24;e++)r[e]=d[2*e];return r}(),p=function(){for(var r=new Float32Array(24),e=0;e<24;e++)r[e]=d[2*e+1];return r}(),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 r=new Float64Array(64),e=0;e<64;e++)r[e]=Math.pow(2,e/3-21);return r}(),M=function(){for(var r=O[15],e=new Float64Array(r+1),t=0;t<=r;t++)e[t]=Math.pow(2,-t);return e}();function B(r,e,t,n){if(0!==n){var o=Math.floor(e/8),a=e%8;t&=(1<<n)-1;for(var i=0;i<n&&o<r.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;r[o]=r[o]&~l|c<<u-f,i+=f,o++,a=0}}}function F(r,e,t){if(0===t)return 0;for(var n=Math.floor(e/8),o=e%8,a=0,i=0;i<t&&n<r.length;){var u=8-o,f=Math.min(t-i,u),c=(1<<f)-1;a=a<<f|r[n]>>u-f&c,i+=f,n++,o=0}return a}function P(r,e,t){var n=F(r,e,t);return n>=1<<t-1?n-(1<<t):n}function T(r){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},T(r)}function C(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,I(n.key),n)}}function I(r){var e=function(r,e){if("object"!=T(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=T(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==T(e)?e:e+""}function z(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=function(r,e){if(r){if("string"==typeof r)return x(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?x(r,e):void 0}}(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,o=function(){};return{s:o,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(r){throw r},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(r)},n:function(){var r=t.next();return i=r.done,r},e:function(r){u=!0,a=r},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function x(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function E(r){var e=new Uint8Array(o),t=new DataView(e.buffer),n=i.indexOf(r.nBfu),a=2-r.blockModes[0]<<14|2-r.blockModes[1]<<12|3-r.blockModes[2]<<10|n<<5;t.setUint16(0,a,!1);for(var u=16,f=0;f<r.nBfu;f++)B(e,u,r.wordLengthIndices[f],4),u+=4;for(var c=0;c<r.nBfu;c++)B(e,u,r.scaleFactorIndices[c],6),u+=6;for(var l=0;l<r.nBfu;l++){var s=O[r.wordLengthIndices[l]];if(s>0){var v,h=z(r.quantizedCoefficients[l]);try{for(h.s();!(v=h.n()).done;){var y=v.value;B(e,u,y<0?y+(1<<s):y,s),u+=s}}catch(r){h.e(r)}finally{h.f()}}}return e[209]=0,e[210]=0,e[211]=0,e}function q(r){if(r.length!==o)throw new Error("Frame must be ".concat(o," bytes"));for(var e=new DataView(r.buffer,r.byteOffset,r.byteLength).getUint16(0,!1),t=[2-(e>>14&3),2-(e>>12&3),3-(e>>10&3)],n=i[e>>5&7],u=16,f=new Int32Array(n),c=0;c<n;c++)f[c]=F(r,u,4),u+=4;for(var l=new Int32Array(n),s=0;s<n;s++)l[s]=F(r,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(r,u,y),u+=y;v.push(b)}return{nBfu:n,scaleFactorIndices:l,wordLengthIndices:f,quantizedCoefficients:v,blockModes:t}}var _=function(){return r=function r(){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r)},o=[{key:"createHeader",value:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=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(r);return a.set(u.subarray(0,Math.min(u.length,255)),4),i.setUint32(260,e,!0),a[264]=o,a}},{key:"parseHeader",value:function(r){if(r.length!==n)throw new Error("Header must be ".concat(n," bytes"));for(var e=0;e<t.length;e++)if(r[e]!==t[e])throw new Error("Invalid AEA file");var o=new DataView(r.buffer,r.byteOffset,r.byteLength),a=r.indexOf(0,4),i=-1===a?256:a-4;return{title:(new TextDecoder).decode(r.subarray(4,4+i)),frameCount:o.getUint32(260,!0),channelCount:r[264]}}}],(e=null)&&C(r.prototype,e),o&&C(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,e,o}();function D(r){return D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},D(r)}function U(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})),t.push.apply(t,n)}return t}function H(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?U(Object(t),!0).forEach(function(e){L(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):U(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}function L(r,e,t){return(e=V(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function W(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,a,i,u=[],f=!0,c=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);f=!0);}catch(r){c=!0,o=r}finally{try{if(!f&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(c)throw o}}return u}}(r,e)||function(r,e){if(r){if("string"==typeof r)return G(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?G(r,e):void 0}}(r,e)||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(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function N(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,V(n.key),n)}}function V(r){var e=function(r,e){if("object"!=D(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=D(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==D(e)?e:e+""}var R=function(){return r=function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),this.values={transientThresholdLow:1,transientThresholdMid:1.5,transientThresholdHigh:2},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}},e&&this.setOptions(e)},(e=[{key:"setOptions",value:function(r){for(var e=0,t=Object.entries(r);e<t.length;e++){var n=W(t[e],2),o=n[0],a=n[1];o in this.values&&this.setValue(o,a)}}},{key:"setValue",value:function(r,e){if(!(r in this.metadata))throw new Error("Unknown option: ".concat(r));var t=W(this.metadata[r].range,2),n=t[0],o=t[1];if(e<n||e>o)throw new Error("Value for ".concat(r," must be between ").concat(n," and ").concat(o,", got ").concat(e));this.values[r]=e}},{key:"getValue",value:function(r){if(!(r in this.values))throw new Error("Unknown option: ".concat(r));return this.values[r]}},{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:"getMetadata",value:function(r){return this.metadata[r]}},{key:"getAllMetadata",value:function(){return H({},this.metadata)}},{key:"reset",value:function(){for(var r=0,e=Object.entries(this.metadata);r<e.length;r++){var t=W(e[r],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(r.prototype,e),t&&N(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,e,t}();function $(r){throw new Error(r)}function J(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];var o=t.map(function(e){return e(r)});return function(r){return o.reduce(function(r,e){return e(r)},r)}}function K(r,e){for(var t=e[r.length],n=0;n<r.length;n++)t[n]=r[r.length-1-n];return t}function Q(r,e){var t,n,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=r.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(e),u.set(r,e.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(r,e,t){var n,o,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=r.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=r[c],s=e[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(r){return Y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Y(r)}function Z(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,rr(n.key),n)}}function rr(r){var e=function(r,e){if("object"!=Y(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Y(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Y(e)?e:e+""}var er=function(){return r=function r(){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r)},t=[{key:"fft",value:function(r,e){var t=r.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=[r[a],r[o]];r[o]=f[0],r[a]=f[1];var c=[e[a],e[o]];e[o]=c[0],e[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=r[w],k=e[w],A=r[g],O=e[g],j=A*b-O*p,M=A*p+O*b;r[w]=S+j,e[w]=k+M,r[g]=S-j,e[g]=k-M;var B=b*h-p*y;p=b*y+p*h,b=B}}}}],(e=null)&&Z(r.prototype,e),t&&Z(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,e,t}();function tr(r){return tr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},tr(r)}function nr(r,e,t){return e=ar(e),function(r,e){if(e&&("object"==tr(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}(r)}(r,or()?Reflect.construct(e,t||[],ar(r).constructor):e.apply(r,t))}function or(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(r){}return(or=function(){return!!r})()}function ar(r){return ar=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ar(r)}function ir(r,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&ur(r,e)}function ur(r,e){return ur=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,e){return r.__proto__=e,r},ur(r,e)}function fr(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,lr(n.key),n)}}function cr(r,e,t){return e&&fr(r.prototype,e),t&&fr(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function lr(r){var e=function(r,e){if("object"!=tr(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=tr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==tr(e)?e:e+""}function sr(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var vr=cr(function r(e,t){sr(this,r),this.size=e,this.halfSize=e>>1,this.quarterSize=e>>2,this.fftSize=this.halfSize>>1;var n=2*Math.PI/(8*e),o=2*Math.PI/e,a=Math.sqrt(t/e);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)}}),hr=function(){function r(e,t){return sr(this,r),nr(this,r,[e,t])}return ir(r,vr),cr(r,[{key:"transform",value:function(r){var e,t,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=null!==(e=null==o?void 0:o[this.fftSize])&&void 0!==e?e:$("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=r[c-1-l]+r[s],d=r[v]-r[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=r[c-1-m]-r[g],O=r[S]+r[k],j=this.sinCosTable[m],M=this.sinCosTable[m+1];i[w]=A*j+O*M,u[w]=O*j-A*M}er.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],I=u[F];B[2*F]=-C*P-I*T,B[this.halfSize-1-2*F]=-C*T+I*P}return B}}])}(),yr=function(){function r(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return sr(this,r),nr(this,r,[e,t||e])}return ir(r,vr),cr(r,[{key:"transform",value:function(r){var e,t,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=null!==(e=null==o?void 0:o[this.fftSize])&&void 0!==e?e:$("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=-r[s],h=-r[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}er.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],I=T*F+C*P,z=T*P-C*F;b[c-1-M]=I,b[M-f]=-I,b[f+M]=z,b[5*f-1-M]=z}return b}}])}(),dr=new hr(64,.5),br=new hr(l,.5),pr=new hr(s,1),mr=new yr(64,512),wr=new yr(l,2048),gr=new yr(s,2048);function Sr(r,e,t){for(var n=r.length,o=new Float32Array(2*n),a=0;a<n;a++){var i=t[a],u=t[2*n-1-a],f=r[a],c=e[n-1-a];o[a]=f*u-c*i,o[2*n-1-a]=f*i+c*u}return o}function kr(r,e,t){var n=r.length,o=new Int32Array(n);if(0===t||0===e)return o.fill(0,0,n),o;for(var a=(1<<t-1)-1,i=a/j[e],u=a,f=-a,c=0;c<n;c++){var l=r[c]*i,s=l+(l>=0?.5:-.5)|0;o[c]=s>u?u:s<f?f:s}return o}function Ar(r,e,t){if(0===t||0===e)return new Float32Array(r.length);for(var n=j[e],o=(1<<t-1)-1,a=new Float32Array(r.length),i=0;i<r.length;i++)a[i]=r[i]*n/o;return a}function Or(r,e,t){var n=t,o=function(r,e,t,n){for(var o=new Int32Array(52),a=new Int32Array(r),i=[],u=[],f=function(r,e,t){var n=o[r],a=j[n];if(0===a)return 0;var i=0|O[e],u=0|O[t];return a*((0===i?2:M[i])-M[u])},c=0;c<r;c++){var l=0|t[c];if(0!==l){var s=jr(e[c].subarray(0,l));if(o[c]=s,0!==s){var v=0,h=1,y=O[h]-O[v]|0;if(!(y<=0)){var d=f(c,v,h);i.push(c),u.push(d/y)}}}}for(var b=(i.length>>1)-1;b>=0;b--)Br(i,u,b);for(;n>0&&i.length>0;){var p=i[0],m=0|a[p],w=m+1,g=0|t[p],S=(O[w]-O[m]|0)*g;if(S>n||S<=0)Mr(i,u);else if(n-=S,a[p]=w,w<15){var k=w+1,A=O[k]-O[w]|0;A>0?(u[0]=f(p,w,k)/A,Br(i,u,0)):Mr(i,u)}else Mr(i,u)}return{wordLengths:a,scaleFactorIndices:o}}(n,r,e,1656-10*n);return{bfuCount:n,allocation:o.wordLengths,scaleFactorIndices:o.scaleFactorIndices}}function jr(r){for(var e=0,t=0;t<r.length;t++){var n=Math.abs(r[t]);n>e&&(e=n)}if(0===e)return 0;var o=Math.ceil(3*(Math.log2(e)+21));return Math.max(0,Math.min(63,o))}function Mr(r,e){var t=r.length-1;r[0]=r[t],e[0]=e[t],r.pop(),e.pop(),r.length&&Br(r,e,0)}function Br(r,e,t){for(var n=r.length,o=t,a=r[o],i=e[o];;){var u=1+(o<<1),f=u+1,c=o,l=i;if(u<n&&e[u]>l&&(c=u,l=e[u]),f<n&&e[f]>l&&(c=f),c===o)break;r[o]=r[c],e[o]=e[c],o=c}r[o]=a,e[o]=i}function Fr(r){return Fr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Fr(r)}function Pr(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,Cr(n.key),n)}}function Tr(r,e,t){return e&&Pr(r.prototype,e),t&&Pr(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function Cr(r){var e=function(r,e){if("object"!=Fr(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Fr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Fr(e)?e:e+""}var Ir=Tr(function r(){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),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 zr(r,e,t){if(!e)return!1;var n=function(r,e){var t=function(r,e){for(var t=0,n=0,o=0;o<r.length;o++){var a=Math.abs(r[o]),i=a-Math.abs(e[o]);i>0&&(t+=i),n+=a*a}var u=Math.sqrt(n)||1e-6;return t/u}(r,e),n=xr(r),o=xr(e),a=Math.abs(n-o),i=Er(r),u=Er(e),f=Math.abs(i-u),c=function(r,e){for(var t=0,n=0,o=0;o<r.length;o++)t+=r[o]*r[o],n+=e[o]*e[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)}(r,e);return{spectralFlux:t,flatnessChange:a,hfChange:f,energyChange:c}}(r,e),o=function(r){var e=r.spectralFlux,t=r.flatnessChange,n=r.hfChange,o=r.energyChange,a=e,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 xr(r){for(var e=0,t=0,n=0,o=0;o<r.length;o++){var a=Math.abs(r[o]);a>1e-10&&(e+=Math.log(a),t+=a,n++)}if(0===n)return 0;var i=Math.exp(e/n),u=t/n;return u>1e-10?i/u:0}function Er(r){for(var e=Math.floor(r.length/2),t=0,n=0,o=0;o<e;o++)t+=r[o]*r[o];for(var a=e;a<r.length;a++)n+=r[a]*r[a];var i=t+n;return i>0?n/i:0}function qr(r){var e,t=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:$("qmfAnalysisStage: bufferPool is required"),n=t.qmfDelays;return function(r){var e=Q(r,n.lowBand,t.qmfWorkBuffers);n.lowBand=e.newDelay;var o=Q(e.lowBand,n.midBand,t.qmfWorkBuffers);n.midBand=o.newDelay;var a=t.qmfWorkBuffers.highBandDelay[e.highBand.length];a.set(n.highBand),a.set(e.highBand,n.highBand.length);var i=a.slice(0,e.highBand.length);return n.highBand=a.slice(e.highBand.length),{bands:[o.lowBand,o.highBand,i]}}}function _r(r){var e,t,n=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:$("blockSelectorStage: bufferPool is required"),o=null!==(t=null==r?void 0:r.options)&&void 0!==t?t:$("blockSelectorStage: options is required");return function(r){var e=r.bands,t=[128,128,256],a=e.map(function(r,e){var a=function(r,e){var t=new Float32Array(e),n=new Float32Array(e),o=Math.min(r.length,e);t.set(r.subarray(0,o)),er.fft(t,n);for(var a=new Float32Array(e/2),i=0;i<e/2;i++)a[i]=Math.sqrt(t[i]*t[i]+n[i]*n[i]);return a}(r,t[e]),i=zr(a,n.transientDetection[e],o.transientThresholdLow);return n.transientDetection[e]=a,i*Math.max(e+1,2)});return{bands:e,blockModes:a}}}function Dr(r){var e,t=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:$("mdctStage: bufferPool is required"),n=t.mdctOverlap,o=[br,br,pr];function a(r,e,t,n,a){var u=m[e];return 0===t?function(r,e,t,n,o,a){var u=2===e?s:l,f=a.transformBuffers[u];f.fill(0),f.set(o,t.windowStart),i(r,o,t.size),f.set(r,t.windowStart+32);var c=n.transform(f,a.mdctBuffers);e>0&&(c=K(c,a.reversalBuffers));return c}(r,e,u,o[e],n,a):function(r,e,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=r.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=dr.transform(s,o.mdctBuffers);e>0&&(v=K(v,o.reversalBuffers)),u.set(v,c)}return u}(r,e,u,n,a)}function i(r,e,t){for(var n=t-g,o=0;o<g;o++){var a=r[n+o];e[o]=v[o]*a,r[n+o]=a*v[31-o]}}return function(r){var e=r.bands,o=r.blockModes,i=r.originalFrame,u=new Float32Array(512);return e.forEach(function(r,e){var i=a(r,e,o[e],n[e],t),f=function(r){return 0===r?0:1===r?128:256}(e);u.set(i,f)}),{bands:e,coefficients:u,blockModes:o,originalFrame:i}}}function Ur(){return function(r){for(var e=r.coefficients,t=r.blockModes,n=function(r,e){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===e[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(r.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(r.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}}(e,t),o=n.bfuData,i=n.bfuSizes,l=Or(o,i,n.bfuCount),s=l.bfuCount,v=l.allocation,h=l.scaleFactorIndices,y=[],d=0;d<s;d++){var b=o[d].subarray(0,i[d]),p=v[d],m=O[p],w=kr(b,h[d],m);y.push(w)}return{nBfu:s,scaleFactorIndices:h,wordLengthIndices:v.slice(0,s),quantizedCoefficients:y,blockModes:t}}}function Hr(){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 Ir},qr,_r,Dr,Ur)}function Lr(){return function(r){for(var e=new Float32Array(512),t=r.nBfu,n=r.scaleFactorIndices,o=r.wordLengthIndices,a=r.quantizedCoefficients,i=r.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=Ar(a[l],n[l],s);e.set(y,h)}}return{coefficients:e,blockModes:i}}}function Wr(r){var e,t=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:$("imdctStage: bufferPool is required"),n=t.imdctOverlap,o=[wr,wr,gr];function a(r,e,t,n,a,i){return 0===t?function(r,e,t,n,o,a){var i=r;e>0&&(i=K(r,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=Sr(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===e?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)}(r,e,n,a,i,o[e]):function(r,e,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=r.slice(c,c+w);e>0&&(s=K(s,n.reversalBuffers));for(var h=mr.transform(s,n.mdctBuffers),y=h.length/4,d=0;d<w;d++)i[f+d]=h[y+d];var b=Sr(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)}(r,e,n,a,i)}return function(r){var e=r.coefficients,o=r.blockModes;return m.map(function(r,i){var u=function(r,e){var t=[0,128,256,512];return r.subarray(t[e],t[e+1])}(e,i);return a(u,i,o[i],n[i],t,r)})}}function Gr(r){var e,t=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:$("qmfSynthesisStage: bufferPool is required"),n=t.qmfDelays;return function(r){var e=t.qmfWorkBuffers.highBandDelay[r[2].length];e.set(n.highBand),e.set(r[2],n.highBand.length);var o=e.slice(0,2*r[0].length);n.highBand=e.slice(2*r[0].length);var a=X(r[0],r[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 Nr(){return J({bufferPool:arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Ir},Lr,Wr,Gr)}function Vr(r){return Vr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Vr(r)}function Rr(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=Qr(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,o=function(){};return{s:o,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(r){throw r},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(r)},n:function(){var r=t.next();return i=r.done,r},e:function(r){u=!0,a=r},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function $r(r,e,t,n,o,a,i){try{var u=r[a](i),f=u.value}catch(r){return void t(r)}u.done?e(f):Promise.resolve(f).then(n,o)}function Jr(r){return function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(r){$r(a,n,o,i,u,"next",r)}function u(r){$r(a,n,o,i,u,"throw",r)}i(void 0)})}}function Kr(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,a,i,u=[],f=!0,c=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);f=!0);}catch(r){c=!0,o=r}finally{try{if(!f&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(c)throw o}}return u}}(r,e)||Qr(r,e)||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 Qr(r,e){if(r){if("string"==typeof r)return Xr(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Xr(r,e):void 0}}function Xr(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function Yr(r){if(null!=r){var e=r["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],t=0;if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length))return{next:function(){return r&&t>=r.length&&(r=void 0),{value:r&&r[t++],done:!r}}}}throw new TypeError(Vr(r)+" is not iterable")}function Zr(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var r,e,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 re(c,"_invoke",function(t,n,o){var a,u,f,c=0,l=o||[],s=!1,v={p:0,n:0,v:r,a:h,f:h.bind(r,4),d:function(e,t){return a=e,u=0,f=r,v.n=t,i}};function h(t,n){for(u=t,f=n,e=0;!s&&c&&!o&&e<l.length;e++){var o,a=l[e],h=v.p,y=a[2];t>3?(o=y===n)&&(f=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=r):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;(e=u<2?r: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"),e=a[o]){if(!(e=e.call(a,f)))throw TypeError("iterator result is not an object");if(!e.done)return e;f=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(f=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=v.n<0)?f:t.call(n,v))!==i)break}catch(e){a=r,u=1,f=e}finally{c=1}}return{value:e,done:s}}}(t,o,a),!0),c}var i={};function u(){}function f(){}function c(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(re(e={},n,function(){return this}),e),s=c.prototype=u.prototype=Object.create(l);function v(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,c):(r.__proto__=c,re(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return f.prototype=c,re(s,"constructor",c),re(c,"constructor",f),f.displayName="GeneratorFunction",re(c,o,"GeneratorFunction"),re(s),re(s,o,"Generator"),re(s,n,function(){return this}),re(s,"toString",function(){return"[object Generator]"}),(Zr=function(){return{w:a,m:v}})()}function re(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}re=function(r,e,t,n){if(e)o?o(r,e,{value:t,enumerable:!n,configurable:!n,writable:!n}):r[e]=t;else{var a=function(e,t){re(r,e,function(r){return this._invoke(e,t,r)})};a("next",0),a("throw",1),a("return",2)}},re(r,e,t,n)}function ee(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,te(n.key),n)}}function te(r){var e=function(r,e){if("object"!=Vr(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Vr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Vr(e)?e:e+""}function ne(r){return function(){return new oe(r.apply(this,arguments))}}function oe(r){var e,t;function n(e,t){try{var a=r[e](t),i=a.value,u=i instanceof ue;Promise.resolve(u?i.v:i).then(function(t){if(u){var f="return"===e?"return":"next";if(!i.k||t.done)return n(f,t);t=r[f](t).value}o(a.done?"return":"normal",t)},function(r){n("throw",r)})}catch(r){o("throw",r)}}function o(r,o){switch(r){case"return":e.resolve({value:o,done:!0});break;case"throw":e.reject(o);break;default:e.resolve({value:o,done:!1})}(e=e.next)?n(e.key,e.arg):t=null}this._invoke=function(r,o){return new Promise(function(a,i){var u={key:r,arg:o,resolve:a,reject:i,next:null};t?t=t.next=u:(e=t=u,n(r,o))})},"function"!=typeof r.return&&(this.return=void 0)}function ae(r){return new ue(r,0)}function ie(r){var e={},t=!1;function n(e,n){return t=!0,n=new Promise(function(t){t(r[e](n))}),{done:!1,value:new ue(n,1)}}return e["undefined"!=typeof Symbol&&Symbol.iterator||"@@iterator"]=function(){return this},e.next=function(r){return t?(t=!1,r):n("next",r)},"function"==typeof r.throw&&(e.throw=function(r){if(t)throw t=!1,r;return n("throw",r)}),"function"==typeof r.return&&(e.return=function(r){return t?(t=!1,r):n("return",r)}),e}function ue(r,e){this.v=r,this.k=e}function fe(r){var e,t,n,o=2;for("undefined"!=typeof Symbol&&(t=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(t&&null!=(e=r[t]))return e.call(r);if(n&&null!=(e=r[n]))return new ce(e.call(r));t="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function ce(r){function e(r){if(Object(r)!==r)return Promise.reject(new TypeError(r+" is not an object."));var e=r.done;return Promise.resolve(r.value).then(function(r){return{value:r,done:e}})}return ce=function(r){this.s=r,this.n=r.next},ce.prototype={s:null,n:null,next:function(){return e(this.n.apply(this.s,arguments))},return:function(r){var t=this.s.return;return void 0===t?Promise.resolve({value:r,done:!0}):e(t.apply(this.s,arguments))},throw:function(r){var t=this.s.return;return void 0===t?Promise.reject(r):e(t.apply(this.s,arguments))}},new ce(r)}oe.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},oe.prototype.next=function(r){return this._invoke("next",r)},oe.prototype.throw=function(r){return this._invoke("throw",r)},oe.prototype.return=function(r){return this._invoke("return",r)};var le=function(){function r(){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r)}return t=r,a=null,i=[{key:"encodeStream",value:function(e){return ne(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Zr().m(function n(){var o,a,i,u;return Zr().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(Yr(ie(fe(r._encodeMonoStream(e,i,u)))),1);case 1:case 3:n.n=5;break;case 2:if(2!==a){n.n=4;break}return n.d(Yr(ie(fe(r._encodeStereoStream(e,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(r,e,t){return ne(Zr().m(function n(){var o,a,i,u,f,c,l,s,v,h,y;return Zr().w(function(n){for(;;)switch(n.n){case 0:o=t||new R,a=Hr(o),i=0,u=!1,f=!1,n.p=1,l=fe(r);case 2:return n.n=3,ae(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:e&&e(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,ae(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(r,e,t){return ne(Zr().m(function n(){var o,a,i,u,f,c,l,s,v,h,y,d,b,p,m;return Zr().w(function(n){for(;;)switch(n.n){case 0:o=t||new R,a=Hr(o),i=Hr(o),u=0,f=!1,c=!1,n.p=1,s=fe(r);case 2:return n.n=3,ae(s.next());case 3:if(!(f=!(v=n.v).done)){n.n=7;break}return h=Kr(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:e&&e(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,ae(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(e){return ne(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Zr().m(function n(){var o,a,i;return Zr().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(Yr(ie(fe(r._decodeMonoStream(e,i)))),1);case 1:case 3:n.n=5;break;case 2:if(2!==a){n.n=4;break}return n.d(Yr(ie(fe(r._decodeStereoStream(e,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(r,e){return ne(Zr().m(function t(){var n,o,a;return Zr().w(function(t){for(;;)switch(t.n){case 0:return n=Nr(),o=0,a=function(){var t=ne(Zr().m(function t(){var a,i,u,f,c,l,s,v;return Zr().w(function(t){for(;;)switch(t.n){case 0:a=!1,i=!1,t.p=1,f=fe(r);case 2:return t.n=3,ae(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:e&&e(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,ae(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(Yr(ie(fe(a()))),1);case 1:return t.a(2)}},t)}))()}},{key:"_decodeStereoStream",value:function(e,t){return ne(Zr().m(function n(){var o,a,i,u;return Zr().w(function(n){for(;;)switch(n.n){case 0:return o=Nr(),a=Nr(),i=0,u=function(){var n=ne(Zr().m(function n(){var u,f,c,l,s,v,h,y,d,b,p,m,w,g,S;return Zr().w(function(n){for(;;)switch(n.n){case 0:u=null,f=!0,c=!1,l=!1,n.p=1,v=fe(e);case 2:return n.n=3,ae(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,ae(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=r._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(Yr(ie(fe(u()))),1);case 1:return n.a(2)}},n)}))()}},{key:"frameBufferToFrames",value:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:512;return Zr().m(function t(){var n,o,a,i,u,f,c,l,s,v,h,y,d,b,p,m;return Zr().w(function(t){for(;;)switch(t.n){case 0:if(1!==(n=r.length)){t.n=4;break}o=Kr(r,1),a=o[0],i=0;case 1:if(!(i<a.length)){t.n=3;break}for(u=new Float32Array(e),f=Math.min(i+e,a.length),c=0;c<f-i;c++)u[c]=a[i+c];return t.n=2,u;case 2:i+=e,t.n=1;break;case 3:t.n=9;break;case 4:if(2!==n){t.n=8;break}l=Kr(r,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(e),b=new Float32Array(e),p=Math.min(y+e,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+=e,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=Jr(Zr().m(function r(e){var t,n,o,a,i,u,f,c;return Zr().w(function(r){for(;;)switch(r.n){case 0:t=[],n=!1,o=!1,r.p=1,i=fe(e);case 2:return r.n=3,i.next();case 3:if(!(n=!(u=r.v).done)){r.n=5;break}f=u.value,t.push(f);case 4:n=!1,r.n=2;break;case 5:r.n=7;break;case 6:r.p=6,c=r.v,o=!0,a=c;case 7:if(r.p=7,r.p=8,!n||null==i.return){r.n=9;break}return r.n=9,i.return();case 9:if(r.p=9,!o){r.n=10;break}throw a;case 10:return r.f(9);case 11:return r.f(7);case 12:return r.a(2,t)}},r,null,[[8,,9,11],[1,6,7,12]])})),function(r){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=Jr(Zr().m(function r(e){var t,n,o,a,i,u,f,c,l,s,v,h,y,d,b,p,m,w,g,S,k=arguments;return Zr().w(function(r){for(;;)switch(r.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,r.p=1,s=fe(e);case 2:return r.n=3,s.next();case 3:if(!(f=!(v=r.v).done)){r.n=5;break}h=v.value,u.push(E(h));case 4:f=!1,r.n=2;break;case 5:r.n=7;break;case 6:r.p=6,S=r.v,c=!0,l=S;case 7:if(r.p=7,r.p=8,!f||null==s.return){r.n=9;break}return r.n=9,s.return();case 9:if(r.p=9,!c){r.n=10;break}throw l;case 10:return r.f(9);case 11:return r.f(7);case 12:for(y=_.createHeader(o,u.length,i),d=y.length+u.reduce(function(r,e){return r+e.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 r.a(2,new Blob([b],{type:"application/octet-stream"}))}},r,null,[[8,,9,11],[1,6,7,12]])})),function(r){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]:e,a=Array.isArray(t)?t:[t];if(1===n)return r._createMonoWavBlob(a,o);if(2===n)return r._createStereoWavBlob(a,o);throw new Error("Unsupported channel count: ".concat(n))}},{key:"_createMonoWavBlob",value:function(e,t){var n=e.reduce(function(r,e){return r+e.length},0),o=new ArrayBuffer(44+2*n),a=new DataView(o);r._writeWavHeader(a,n,1,t);var i,u=44,f=Rr(e);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(r){f.e(r)}finally{f.f()}return new Blob([o],{type:"audio/wav"})}},{key:"_createStereoWavBlob",value:function(e,t){var n=e.reduce(function(r,e){var t=Kr(e,2),n=t[0],o=t[1];return r+Math.max(n.length,o.length)},0),o=new ArrayBuffer(44+2*n*2),a=new DataView(o);r._writeWavHeader(a,n,2,t);var i,u=44,f=Rr(e);try{for(f.s();!(i=f.n()).done;)for(var c=Kr(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(r){f.e(r)}finally{f.f()}return new Blob([o],{type:"audio/wav"})}},{key:"_writeWavHeader",value:function(r,e,t,n){var o=n*t*2,a=2*t,i=e*a,u=36+i,f=0,c=function(e,t){for(var n=0;n<t.length;n++)r.setUint8(e+n,t.charCodeAt(n))};c(f,"RIFF"),f+=4,r.setUint32(f,u,!0),c(f+=4,"WAVE"),c(f+=4,"fmt "),f+=4,r.setUint32(f,16,!0),f+=4,r.setUint16(f,1,!0),f+=2,r.setUint16(f,t,!0),f+=2,r.setUint32(f,n,!0),f+=4,r.setUint32(f,o,!0),f+=4,r.setUint16(f,a,!0),f+=2,r.setUint16(f,16,!0),c(f+=2,"data"),f+=4,r.setUint32(f,i,!0)}},{key:"parseAeaBlob",value:(u=Jr(Zr().m(function r(e){var t,a,i,u,f,c;return Zr().w(function(r){for(;;)switch(r.n){case 0:return r.n=1,e.arrayBuffer();case 1:for(t=r.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 r.a(2,{info:i,frameData:u})}},r)})),function(r){return u.apply(this,arguments)})},{key:"deserializedFrameStream",value:Zr().m(function r(e){var t,n,o,a;return Zr().w(function(r){for(;;)switch(r.n){case 0:t=Rr(e),r.p=1,t.s();case 2:if((n=t.n()).done){r.n=4;break}return o=n.value,r.n=3,q(o);case 3:r.n=2;break;case 4:r.n=6;break;case 5:r.p=5,a=r.v,t.e(a);case 6:return r.p=6,t.f(),r.f(6);case 7:return r.a(2)}},r,null,[[1,5,6,7]])})},{key:"assemblePcmFrames",value:function(r,e){if(1===e){var t,n=r.reduce(function(r,e){return r+e.length},0),o=new Float32Array(n),a=0,i=Rr(r);try{for(i.s();!(t=i.n()).done;){var u=t.value;o.set(u,a),a+=u.length}}catch(r){i.e(r)}finally{i.f()}return o}if(2===e){var f,c=r.reduce(function(r,e){var t=Kr(e,2),n=t[0],o=t[1];return r+Math.max(n.length,o.length)},0),l=new Float32Array(2*c),s=0,v=Rr(r);try{for(v.s();!(f=v.n()).done;)for(var h=Kr(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(r){v.e(r)}finally{v.f()}return l}throw new Error("Unsupported channel count: ".concat(e))}}],a&&ee(t.prototype,a),i&&ee(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,a,i,u,f,c}();function se(r){return se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},se(r)}function ve(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})),t.push.apply(t,n)}return t}function he(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?ve(Object(t),!0).forEach(function(e){ye(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ve(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}function ye(r,e,t){return(e=function(r){var e=function(r,e){if("object"!=se(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=se(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==se(e)?e:e+""}(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function de(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var r,e,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 be(c,"_invoke",function(t,n,o){var a,u,f,c=0,l=o||[],s=!1,v={p:0,n:0,v:r,a:h,f:h.bind(r,4),d:function(e,t){return a=e,u=0,f=r,v.n=t,i}};function h(t,n){for(u=t,f=n,e=0;!s&&c&&!o&&e<l.length;e++){var o,a=l[e],h=v.p,y=a[2];t>3?(o=y===n)&&(f=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=r):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;(e=u<2?r: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"),e=a[o]){if(!(e=e.call(a,f)))throw TypeError("iterator result is not an object");if(!e.done)return e;f=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(f=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=v.n<0)?f:t.call(n,v))!==i)break}catch(e){a=r,u=1,f=e}finally{c=1}}return{value:e,done:s}}}(t,o,a),!0),c}var i={};function u(){}function f(){}function c(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(be(e={},n,function(){return this}),e),s=c.prototype=u.prototype=Object.create(l);function v(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,c):(r.__proto__=c,be(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return f.prototype=c,be(s,"constructor",c),be(c,"constructor",f),f.displayName="GeneratorFunction",be(c,o,"GeneratorFunction"),be(s),be(s,o,"Generator"),be(s,n,function(){return this}),be(s,"toString",function(){return"[object Generator]"}),(de=function(){return{w:a,m:v}})()}function be(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}be=function(r,e,t,n){if(e)o?o(r,e,{value:t,enumerable:!n,configurable:!n,writable:!n}):r[e]=t;else{var a=function(e,t){be(r,e,function(r){return this._invoke(e,t,r)})};a("next",0),a("throw",1),a("return",2)}},be(r,e,t,n)}function pe(r,e,t,n,o,a,i){try{var u=r[a](i),f=u.value}catch(r){return void t(r)}u.done?e(f):Promise.resolve(f).then(n,o)}function me(r){return function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(r){pe(a,n,o,i,u,"next",r)}function u(r){pe(a,n,o,i,u,"throw",r)}i(void 0)})}}function we(r,e,t){return ge.apply(this,arguments)}function ge(){return(ge=me(de().m(function r(e,t,n){var o,a,i,u,f,c,l;return de().w(function(r){for(;;)switch(r.n){case 0:return n=null!=n?n:"encoded by carta1",r.p=1,o=le.frameBufferToFrames(e),a=e.length,i=new R(t),u=le.encodeStream(o,{channelCount:a,encoderOptions:i}),r.n=2,le.collectFrames(u);case 2:return f=r.v,r.n=3,le.createAeaBlob(f,{title:n,channelCount:a});case 3:return c=r.v,r.a(2,{aeaBlob:c});case 4:throw r.p=4,l=r.v,console.error("Worker encode error:",l),l;case 5:return r.a(2)}},r,null,[[1,4]])}))).apply(this,arguments)}function Se(){return(new R).toObject()}function ke(r){return Ae.apply(this,arguments)}function Ae(){return(Ae=me(de().m(function r(t){var n,o,a,i,u,f,c,l,s;return de().w(function(r){for(;;)switch(r.n){case 0:return n=t.header,o=t.aeaData,(a=t.info)?i=he({sampleRate:e},a):n?(u=_.parseHeader(n),i=he({sampleRate:e},u)):i={channelCount:2,sampleRate:e},f=le.deserializedFrameStream(o),c=le.decodeStream(f,{channelCount:i.channelCount}),r.n=1,le.collectFrames(c);case 1:return l=r.v,s=le.createWavBlob(l,i.channelCount,i.sampleRate),r.a(2,{wavBlob:s,info:i})}},r)}))).apply(this,arguments)}self.onmessage=function(){var r=me(de().m(function r(e){var t,n,o,a,i,u,f,c,l,s,v;return de().w(function(r){for(;;)switch(r.n){case 0:t=e.data,n=t.jobId,o=t.type,a=t.pcmData,i=t.aea,u=t.options,f=t.title,c=t.blob,r.p=1,s=o,r.n="encode"===s?2:"decode"===s?4:"parseAea"===s?6:"getEncoderOptions"===s?8:9;break;case 2:return r.n=3,we(a,u,f);case 3:return l=r.v,r.a(3,10);case 4:return r.n=5,ke(i);case 5:return l=r.v,r.a(3,10);case 6:return r.n=7,le.parseAeaBlob(c);case 7:return l=r.v,r.a(3,10);case 8:return l=Se(),r.a(3,10);case 9:throw new Error("Unknown worker message type: ".concat(o));case 10:self.postMessage({jobId:n,result:l}),r.n=12;break;case 11:r.p=11,v=r.v,console.error("Worker error:",v),self.postMessage({jobId:n,error:v.message});case 12:return r.a(2)}},r,null,[[1,11]])}));return function(e){return r.apply(this,arguments)}}();var Oe=self;for(var je in r)Oe[je]=r[je];r.__esModule&&Object.defineProperty(Oe,"__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,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});
|
|
2
2
|
//# sourceMappingURL=carta1-worker.min.js.map
|