| 'use strict';var n;function aa(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}}var v=typeof Object.defineProperties=="function"?Object.defineProperty:function(a,b,d){if(a==Array.prototype||a==Object.prototype)return a;a[b]=d.value;return a}; |
| function ba(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var d=a[b];if(d&&d.Math==Math)return d}throw Error("Cannot find global object");}var w=ba(this);function x(a,b){if(b)a:{var d=w;a=a.split(".");for(var g=0;g<a.length-1;g++){var k=a[g];if(!(k in d))break a;d=d[k]}a=a[a.length-1];g=d[a];b=b(g);b!=g&&b!=null&&v(d,a,{configurable:!0,writable:!0,value:b})}} |
| x("Symbol",function(a){function b(l){if(this instanceof b)throw new TypeError("Symbol is not a constructor");return new d(g+(l||"")+"_"+k++,l)}function d(l,f){this.g=l;v(this,"description",{configurable:!0,writable:!0,value:f})}if(a)return a;d.prototype.toString=function(){return this.g};var g="jscomp_symbol_"+(Math.random()*1E9>>>0)+"_",k=0;return b}); |
| x("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),d=0;d<b.length;d++){var g=w[b[d]];typeof g==="function"&&typeof g.prototype[a]!="function"&&v(g.prototype,a,{configurable:!0,writable:!0,value:function(){return ca(aa(this))}})}return a});function ca(a){a={next:a};a[Symbol.iterator]=function(){return this};return a} |
| function da(a){return ea(a,a)}function ea(a,b){a.raw=b;Object.freeze&&(Object.freeze(a),Object.freeze(b));return a}function y(a){var b=typeof Symbol!="undefined"&&Symbol.iterator&&a[Symbol.iterator];if(b)return b.call(a);if(typeof a.length=="number")return{next:aa(a)};throw Error(String(a)+" is not an iterable or ArrayLike");}function fa(a){for(var b,d=[];!(b=a.next()).done;)d.push(b.value);return d}function z(){this.l=!1;this.h=null;this.i=void 0;this.g=1;this.u=0;this.j=null} |
| function A(a){if(a.l)throw new TypeError("Generator is already running");a.l=!0}z.prototype.o=function(a){this.i=a};function B(a,b){a.j={ja:b,la:!0};a.g=a.u}z.prototype.return=function(a){this.j={return:a};this.g=this.u};function C(a,b,d){a.g=d;return{value:b}}function ha(a){this.g=new z;this.h=a}function ia(a,b){A(a.g);var d=a.g.h;if(d)return D(a,"return"in d?d["return"]:function(g){return{value:g,done:!0}},b,a.g.return);a.g.return(b);return I(a)} |
| function D(a,b,d,g){try{var k=b.call(a.g.h,d);if(!(k instanceof Object))throw new TypeError("Iterator result "+k+" is not an object");if(!k.done)return a.g.l=!1,k;var l=k.value}catch(f){return a.g.h=null,B(a.g,f),I(a)}a.g.h=null;g.call(a.g,l);return I(a)}function I(a){for(;a.g.g;)try{var b=a.h(a.g);if(b)return a.g.l=!1,{value:b.value,done:!1}}catch(d){a.g.i=void 0,B(a.g,d)}a.g.l=!1;if(a.g.j){b=a.g.j;a.g.j=null;if(b.la)throw b.ja;return{value:b.return,done:!0}}return{value:void 0,done:!0}} |
| function ja(a){this.next=function(b){A(a.g);a.g.h?b=D(a,a.g.h.next,b,a.g.o):(a.g.o(b),b=I(a));return b};this.throw=function(b){A(a.g);a.g.h?b=D(a,a.g.h["throw"],b,a.g.o):(B(a.g,b),b=I(a));return b};this.return=function(b){return ia(a,b)};this[Symbol.iterator]=function(){return this}}function ka(a){function b(g){return a.next(g)}function d(g){return a.throw(g)}return new Promise(function(g,k){function l(f){f.done?g(f.value):Promise.resolve(f.value).then(b,d).then(l,k)}l(a.next())})} |
| function J(a){return ka(new ja(new ha(a)))}function la(){for(var a=Number(this),b=[],d=a;d<arguments.length;d++)b[d-a]=arguments[d];return b} |
| x("Promise",function(a){function b(f){this.h=0;this.i=void 0;this.g=[];this.u=!1;var e=this.j();try{f(e.resolve,e.reject)}catch(c){e.reject(c)}}function d(){this.g=null}function g(f){return f instanceof b?f:new b(function(e){e(f)})}if(a)return a;d.prototype.h=function(f){if(this.g==null){this.g=[];var e=this;this.i(function(){e.l()})}this.g.push(f)};var k=w.setTimeout;d.prototype.i=function(f){k(f,0)};d.prototype.l=function(){for(;this.g&&this.g.length;){var f=this.g;this.g=[];for(var e=0;e<f.length;++e){var c= |
| f[e];f[e]=null;try{c()}catch(h){this.j(h)}}}this.g=null};d.prototype.j=function(f){this.i(function(){throw f;})};b.prototype.j=function(){function f(h){return function(m){c||(c=!0,h.call(e,m))}}var e=this,c=!1;return{resolve:f(this.M),reject:f(this.l)}};b.prototype.M=function(f){if(f===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(f instanceof b)this.O(f);else{a:switch(typeof f){case "object":var e=f!=null;break a;case "function":e=!0;break a;default:e=!1}e?this.L(f):this.o(f)}}; |
| b.prototype.L=function(f){var e=void 0;try{e=f.then}catch(c){this.l(c);return}typeof e=="function"?this.da(e,f):this.o(f)};b.prototype.l=function(f){this.F(2,f)};b.prototype.o=function(f){this.F(1,f)};b.prototype.F=function(f,e){if(this.h!=0)throw Error("Cannot settle("+f+", "+e+"): Promise already settled in state"+this.h);this.h=f;this.i=e;this.h===2&&this.N();this.K()};b.prototype.N=function(){var f=this;k(function(){if(f.U()){var e=w.console;typeof e!=="undefined"&&e.error(f.i)}},1)};b.prototype.U= |
| function(){if(this.u)return!1;var f=w.CustomEvent,e=w.Event,c=w.dispatchEvent;if(typeof c==="undefined")return!0;typeof f==="function"?f=new f("unhandledrejection",{cancelable:!0}):typeof e==="function"?f=new e("unhandledrejection",{cancelable:!0}):(f=w.document.createEvent("CustomEvent"),f.initCustomEvent("unhandledrejection",!1,!0,f));f.promise=this;f.reason=this.i;return c(f)};b.prototype.K=function(){if(this.g!=null){for(var f=0;f<this.g.length;++f)l.h(this.g[f]);this.g=null}};var l=new d;b.prototype.O= |
| function(f){var e=this.j();f.P(e.resolve,e.reject)};b.prototype.da=function(f,e){var c=this.j();try{f.call(e,c.resolve,c.reject)}catch(h){c.reject(h)}};b.prototype.then=function(f,e){function c(r,t){return typeof r=="function"?function(F){try{h(r(F))}catch(G){m(G)}}:t}var h,m,q=new b(function(r,t){h=r;m=t});this.P(c(f,h),c(e,m));return q};b.prototype.catch=function(f){return this.then(void 0,f)};b.prototype.P=function(f,e){function c(){switch(h.h){case 1:f(h.i);break;case 2:e(h.i);break;default:throw Error("Unexpected state: "+ |
| h.h);}}var h=this;this.g==null?l.h(c):this.g.push(c);this.u=!0};b.resolve=g;b.reject=function(f){return new b(function(e,c){c(f)})};b.race=function(f){return new b(function(e,c){for(var h=y(f),m=h.next();!m.done;m=h.next())g(m.value).P(e,c)})};b.all=function(f){var e=y(f),c=e.next();return c.done?g([]):new b(function(h,m){function q(F){return function(G){r[F]=G;t--;t==0&&h(r)}}var r=[],t=0;do r.push(void 0),t++,g(c.value).P(q(r.length-1),m),c=e.next();while(!c.done)})};return b}); |
| function K(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var ma=typeof Object.assign=="function"?Object.assign:function(a,b){for(var d=1;d<arguments.length;d++){var g=arguments[d];if(g)for(var k in g)K(g,k)&&(a[k]=g[k])}return a};x("Object.assign",function(a){return a||ma}); |
| x("String.prototype.endsWith",function(a){return a?a:function(b,d){if(this==null)throw new TypeError("The 'this' value for String.prototype.endsWith must not be null or undefined");if(b instanceof RegExp)throw new TypeError("First argument to String.prototype.endsWith must not be a regular expression");d===void 0&&(d=this.length);d=Math.max(0,Math.min(d|0,this.length));for(var g=b.length;g>0&&d>0;)if(this[--d]!=b[--g])return!1;return g<=0}}); |
| x("WeakMap",function(a){function b(c){this.g=(e+=Math.random()+1).toString();if(c){c=y(c);for(var h;!(h=c.next()).done;)h=h.value,this.set(h[0],h[1])}}function d(){}function g(c){var h=typeof c;return h==="object"&&c!==null||h==="function"}function k(c){if(!K(c,f)){var h=new d;v(c,f,{value:h})}}function l(c){var h=Object[c];h&&(Object[c]=function(m){if(m instanceof d)return m;Object.isExtensible(m)&&k(m);return h(m)})}if(function(){if(!a||!Object.seal)return!1;try{var c=Object.seal({}),h=Object.seal({}), |
| m=new a([[c,2],[h,3]]);if(m.get(c)!=2||m.get(h)!=3)return!1;m.delete(c);m.set(h,4);return!m.has(c)&&m.get(h)==4}catch(q){return!1}}())return a;var f="$jscomp_hidden_"+Math.random();l("freeze");l("preventExtensions");l("seal");var e=0;b.prototype.set=function(c,h){if(!g(c))throw Error("Invalid WeakMap key");k(c);if(!K(c,f))throw Error("WeakMap key fail: "+c);c[f][this.g]=h;return this};b.prototype.get=function(c){return g(c)&&K(c,f)?c[f][this.g]:void 0};b.prototype.has=function(c){return g(c)&&K(c, |
| f)&&K(c[f],this.g)};b.prototype.delete=function(c){return g(c)&&K(c,f)&&K(c[f],this.g)?delete c[f][this.g]:!1};return b}); |
| x("Map",function(a){function b(){var e={};return e.C=e.next=e.head=e}function d(e,c){var h=e[1];return ca(function(){if(h){for(;h.head!=e[1];)h=h.C;for(;h.next!=h.head;)return h=h.next,{done:!1,value:c(h)};h=null}return{done:!0,value:void 0}})}function g(e,c){var h=c&&typeof c;h=="object"||h=="function"?l.has(c)?h=l.get(c):(h=""+ ++f,l.set(c,h)):h="p_"+c;var m=e[0][h];if(m&&K(e[0],h))for(e=0;e<m.length;e++){var q=m[e];if(c!==c&&q.key!==q.key||c===q.key)return{id:h,list:m,index:e,m:q}}return{id:h, |
| list:m,index:-1,m:void 0}}function k(e){this[0]={};this[1]=b();this.size=0;if(e){e=y(e);for(var c;!(c=e.next()).done;)c=c.value,this.set(c[0],c[1])}}if(function(){if(!a||typeof a!="function"||!a.prototype.entries||typeof Object.seal!="function")return!1;try{var e=Object.seal({x:4}),c=new a(y([[e,"s"]]));if(c.get(e)!="s"||c.size!=1||c.get({x:4})||c.set({x:4},"t")!=c||c.size!=2)return!1;var h=c.entries(),m=h.next();if(m.done||m.value[0]!=e||m.value[1]!="s")return!1;m=h.next();return m.done||m.value[0].x!= |
| 4||m.value[1]!="t"||!h.next().done?!1:!0}catch(q){return!1}}())return a;var l=new WeakMap;k.prototype.set=function(e,c){e=e===0?0:e;var h=g(this,e);h.list||(h.list=this[0][h.id]=[]);h.m?h.m.value=c:(h.m={next:this[1],C:this[1].C,head:this[1],key:e,value:c},h.list.push(h.m),this[1].C.next=h.m,this[1].C=h.m,this.size++);return this};k.prototype.delete=function(e){e=g(this,e);return e.m&&e.list?(e.list.splice(e.index,1),e.list.length||delete this[0][e.id],e.m.C.next=e.m.next,e.m.next.C=e.m.C,e.m.head= |
| null,this.size--,!0):!1};k.prototype.clear=function(){this[0]={};this[1]=this[1].C=b();this.size=0};k.prototype.has=function(e){return!!g(this,e).m};k.prototype.get=function(e){return(e=g(this,e).m)&&e.value};k.prototype.entries=function(){return d(this,function(e){return[e.key,e.value]})};k.prototype.keys=function(){return d(this,function(e){return e.key})};k.prototype.values=function(){return d(this,function(e){return e.value})};k.prototype.forEach=function(e,c){for(var h=this.entries(),m;!(m=h.next()).done;)m= |
| m.value,e.call(c,m[1],m[0],this)};k.prototype[Symbol.iterator]=k.prototype.entries;var f=0;return k});x("Promise.prototype.finally",function(a){return a?a:function(b){return this.then(function(d){return Promise.resolve(b()).then(function(){return d})},function(d){return Promise.resolve(b()).then(function(){throw d;})})}});x("globalThis",function(a){return a||w});var L=!1,N=!1,O;function na(a,b,d){a.addEventListener("change",function(){b.controls=a.checked;d.controls=a.checked})} |
| function oa(a){O=a;N=L=!1;O.B.addEventListener("click",pa);O.I.addEventListener("click",function(){N=!1;P();Q();O.timeline.redraw()});O.G.addEventListener("click",function(){N=!0;P();Q();O.timeline.redraw()});O.s.addEventListener("ended",qa);O.v.addEventListener("ended",qa);O.timeline.setIsBinauralGetter(function(){return N});O.timeline.setTimeControlGetter(ra);O.timeline.setTimeControlSetter(sa);O.B.textContent="\u23f5";P();Q()} |
| function pa(){L?ta():(L=!0,O.s.play(),O.v.play(),O.timeline.play(),O.video.hidden||O.video.play(),O.B.textContent="\u23f8")}function ra(){return O.s.currentTime/O.s.duration}function sa(a){a*=O.s.duration;O.s.currentTime=a;O.v.currentTime=a;O.video.currentTime=a}function ta(){L=!1;O.s.pause();O.v.pause();O.timeline.pause();O.video.hidden||O.video.pause();O.B.textContent="\u23f5"}function P(){O.s.muted=N;O.v.muted=!N} |
| function Q(){N?(O.I.classList.remove("activeButton"),O.G.classList.add("activeButton")):(O.I.classList.add("activeButton"),O.G.classList.remove("activeButton"))}function qa(){L=!1;O.timeline.pause();O.B.textContent="\u23f5"};function ua(a,b){var d=va(b);if(d%2!==0)throw Error("Number of samples, "+d+" is not a multiple of 2");return Aa(a,d/2,Ba.bind(null,b))} |
| function Aa(a,b,d){function g(h,m){e.setUint32(h,m,!0);return h+4}function k(h,m){e.setUint16(h,m,!0);return h+2}function l(h,m){for(var q=0;q<m.length;++q)e.setUint8(h+q,m.charCodeAt(q));return h+m.length}if(a<1||b<1)throw Error("Invalid arguments to createInt16WavFile");var f=b*2*2;b=new ArrayBuffer(44+f);var e=new DataView(b);var c=l(0,"RIFF");c=g(c,36+f);c=l(c,"WAVE");c=l(c,"fmt ");c=g(c,16);c=k(c,1);c=k(c,2);c=g(c,a);c=g(c,a*2*2);c=k(c,4);c=k(c,16);c=l(c,"data");c=g(c,f);if(c!==44)throw Error("We should have written exactly 44 bytes at this point."); |
| a=new DataView(b,c);d(a);return b}function va(a){return a.reduce(function(b,d){return b+d.length},0)}function Ba(a,b){if(va(a)*2!==b.byteLength)throw Error("Input int16 length "+a.length+" does not match destination byte length "+b.byteLength);var d=0;a=y(a);for(var g=a.next();!g.done;g=a.next()){g=g.value;for(var k=0;k<g.length;++k)b.setInt16(d+2*k,g[k],!0);d+=2*g.length}};function Ca(a){var b=b===void 0?{W:150}:b;if(b.W<1)throw Error("Number of buckets must be at least 1.");a=new DataView(a,44);if(a.byteLength%2)throw Error("Amount of data does not divide evenly into int16s.");for(var d=Math.floor(a.byteLength/2/b.W),g=[],k=0,l=0,f=0;f<a.byteLength;f+=2){var e=a.getInt16(f,!0);l+=e*e;++k;if(k>=d&&(g.push(Math.sqrt(l/k)),k=l=0,g.length===b.W))break}var c=Math.max.apply(Math,[1E-6].concat(g instanceof Array?g:fa(y(g))));return g.map(function(h){return h/c})};function Da(a){a=y(a);for(var b=a.next();!b.done;b=a.next())b.value.disabled=!1};function Ea(a){var b=new Fa(a);a=Ga(b);if(!a)return null;if(a.aa!==31)return console.error("obuType is "+a.aa+", expected 31."),null;if(b.offset+4>b.g.byteLength){console.error("Trying to read offset "+b.offset+", outside of DataView range.");var d=null}else d=b.g.getUint32(b.offset,!1),b.offset+=4;if(d===null)return null;var g=R(b);if(g===null)return null;b=R(b);return b===null?null:{Aa:a,Z:d,qa:g,ea:b}}function Fa(a){this.g=a;this.offset=0} |
| function R(a){return a.offset>=a.g.byteLength?(console.error("Trying to read offset "+a.offset+", outside of DataView range."),null):a.g.getUint8(a.offset++)} |
| function S(a){a:{var b=a.g;for(var d=a.offset,g=d,k=0,l=0;;){var f=b,e=d;try{var c=f.getUint8(e)}catch(h){h instanceof RangeError?console.error("RangeError in LEB128 parsing at offset "+e+"."):console.error("Error in LEB128 parsing at offset "+e+": "+h),c=null}f=c;if(f===null){b={value:null,V:0};break a}if(l>28||l===28&&(f&240)!==0){console.error("More than 32 bits in LEB128 parsing at offset "+d+".");b={value:null,V:d-g+1};break a}k+=(f&127)<<l>>>0;if((f&128)===0)break;l+=7;++d}b={value:k,V:d-g+ |
| 1}}d=b;b=d.value;d=d.V;if(typeof b!=="number")return console.error("Failed to parse LEB128 at offset "+(a.offset-d)+"."),null;a.offset+=d;return b} |
| function Ga(a){var b=R(a);if(!b)return null;var d=(b&248)>>>3,g=!!(b&4),k=!!(b&2);b=!!(b&1);var l=S(a);if(!l)return null;var f=0,e=0;if(k){f=S(a);if(!f)return null;e=S(a);if(!e)return null}var c=null;if(b){c=S(a);if(!c)return null;if(a.offset+c>a.g.byteLength)console.error("Trying to read offset "+a.offset+", outside of DataView range."),c=null;else{var h=new Uint8Array(a.g.buffer,a.offset,c);a.offset+=c;c=h}if(!c)return null}return{aa:d,Ea:g,Ga:k,Da:b,Fa:l,Ba:f,Ca:e,za:c}};function Ha(a,b){if(a.endsWith(".mp4"))return console.log("Filename ends with .mp4, assuming it is an MP4 file."),!1;a=Ea(b);if(!a)return console.log("Failed to parse as a standalone IAMF file, assuming it is an MP4 file."),!1;console.log("Successfully parsed beginning of the file. ia_code: "+a.Z+", primary_profile: "+(a.qa+", additional_profile: ")+(a.ea+"."));if(a.Z===1767992678)return console.log("ia_code is 'iamf', so assuming it is a standalone IAMF file."),!0;console.log("ia_code does not match expected 'iamf', so assuming it is an MP4 file."); |
| return!1};var Ia=new Map([["Animated demo (3rd-order ambisonics)","./data/Animated_demo_3OA.iamf"],["Animated demo (3rd-order ambisonics + stereo)","./data/Animated_demo_3OA_and_2_0.iamf"]]); |
| function Ja(a){var b,d,g,k,l,f,e;return J(function(c){if(c.g==1){b=Ia.get(a);if(!b)return c.return(Promise.reject(Error("Demo file does not exist.")));console.log("Attempting to fetch IAMF file: "+b);d="application/octet-stream";g=performance.now();return C(c,fetch(b,{headers:{Accept:d}}),2)}if(c.g!=3){k=c.i;l=((performance.now()-g)/1E3).toFixed(3);if(!k.ok)return c.return(Promise.reject(Error("Could not load specified IAMF file: "+k.statusText)));f=k.headers.get("content-type");f!==d&&console.warn("Received content-type: "+ |
| f+" rather than "+d);return C(c,k.arrayBuffer(),3)}e=c.i;console.log("Fetched "+e.byteLength+" bytes from "+b+" in "+l+" seconds.");return c.return(e)})};function Ka(a){var b=console.log;console.log=function(k){b(k);T(a,k)};console.debug=console.info=console.log;var d=console.warn;console.warn=function(k){d(k);T(a,"WARNING: "+k)};var g=console.error;console.error=function(k){g(k);T(a,"ERROR: "+k)}}function T(a,b){var d=document.createElement("pre");d.textContent="["+(new Date).toLocaleTimeString()+"] "+b;a.appendChild(d);a.scrollTop=a.scrollHeight};function La(){var a=document.getElementById("logBox");if(!a)throw Error("No log box could be found.");var b=document.getElementById("demoFile");if(!b)throw Error("Demo file element not found");var d=document.getElementById("outputSampleRate");if(!d)throw Error("Output sample rate element not found");var g=document.getElementById("advancedSettingsCheckbox");if(!g)throw Error("No advanced settings checkbox could be found.");var k=document.getElementById("advancedSettings");if(!k)throw Error("No advanced settings div could be found."); |
| var l=document.getElementById("showAudioElementsCheckbox");if(!l)throw Error("No show audio elements checkbox could be found.");var f=document.getElementById("fileDrop");if(!f)throw Error("No file drop div could be found.");var e=document.getElementById("playPauseButton");if(!e)throw Error("No play/pause button could be found.");var c=document.getElementById("stereoButton");if(!c)throw Error("No stereo button could be found.");var h=document.getElementById("stereoPlayback");if(!h)throw Error("No stereo audio element found."); |
| var m=document.getElementById("binauralButton");if(!m)throw Error("No binaural button could be found.");var q=document.getElementById("binauralPlayback");if(!q)throw Error("No binaural audio element found.");var r=document.getElementById("videoPlayback");if(!r)throw Error("No video element found.");var t=document.getElementById("timelineCanvas");if(!t)throw Error("No timeline element found.");return{ma:a,D:b,S:d,ga:g,fa:k,ua:l,R:f,B:e,I:c,s:h,G:m,v:q,ca:r,wa:t}};var U=void 0,V=void 0;function Ma(a,b){U=a;V=b} |
| function Na(a,b,d,g,k,l,f,e){var c,h,m;J(function(q){c=!1;if(!U||U.byteLength===0)return e(c),f(),q.return();V||(console.error("No filename set for current IAMF bytes, setting to iamf_audio."),V="iamf_audio");h=new DataView(U);m=a(V,h);return m?C(q,Promise.all([Oa(d,b,k),Oa(g,b,l)]).then(function(r){var t=y(r);r=t.next().value;c=t.next().value||r}).catch(function(r){console.error("Error during decoding: ",r.message);f()}).finally(function(){e(c)}),0):(console.error("Only standalone IAMF files are supported at this point."), |
| e(c),f(),q.return())})};/* |
| |
| Copyright Google LLC |
| SPDX-License-Identifier: Apache-2.0 |
| */ |
| var Pa=globalThis.trustedTypes,W;function Qa(){var a=null;if(!Pa)return a;try{var b=function(d){return d};a=Pa.createPolicy("goog#html",{createHTML:b,createScript:b,createScriptURL:b})}catch(d){}return a};function Ra(a){this.g=a}Ra.prototype.toString=function(){return this.g+""};function Sa(a){W===void 0&&(W=Qa());var b=W;return new Ra(b?b.createScriptURL(a):a)};function X(a){this.g=a}X.prototype.toString=function(){return this.g};function Ta(a){if(a instanceof X)return a.g;throw Error("");};function Ua(a){if(typeof MediaSource!=="undefined"&&a instanceof MediaSource)return new X(URL.createObjectURL(a));var b=a.type.match(/^([^;]+)(?:;\w+=(?:\w+|"[\w;,= ]+"))*$/i);if((b==null?void 0:b.length)!==2||!(/^image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp|x-icon|heic|heif|avif|x-ms-bmp)$/i.test(b[1])||/^video\/(?:mpeg|mp4|ogg|webm|x-matroska|quicktime|x-ms-wmv)$/i.test(b[1])||/^audio\/(?:3gpp2|3gpp|aac|amr|L16|midi|mp3|mp4|mpeg|oga|ogg|opus|x-m4a|x-matroska|x-wav|wav|webm)$/i.test(b[1])||/^font\/[\w-]+$/i.test(b[1])))throw Error(""); |
| return new X(URL.createObjectURL(a))};function Va(a){var b=la.apply(1,arguments);if(b.length===0)return Sa(a[0]);for(var d=a[0],g=0;g<b.length;g++)d+=encodeURIComponent(b[g])+a[g+1];return Sa(d)};function Wa(a,b,d){a.src=Ta(Ua(new Blob([b],{type:"audio/wav"})));a.title=d};var Xa={ba:"#ccc",va:"#ccc",ha:"#8c9dd8",spacing:2,A:16,J:10,xa:4,sa:2,ra:"#ffc80c",ta:"#12b17d55"}; |
| function Ya(a){var b=b===void 0?{}:b;this.g=a;this.K=void 0;this.j=this.l=!0;this.o=!1;this.F=0;this.U=function(){return!1};this.N=function(){return-1};this.O=function(){};this.i=this.u=null;this.config=Object.assign({},Xa,b);this.h=this.g.getContext("2d",{willReadFrequently:!0});this.g.addEventListener("mousedown",this.na.bind(this));this.g.addEventListener("mousemove",this.oa.bind(this));this.g.addEventListener("mouseup",this.pa.bind(this));this.M=new ImageData(this.g.width,this.g.height);this.L= |
| new ImageData(this.g.width,this.g.height)}n=Ya.prototype;n.setIsBinauralGetter=function(a){this.U=a};n.setTimeControlGetter=function(a){this.N=a};n.setTimeControlSetter=function(a){this.O=a};n.redraw=function(){this.l||this.j||this.o||Y(this)};n.play=function(){this.o=!0;this.F=requestAnimationFrame(this.X.bind(this))};n.pause=function(){this.o=!1;cancelAnimationFrame(this.F);Y(this)}; |
| function Za(a){a.K?a.h.putImageData(a.K,0,0):(a.h.clearRect(0,0,a.g.width,a.g.height),a.h.fillStyle=a.config.ba,a.h.font="24px Google Sans",a.h.fillText("Decoding...",10,30),a.K=a.h.getImageData(0,0,a.g.width,a.g.height))} |
| function $a(a,b){a.h.clearRect(0,0,a.g.width,a.g.height);for(var d=(a.g.width-2*a.config.A-(b.length-1)*a.config.spacing)/b.length,g=a.config.A,k=d+a.config.spacing,l=a.g.height-2*a.config.J,f=a.g.height/2,e=0;e<b.length;e++){var c=Math.max(b[e]*l,a.config.xa);a.h.fillRect(g+e*k,f-c/2,d,c)}}n.na=function(a){this.l||this.j||(this.u=a)};n.oa=function(a){!this.u||this.l||this.j||(ab(this,a),this.o||Y(this))}; |
| n.pa=function(a){this.l||this.j||(ab(this,a),this.u=null,this.i?bb(this,this.i.T):bb(this,a.offsetX),this.o||Y(this))};function ab(a,b){if(a.u){var d=a.config.A,g=a.g.width-a.config.A,k=Math.max(Math.min(a.u.offsetX,g),d);b=Math.max(Math.min(b.offsetX,g),d);Math.abs(k-b)>10?a.i={T:Math.min(k,b),Y:Math.max(k,b)}:a.i=null}}function bb(a,b){a.O(Math.max(0,Math.min(1,(b-a.config.A)/(a.g.width-2*a.config.A))))}n.X=function(){this.o&&(this.i&&cb(this)>this.i.Y&&bb(this,this.i.T),Y(this),this.F=requestAnimationFrame(this.X.bind(this)))}; |
| function Y(a){a.h.clearRect(0,0,a.g.width,a.g.height);a.U()?a.h.putImageData(a.L,0,0):a.h.putImageData(a.M,0,0);a.i&&(a.h.fillStyle=a.config.ta,a.h.fillRect(a.i.T,a.config.J,a.i.Y-a.i.T,a.g.height-2*a.config.J));var b=cb(a);a.h.fillStyle=a.config.ra;a.h.fillRect(b,a.config.J,a.config.sa,a.g.height-2*a.config.J)}function cb(a){var b=a.N();return!b||b<0?a.config.A:a.config.A+b*(a.g.width-2*a.config.A)};function db(a,b){a.checked=!1;a.addEventListener("change",function(){b.hidden=!a.checked})}function eb(a,b){return{ya:a.value,H:Number(b.value)}};var fb=new Map([["Animated demo (3rd-order ambisonics)","./data/videos/Animated_demo_720_silent.mp4"],["Animated demo (3rd-order ambisonics + stereo)","./data/videos/Animated_demo_720_silent.mp4"]]); |
| function gb(a,b){var d,g,k,l;J(function(f){if(f.g==1){d=fb.get(a);if(!d)return b.src="",b.hidden=!0,f.return();console.log("Video file: "+d);return C(f,fetch(d),2)}if(f.g!=3)return g=f.i,g.ok?C(f,g.arrayBuffer(),3):(b.src="",b.hidden=!0,console.warn("Failed to load video file: "+d),f.return());k=f.i;l=new Blob([k],{type:"video/mp4"});b.src=Ta(Ua(l));b.hidden=!1;f.g=0})};function hb(a){var b=Worker;if(a instanceof Ra)a=a.g;else throw Error("");return new b(a,void 0)};var ib=da(["./decoder_worker_bundle.js"]);function Z(a,b){var d=this;this.binaural=a;this.j=b;this.g=a?"Binaural":"Stereo";a=Va(ib);this.i=hb(a);this.i.addEventListener("message",this.o.bind(this));this.i.addEventListener("error",function(g){console.log("Error from "+d.g+" worker: "+g.message)});this.i.addEventListener("messageerror",function(g){console.log("Message error from "+d.g+" worker: "+g)});this.i.postMessage({eventType:"CREATE_DECODER"})} |
| function Oa(a,b,d){var g=U,k=V;return J(function(l){if(l.g==1){if(a.j)throw Error("Worker is not ready, wait for workerReadyCallback.");console.log("Starting "+a.g+" decoding.");return C(l,new Promise(a.l.bind(a,g,k,b,d)),2)}return l.return(l.i)})} |
| Z.prototype.o=function(a){switch(a.data.eventType){case "LOG_MESSAGE":console.log(this.g+" decoder: "+a.data.message);break;case "DECODER_CREATED":this.j?(console.log(this.g+" decoder created."),this.j(),this.j=void 0):console.warn(this.g+" decoder reporting ready more than once.");break;case "DECODE_DONE":jb(this,a.data.outputBuffers);break;case "ERROR":a=a.data.message;console.error("Error from "+this.g+" decoder: "+a+".Aborting decoding.");this.h&&(this.h.reject(a),this.h=void 0);break;default:console.warn("Worker sent unhandled message: "+ |
| JSON.stringify(a,["type","data","message"])+".")}};Z.prototype.l=function(a,b,d,g,k,l){this.h={start:performance.now(),ka:b,H:d,ia:g,resolve:k,reject:l};this.i.postMessage({eventType:"DECODE_STANDALONE_IAMF",eventData:{iamfBytes:a,sampleRate:d,binaural:this.binaural}})}; |
| function jb(a,b){if(a.h){var d=a.h,g=!1;console.log(a.g+" decoding took approximately "+((performance.now()-d.start)/1E3).toFixed(1)+" seconds.");if(b&&b.length>0){g=!0;var k=(b.reduce(function(l,f){return l+f.length},0)/d.H/2).toFixed(3);console.log(a.g+" audio output is "+k+" seconds long.");k=d.ka+"_"+(a.binaural?"binaural":"loudspeakers_A")+"_"+d.H+"Hz.wav";b=ua(d.H,b);d.ia(b,k)}a.h.resolve(g);a.h=void 0}else console.log("{this.layoutString} decoder reporting done without decodingRunState present.")} |
| ;(function(){var a,b,d,g,k,l,f,e,c,h,m,q,r,t,F,G,wa;return J(function(kb){a=La();Ka(a.ma);db(a.ga,a.fa);na(a.ua,a.s,a.v);b=new Ya(a.wa);oa({B:a.B,I:a.I,G:a.G,s:a.s,v:a.v,video:a.ca,timeline:b});d=function(){a.R.classList.add("div-disabled");for(var p=y([a.D,a.S,a.B]),u=p.next();!u.done;u=p.next())u.value.disabled=!0};g=function(){O&&ta();b.l=!0;b.j=!0;Za(b);d()};k=function(p){Da([a.D,a.S]);a.R.classList.remove("div-disabled");p&&Da([a.B])};l=0;f=function(){l++;console.log(l+" worker"+(l===1?"":"s")+ |
| " ready.");l===2&&k(!1)};e=new Z(!1,f);c=new Z(!0,f);h=eb.bind(null,a.D,a.S);m=function(p,u){Wa(a.s,p,u);p=Ca(p);b.l=!1;b.i=null;b.h.fillStyle=b.config.va;$a(b,p);b.M=b.h.getImageData(0,0,b.g.width,b.g.height);b.l||b.j?Za(b):Y(b)};q=function(p,u){Wa(a.v,p,u);p=Ca(p);b.j=!1;b.i=null;b.h.fillStyle=b.config.ha;$a(b,p);b.L=b.h.getImageData(0,0,b.g.width,b.g.height);b.l||b.j?Za(b):Y(b)};r=function(){b.h.clearRect(0,0,b.g.width,b.g.height);b.h.fillStyle=b.config.ba;b.h.font="24px Google Sans";b.h.fillText("Error", |
| 10,30)};t=function(){gb(a.D.value,a.ca);Na(Ha,h().H,e,c,m,q,r,k)};F=function(){var p;return J(function(u){p=a.D.value;g();return C(u,Ja(p).then(function(H){return J(function(E){Ma(H,p);t();E.g=0})}).catch(function(H){console.error(H.message)}),0)})};a.D.addEventListener("change",function(){return J(function(p){return C(p,F(),0)})});G=function(){return J(function(p){g();t();p.g=0})};a.S.addEventListener("change",function(){return J(function(p){return C(p,G(),0)})});wa=function(p){var u,H;return J(function(E){if(E.g== |
| 1){p.preventDefault();g();var M;var xa;if((M=p.dataTransfer)==null?0:(xa=M.files)==null?0:xa.length){var ya,za;console.log("Received "+((ya=p.dataTransfer)==null?void 0:(za=ya.files)==null?void 0:za.length)+" files.");console.log("Using the first file: "+p.dataTransfer.files[0].name);M={filename:p.dataTransfer.files[0].name,data:p.dataTransfer.files[0].arrayBuffer()}}else console.error("No files found in drop."),M=void 0;u=M;if(!u){E.g=0;return}H=Ma;return C(E,u.data,3)}H(E.i,u.filename);a.D.value= |
| "";t();E.g=0})};a.R.addEventListener("dragover",function(p){p.preventDefault()});a.R.addEventListener("drop",wa);kb.g=0})})(); |