Comparing version 9.0.2 to 9.0.3
# CHANGELOG | ||
## version 9.0.3 - 2020-01-03 | ||
- Fix: remove extra field from ltxt chunks to fix wav regions labels | ||
## version 9.0.2 - 2020-01-03 | ||
@@ -4,0 +7,0 @@ - Fix: add padding byte on bext when byte number is odd to avoid writing currupted files |
@@ -50,39 +50,40 @@ try{if(!Uint8Array.prototype.slice)Object.defineProperty(Uint8Array.prototype,"slice",{value:function(begin,end){return new Uint8Array(Array.prototype.slice.call(this,begin,end))}})}catch(err){}var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.objectCreate=$jscomp.ASSUME_ES5||"function"==typeof Object.create?Object.create:function(d){var k=function(){};k.prototype=d;return new k}; | ||
};r.prototype.readLISTChunk_=function(a){var b=this.findChunk("LIST",!0);if(null!==b)for(var c=0;c<b.length;c++){var e=b[c];this.LIST.push({chunkId:e.chunkId,chunkSize:e.chunkSize,format:e.format,subChunks:[]});for(var d=0;d<e.subChunks.length;d++)this.readLISTSubChunks_(e.subChunks[d],e.format,a)}};r.prototype.readLISTSubChunks_=function(a,b,c){"adtl"==b?-1<["labl","note","ltxt"].indexOf(a.chunkId)&&(this.head=a.chunkData.start,b={chunkId:a.chunkId,chunkSize:a.chunkSize,dwName:this.readUInt32(c)}, | ||
"ltxt"==a.chunkId&&(b.dwSampleLength=this.readUInt32(c),b.dwPurposeID=this.readUInt32(c),b.dwCountry=this.readUInt16_(c),b.dwLanguage=this.readUInt16_(c),b.dwDialect=this.readUInt16_(c),b.dwCodePage=this.readUInt16_(c)),b.value=this.readZSTR_(c,this.head),this.LIST[this.LIST.length-1].subChunks.push(b)):"INFO"==b&&(this.head=a.chunkData.start,this.LIST[this.LIST.length-1].subChunks.push({chunkId:a.chunkId,chunkSize:a.chunkSize,value:this.readZSTR_(c,this.head)}))};r.prototype.readJunkChunk_=function(a){var b= | ||
this.findChunk("junk");b&&(this.junk={chunkId:b.chunkId,chunkSize:b.chunkSize,chunkData:[].slice.call(a.slice(b.chunkData.start,b.chunkData.end))})};r.prototype.readZSTR_=function(a,b){for(var c=b=void 0===b?0:b;c<a.length&&(this.head++,0!==a[c]);c++);return M(a,b,this.head-1)};r.prototype.readUInt16_=function(a){a=N(a,this.uInt16,this.head);this.head+=2;return a};var q=function(){return r.apply(this,arguments)||this};$jscomp.inherits(q,r);q.prototype.toBuffer=function(){this.uInt16.be="RIFX"===this.container; | ||
this.uInt32.be=this.uInt16.be;for(var a=[this.getJunkBytes_(),this.getDs64Bytes_(),this.getBextBytes_(),this.getFmtBytes_(),this.getFactBytes_(),v(this.data.chunkId),g(this.data.samples.length,this.uInt32),this.data.samples,this.getCueBytes_(),this.getSmplBytes_(),this.getLISTBytes_()],b=0,c=0;c<a.length;c++)b+=a[c].length;c=new Uint8Array(b+12);var e=Z(this.container,c,0);e=S(b+4,this.uInt32,c,e);e=Z(this.format,c,e);for(b=0;b<a.length;b++)c.set(a[b],e),e+=a[b].length;return c};q.prototype.getBextBytes_= | ||
function(){var a=[];this.enforceBext_();this.bext.chunkId&&(this.bext.chunkSize=602+this.bext.codingHistory.length,a=a.concat(v(this.bext.chunkId),g(602+this.bext.codingHistory.length,this.uInt32),w(this.bext.description,256),w(this.bext.originator,32),w(this.bext.originatorReference,32),w(this.bext.originationDate,10),w(this.bext.originationTime,8),g(this.bext.timeReference[0],this.uInt32),g(this.bext.timeReference[1],this.uInt32),g(this.bext.version,this.uInt16),w(this.bext.UMID,64),g(this.bext.loudnessValue, | ||
this.uInt16),g(this.bext.loudnessRange,this.uInt16),g(this.bext.maxTruePeakLevel,this.uInt16),g(this.bext.maxMomentaryLoudness,this.uInt16),g(this.bext.maxShortTermLoudness,this.uInt16),w(this.bext.reserved,180),w(this.bext.codingHistory,this.bext.codingHistory.length)));a.length%2&&a.push(0);return a};q.prototype.enforceBext_=function(){for(var a in this.bext)if(this.bext.hasOwnProperty(a)&&this.bext[a]&&"timeReference"!=a){this.bext.chunkId="bext";break}if(this.bext.timeReference[0]||this.bext.timeReference[1])this.bext.chunkId= | ||
"bext"};q.prototype.getDs64Bytes_=function(){var a=[];this.ds64.chunkId&&(a=a.concat(v(this.ds64.chunkId),g(this.ds64.chunkSize,this.uInt32),g(this.ds64.riffSizeHigh,this.uInt32),g(this.ds64.riffSizeLow,this.uInt32),g(this.ds64.dataSizeHigh,this.uInt32),g(this.ds64.dataSizeLow,this.uInt32),g(this.ds64.originationTime,this.uInt32),g(this.ds64.sampleCountHigh,this.uInt32),g(this.ds64.sampleCountLow,this.uInt32)));return a};q.prototype.getCueBytes_=function(){var a=[];if(this.cue.chunkId){var b=this.getCuePointsBytes_(); | ||
a=a.concat(v(this.cue.chunkId),g(b.length+4,this.uInt32),g(this.cue.dwCuePoints,this.uInt32),b)}return a};q.prototype.getCuePointsBytes_=function(){for(var a=[],b=0;b<this.cue.dwCuePoints;b++)a=a.concat(g(this.cue.points[b].dwName,this.uInt32),g(this.cue.points[b].dwPosition,this.uInt32),v(this.cue.points[b].fccChunk),g(this.cue.points[b].dwChunkStart,this.uInt32),g(this.cue.points[b].dwBlockStart,this.uInt32),g(this.cue.points[b].dwSampleOffset,this.uInt32));return a};q.prototype.getSmplBytes_=function(){var a= | ||
[];if(this.smpl.chunkId){var b=this.getSmplLoopsBytes_();a=a.concat(v(this.smpl.chunkId),g(b.length+36,this.uInt32),g(this.smpl.dwManufacturer,this.uInt32),g(this.smpl.dwProduct,this.uInt32),g(this.smpl.dwSamplePeriod,this.uInt32),g(this.smpl.dwMIDIUnityNote,this.uInt32),g(this.smpl.dwMIDIPitchFraction,this.uInt32),g(this.smpl.dwSMPTEFormat,this.uInt32),g(this.smpl.dwSMPTEOffset,this.uInt32),g(this.smpl.dwNumSampleLoops,this.uInt32),g(this.smpl.dwSamplerData,this.uInt32),b)}return a};q.prototype.getSmplLoopsBytes_= | ||
function(){for(var a=[],b=0;b<this.smpl.dwNumSampleLoops;b++)a=a.concat(g(this.smpl.loops[b].dwName,this.uInt32),g(this.smpl.loops[b].dwType,this.uInt32),g(this.smpl.loops[b].dwStart,this.uInt32),g(this.smpl.loops[b].dwEnd,this.uInt32),g(this.smpl.loops[b].dwFraction,this.uInt32),g(this.smpl.loops[b].dwPlayCount,this.uInt32));return a};q.prototype.getFactBytes_=function(){var a=[];this.fact.chunkId&&(a=a.concat(v(this.fact.chunkId),g(this.fact.chunkSize,this.uInt32),g(this.fact.dwSampleLength,this.uInt32))); | ||
return a};q.prototype.getFmtBytes_=function(){var a=[];if(this.fmt.chunkId)return a.concat(v(this.fmt.chunkId),g(this.fmt.chunkSize,this.uInt32),g(this.fmt.audioFormat,this.uInt16),g(this.fmt.numChannels,this.uInt16),g(this.fmt.sampleRate,this.uInt32),g(this.fmt.byteRate,this.uInt32),g(this.fmt.blockAlign,this.uInt16),g(this.fmt.bitsPerSample,this.uInt16),this.getFmtExtensionBytes_());throw Error('Could not find the "fmt " chunk');};q.prototype.getFmtExtensionBytes_=function(){var a=[];16<this.fmt.chunkSize&& | ||
(a=a.concat(g(this.fmt.cbSize,this.uInt16)));18<this.fmt.chunkSize&&(a=a.concat(g(this.fmt.validBitsPerSample,this.uInt16)));20<this.fmt.chunkSize&&(a=a.concat(g(this.fmt.dwChannelMask,this.uInt32)));24<this.fmt.chunkSize&&(a=a.concat(g(this.fmt.subformat[0],this.uInt32),g(this.fmt.subformat[1],this.uInt32),g(this.fmt.subformat[2],this.uInt32),g(this.fmt.subformat[3],this.uInt32)));return a};q.prototype.getLISTBytes_=function(){for(var a=[],b=0;b<this.LIST.length;b++){var c=this.getLISTSubChunksBytes_(this.LIST[b].subChunks, | ||
this.LIST[b].format);a=a.concat(v(this.LIST[b].chunkId),g(c.length+4,this.uInt32),v(this.LIST[b].format),c)}return a};q.prototype.getLISTSubChunksBytes_=function(a,b){for(var c=[],e=0;e<a.length;e++)"INFO"==b?(c=c.concat(v(a[e].chunkId),g(a[e].value.length+1,this.uInt32),w(a[e].value,a[e].value.length)),c.push(0)):"adtl"==b&&(-1<["labl","note"].indexOf(a[e].chunkId)?(c=c.concat(v(a[e].chunkId),g(a[e].value.length+4+1,this.uInt32),g(a[e].dwName,this.uInt32),w(a[e].value,a[e].value.length)),c.push(0)): | ||
"ltxt"==a[e].chunkId&&(c=c.concat(this.getLtxtChunkBytes_(a[e])))),c.length%2&&c.push(0);return c};q.prototype.getLtxtChunkBytes_=function(a){return[].concat(v(a.chunkId),g(a.value.length+20,this.uInt32),g(a.dwName,this.uInt32),g(a.dwSampleLength,this.uInt32),g(a.dwPurposeID,this.uInt32),g(a.dwCountry,this.uInt16),g(a.dwLanguage,this.uInt16),g(a.dwDialect,this.uInt16),g(a.dwCodePage,this.uInt16),w(a.value,a.value.length))};q.prototype.getJunkBytes_=function(){var a=[];return this.junk.chunkId?a.concat(v(this.junk.chunkId), | ||
g(this.junk.chunkData.length,this.uInt32),this.junk.chunkData):a};var t=function(){var a=q.call(this)||this;a.bitDepth="0";a.dataType={bits:0,be:!1,signed:!1,fp:!1};a.WAV_AUDIO_FORMATS={4:17,8:1,"8a":6,"8m":7,16:1,24:1,32:1,"32f":3,64:3};return a};$jscomp.inherits(t,q);t.prototype.fromScratch=function(a,b,c,e,d){d=void 0===d?{}:d;this.clearHeaders();this.newWavFile_(a,b,c,e,d)};t.prototype.newWavFile_=function(a,b,c,e,d){d=void 0===d?{}:d;d.container||(d.container="RIFF");this.container=d.container; | ||
this.bitDepth=c;if(0<e.length&&e[0].constructor===Array){for(var f=[],g=0,k=e[0].length;g<k;g++)for(var l=0,m=e.length;l<m;l++)f.push(e[l][g]);e=f}this.updateDataType_();f=this.dataType.bits/8;this.data.samples=new Uint8Array(e.length*f);aa(e,this.dataType,this.data.samples);this.makeWavHeader_(c,a,b,f,this.data.samples.length,d);this.data.chunkId="data";this.data.chunkSize=this.data.samples.length;this.validateWavHeader_()};t.prototype.fromBuffer=function(a,b){q.prototype.fromBuffer.call(this,a, | ||
void 0===b?!0:b);this.bitDepthFromFmt_();this.updateDataType_()};t.prototype.toBuffer=function(){this.validateWavHeader_();return q.prototype.toBuffer.call(this)};t.prototype.getSample=function(a){a*=this.dataType.bits/8;if(a+this.dataType.bits/8>this.data.samples.length)throw Error("Range error");return N(this.data.samples.slice(a,a+this.dataType.bits/8),this.dataType)};t.prototype.setSample=function(a,b){a*=this.dataType.bits/8;if(a+this.dataType.bits/8>this.data.samples.length)throw Error("Range error"); | ||
S(b,this.dataType,this.data.samples,a)};t.prototype.makeWavHeader_=function(a,b,c,d,f,h){"4"==a?this.createADPCMHeader_(a,b,c,d,f,h):"8a"==a||"8m"==a?this.createALawMulawHeader_(a,b,c,d,f,h):-1==Object.keys(this.WAV_AUDIO_FORMATS).indexOf(a)||2<b?this.createExtensibleHeader_(a,b,c,d,f,h):this.createPCMHeader_(a,b,c,d,f,h)};t.prototype.createPCMHeader_=function(a,b,c,d,f,h){this.container=h.container;this.chunkSize=36+f;this.format="WAVE";this.bitDepth=a;this.fmt={chunkId:"fmt ",chunkSize:16,audioFormat:this.WAV_AUDIO_FORMATS[a]|| | ||
65534,numChannels:b,sampleRate:c,byteRate:b*d*c,blockAlign:b*d,bitsPerSample:parseInt(a,10),cbSize:0,validBitsPerSample:0,dwChannelMask:0,subformat:[]}};t.prototype.createADPCMHeader_=function(a,b,c,d,f,h){this.createPCMHeader_(a,b,c,d,f,h);this.chunkSize=40+f;this.fmt.chunkSize=20;this.fmt.byteRate=4055;this.fmt.blockAlign=256;this.fmt.bitsPerSample=4;this.fmt.cbSize=2;this.fmt.validBitsPerSample=505;this.fact={chunkId:"fact",chunkSize:4,dwSampleLength:2*f}};t.prototype.createExtensibleHeader_=function(a, | ||
b,c,d,f,h){this.createPCMHeader_(a,b,c,d,f,h);this.chunkSize=60+f;this.fmt.chunkSize=40;this.fmt.bitsPerSample=(parseInt(a,10)-1|7)+1;this.fmt.cbSize=22;this.fmt.validBitsPerSample=parseInt(a,10);a=this.fmt;c=0;1===b?c=4:2===b?c=3:4===b?c=51:6===b?c=63:8===b&&(c=1599);a.dwChannelMask=c;this.fmt.subformat=[1,1048576,2852126848,1905997824]};t.prototype.createALawMulawHeader_=function(a,b,c,d,f,h){this.createPCMHeader_(a,b,c,d,f,h);this.chunkSize=40+f;this.fmt.chunkSize=20;this.fmt.cbSize=2;this.fmt.validBitsPerSample= | ||
8;this.fact={chunkId:"fact",chunkSize:4,dwSampleLength:f}};t.prototype.bitDepthFromFmt_=function(){this.bitDepth=3===this.fmt.audioFormat&&32===this.fmt.bitsPerSample?"32f":6===this.fmt.audioFormat?"8a":7===this.fmt.audioFormat?"8m":this.fmt.bitsPerSample.toString()};t.prototype.validateBitDepth_=function(){if(!this.WAV_AUDIO_FORMATS[this.bitDepth]){if(8<parseInt(this.bitDepth,10)&&54>parseInt(this.bitDepth,10))return!0;throw Error("Invalid bit depth.");}return!0};t.prototype.updateDataType_=function(){this.dataType= | ||
{bits:(parseInt(this.bitDepth,10)-1|7)+1,fp:"32f"==this.bitDepth||"64"==this.bitDepth,signed:"8"!=this.bitDepth,be:"RIFX"==this.container};-1<["4","8a","8m"].indexOf(this.bitDepth)&&(this.dataType.bits=8,this.dataType.signed=!1)};t.prototype.validateWavHeader_=function(){this.validateBitDepth_();var a=this.fmt.numChannels;a=1>a||65535<a*this.fmt.bitsPerSample/8?!1:!0;if(!a)throw Error("Invalid number of channels.");a=this.fmt.sampleRate;a=1>a||4294967295<this.fmt.bitsPerSample/8*this.fmt.numChannels* | ||
a?!1:!0;if(!a)throw Error("Invalid sample rate.");};var p=function(){return t.apply(this,arguments)||this};$jscomp.inherits(p,t);p.prototype.getTag=function(a){a=this.getTagIndex_(a);return null!==a.TAG?this.LIST[a.LIST].subChunks[a.TAG].value:null};p.prototype.setTag=function(a,b){var c=a;if(c.constructor!==String)throw Error("Invalid tag name.");if(4>c.length)for(var d=0,f=4-c.length;d<f;d++)c+=" ";a=c;c=this.getTagIndex_(a);null!==c.TAG?(this.LIST[c.LIST].subChunks[c.TAG].chunkSize=b.length+1, | ||
this.LIST[c.LIST].subChunks[c.TAG].value=b):null!==c.LIST?this.LIST[c.LIST].subChunks.push({chunkId:a,chunkSize:b.length+1,value:b}):(this.LIST.push({chunkId:"LIST",chunkSize:8+b.length+1,format:"INFO",subChunks:[]}),this.LIST[this.LIST.length-1].subChunks.push({chunkId:a,chunkSize:b.length+1,value:b}))};p.prototype.deleteTag=function(a){a=this.getTagIndex_(a);return null!==a.TAG?(this.LIST[a.LIST].subChunks.splice(a.TAG,1),!0):!1};p.prototype.listTags=function(){var a=this.getLISTINFOIndex_(),b= | ||
{};if(null!==a)for(var c=0,d=this.LIST[a].subChunks.length;c<d;c++)b[this.LIST[a].subChunks[c].chunkId]=this.LIST[a].subChunks[c].value;return b};p.prototype.listCuePoints=function(){for(var a=this.getCuePoints_(),b=0,c=a.length;b<c;b++)a[b].milliseconds=a[b].dwPosition/this.fmt.sampleRate*1E3;return a};p.prototype.setCuePoint=function(a,b){b=void 0===b?"":b;this.cue.chunkId="cue ";a=a*this.fmt.sampleRate/1E3;var c=this.getCuePoints_();this.clearLISTadtl_();var d=this.cue.points.length;this.cue.points= | ||
[];var f=!1;if(0===d)this.setCuePoint_(a,1,b);else{for(var h=0;h<d;h++)c[h].dwPosition>a&&!f?(this.setCuePoint_(a,h+1,b),this.setCuePoint_(c[h].dwPosition,h+2,c[h].label),f=!0):this.setCuePoint_(c[h].dwPosition,h+1,c[h].label);f||this.setCuePoint_(a,this.cue.points.length+1,b)}this.cue.dwCuePoints=this.cue.points.length};p.prototype.deleteCuePoint=function(a){this.cue.chunkId="cue ";var b=this.getCuePoints_();this.clearLISTadtl_();var c=this.cue.points.length;this.cue.points=[];for(var d=0;d<c;d++)d+ | ||
1!==a&&this.setCuePoint_(b[d].dwPosition,d+1,b[d].label);this.cue.dwCuePoints=this.cue.points.length;this.cue.dwCuePoints?this.cue.chunkId="cue ":(this.cue.chunkId="",this.clearLISTadtl_())};p.prototype.updateLabel=function(a,b){var c=this.getAdtlChunk_();if(null!==c)for(var d=0,f=this.LIST[c].subChunks.length;d<f;d++)this.LIST[c].subChunks[d].dwName==a&&(this.LIST[c].subChunks[d].value=b)};p.prototype.getCuePoints_=function(){for(var a=[],b=0,c=this.cue.points.length;b<c;b++)a.push({dwPosition:this.cue.points[b].dwPosition, | ||
label:this.getLabelForCuePoint_(this.cue.points[b].dwName)});return a};p.prototype.getLabelForCuePoint_=function(a){var b=this.getAdtlChunk_();if(null!==b)for(var c=0,d=this.LIST[b].subChunks.length;c<d;c++)if(this.LIST[b].subChunks[c].dwName==a)return this.LIST[b].subChunks[c].value;return""};p.prototype.getLISTINFOIndex_=function(){for(var a=null,b=0,c=this.LIST.length;b<c;b++)if("INFO"===this.LIST[b].format){a=b;break}return a};p.prototype.getAdtlChunk_=function(){for(var a=0,b=this.LIST.length;a< | ||
b;a++)if("adtl"==this.LIST[a].format)return a;return null};p.prototype.getTagIndex_=function(a){for(var b={LIST:null,TAG:null},c=0,d=this.LIST.length;c<d;c++)if("INFO"==this.LIST[c].format){b.LIST=c;d=0;for(var f=this.LIST[c].subChunks.length;d<f;d++)if(this.LIST[c].subChunks[d].chunkId==a){b.TAG=d;break}break}return b};p.prototype.setCuePoint_=function(a,b,c){this.cue.points.push({dwName:b,dwPosition:a,fccChunk:"data",dwChunkStart:0,dwBlockStart:0,dwSampleOffset:a});this.setLabl_(b,c)};p.prototype.clearLISTadtl_= | ||
function(){for(var a=0,b=this.LIST.length;a<b;a++)"adtl"==this.LIST[a].format&&this.LIST.splice(a)};p.prototype.setLabl_=function(a,b){var c=this.getAdtlChunk_();null===c&&(this.LIST.push({chunkId:"LIST",chunkSize:4,format:"adtl",subChunks:[]}),c=this.LIST.length-1);this.setLabelText_(null===c?0:c,a,b)};p.prototype.setLabelText_=function(a,b,c){this.LIST[a].subChunks.push({chunkId:"labl",chunkSize:c.length,dwName:b,value:c});this.LIST[a].chunkSize+=c.length+4+4+4+1};var u=function(){return p.apply(this, | ||
arguments)||this};$jscomp.inherits(u,p);u.prototype.toRIFF=function(){this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,this.bitDepth,T(this.data.samples,this.dataType))};u.prototype.toRIFX=function(){this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,this.bitDepth,T(this.data.samples,this.dataType),{container:"RIFX"})};u.prototype.toIMAADPCM=function(){if(8E3!==this.fmt.sampleRate)throw Error("Only 8000 Hz files can be compressed as IMA-ADPCM.");if(1!==this.fmt.numChannels)throw Error("Only mono files can be compressed as IMA-ADPCM."); | ||
this.assure16Bit_();var a=new Int16Array(this.outputSize_());J(this.data.samples,this.dataType,a);this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"4",ea(a),{container:this.correctContainer_()})};u.prototype.fromIMAADPCM=function(a){a=void 0===a?"16":a;this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"16",ha(this.data.samples,this.fmt.blockAlign),{container:this.correctContainer_()});"16"!=a&&this.toBitDepth(a)};u.prototype.toALaw=function(){this.assure16Bit_();var a=new Int16Array(this.outputSize_()); | ||
J(this.data.samples,this.dataType,a);this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"8a",ia(a),{container:this.correctContainer_()})};u.prototype.fromALaw=function(a){a=void 0===a?"16":a;this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"16",ka(this.data.samples),{container:this.correctContainer_()});"16"!=a&&this.toBitDepth(a)};u.prototype.toMuLaw=function(){this.assure16Bit_();var a=new Int16Array(this.outputSize_());J(this.data.samples,this.dataType,a);this.fromExisting_(this.fmt.numChannels, | ||
this.fmt.sampleRate,"8m",la(a),{container:this.correctContainer_()})};u.prototype.fromMuLaw=function(a){a=void 0===a?"16":a;this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"16",na(this.data.samples),{container:this.correctContainer_()});"16"!=a&&this.toBitDepth(a)};u.prototype.toBitDepth=function(a,b){var c=a,d=this.bitDepth;void 0===b||b||("32f"!=a&&(c=this.dataType.bits.toString()),d=""+this.dataType.bits);this.assureUncompressed_();var f=this.data.samples.length/(this.dataType.bits/ | ||
8),h=new Float64Array(f);f=new Float64Array(f);J(this.data.samples,this.dataType,h);if("32f"==d||"64"==d)for(var g=0,k=h.length;g<k;g++)1<h[g]?h[g]=1:-1>h[g]&&(h[g]=-1);var l=d;d=c;V(l);V(d);g=L(l,d);k={oldMin:Math.pow(2,parseInt(l,10))/2,newMin:Math.pow(2,parseInt(d,10))/2,oldMax:Math.pow(2,parseInt(l,10))/2-1,newMax:Math.pow(2,parseInt(d,10))/2-1};c=h.length;if("8"==l)for(var m=0;m<c;m++)f[m]=h[m]-=128;if("32f"==l||"64"==l)for(l=h.length,m=0;m<l;m++)1<h[m]?h[m]=1:-1>h[m]&&(h[m]=-1);for(l=0;l<c;l++)f[l]= | ||
g(h[l],k);if("8"==d)for(h=0;h<c;h++)f[h]=f[h]+=128;this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,a,f,{container:this.correctContainer_()})};u.prototype.assure16Bit_=function(){this.assureUncompressed_();"16"!=this.bitDepth&&this.toBitDepth("16")};u.prototype.assureUncompressed_=function(){"8a"==this.bitDepth?this.fromALaw():"8m"==this.bitDepth?this.fromMuLaw():"4"==this.bitDepth&&this.fromIMAADPCM()};u.prototype.correctContainer_=function(){return"RF64"==this.container?"RIFF":this.container}; | ||
u.prototype.fromExisting_=function(a,b,c,d,f){f=void 0===f?{}:f;var e=new p;Object.assign(this.fmt,e.fmt);Object.assign(this.fact,e.fact);Object.assign(this.ds64,e.ds64);Object.assign(this.data,e.data);this.newWavFile_(a,b,c,d,f)};u.prototype.outputSize_=function(){var a=this.data.samples.length/2;a%2&&a++;return a};x=function(a){a=void 0===a?null:a;var b=u.call(this)||this;a&&b.fromBuffer(a);return b};$jscomp.inherits(x,u);x.prototype.fromBase64=function(a){this.fromBuffer(new Uint8Array(k(a)))}; | ||
x.prototype.toBase64=function(){var a=this.toBuffer(),b=a.length;if(null===b||void 0===b)b=a.byteLength;a=new Uint8Array(a,0,b);b=a.length;for(var c="",d=0;d<b;d+=3)c+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[a[d]>>2],c+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[d]&3)<<4|a[d+1]>>4],c+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[d+1]&15)<<2|a[d+2]>>6],c+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[a[d+ | ||
2]&63];2===b%3?c=c.substring(0,c.length-1)+"=":1===b%3&&(c=c.substring(0,c.length-2)+"==");return c};x.prototype.toDataURI=function(){return"data:audio/wav;base64,"+this.toBase64()};x.prototype.fromDataURI=function(a){this.fromBase64(a.replace("data:audio/wav;base64,",""))};d.WaveFile=x;Object.defineProperty(d,"__esModule",{value:!0})}); | ||
"ltxt"==a.chunkId?(b.dwSampleLength=this.readUInt32(c),b.dwPurposeID=this.readUInt32(c),b.dwCountry=this.readUInt16_(c),b.dwLanguage=this.readUInt16_(c),b.dwDialect=this.readUInt16_(c),b.dwCodePage=this.readUInt16_(c),b.value=""):b.value=this.readZSTR_(c,this.head),this.LIST[this.LIST.length-1].subChunks.push(b)):"INFO"==b&&(this.head=a.chunkData.start,this.LIST[this.LIST.length-1].subChunks.push({chunkId:a.chunkId,chunkSize:a.chunkSize,value:this.readZSTR_(c,this.head)}))};r.prototype.readJunkChunk_= | ||
function(a){var b=this.findChunk("junk");b&&(this.junk={chunkId:b.chunkId,chunkSize:b.chunkSize,chunkData:[].slice.call(a.slice(b.chunkData.start,b.chunkData.end))})};r.prototype.readZSTR_=function(a,b){for(var c=b=void 0===b?0:b;c<a.length&&(this.head++,0!==a[c]);c++);return M(a,b,this.head-1)};r.prototype.readUInt16_=function(a){a=N(a,this.uInt16,this.head);this.head+=2;return a};var q=function(){return r.apply(this,arguments)||this};$jscomp.inherits(q,r);q.prototype.toBuffer=function(){this.uInt16.be= | ||
"RIFX"===this.container;this.uInt32.be=this.uInt16.be;for(var a=[this.getJunkBytes_(),this.getDs64Bytes_(),this.getBextBytes_(),this.getFmtBytes_(),this.getFactBytes_(),v(this.data.chunkId),g(this.data.samples.length,this.uInt32),this.data.samples,this.getCueBytes_(),this.getSmplBytes_(),this.getLISTBytes_()],b=0,c=0;c<a.length;c++)b+=a[c].length;c=new Uint8Array(b+12);var e=Z(this.container,c,0);e=S(b+4,this.uInt32,c,e);e=Z(this.format,c,e);for(b=0;b<a.length;b++)c.set(a[b],e),e+=a[b].length;return c}; | ||
q.prototype.getBextBytes_=function(){var a=[];this.enforceBext_();this.bext.chunkId&&(this.bext.chunkSize=602+this.bext.codingHistory.length,a=a.concat(v(this.bext.chunkId),g(602+this.bext.codingHistory.length,this.uInt32),w(this.bext.description,256),w(this.bext.originator,32),w(this.bext.originatorReference,32),w(this.bext.originationDate,10),w(this.bext.originationTime,8),g(this.bext.timeReference[0],this.uInt32),g(this.bext.timeReference[1],this.uInt32),g(this.bext.version,this.uInt16),w(this.bext.UMID, | ||
64),g(this.bext.loudnessValue,this.uInt16),g(this.bext.loudnessRange,this.uInt16),g(this.bext.maxTruePeakLevel,this.uInt16),g(this.bext.maxMomentaryLoudness,this.uInt16),g(this.bext.maxShortTermLoudness,this.uInt16),w(this.bext.reserved,180),w(this.bext.codingHistory,this.bext.codingHistory.length)));a.length%2&&a.push(0);return a};q.prototype.enforceBext_=function(){for(var a in this.bext)if(this.bext.hasOwnProperty(a)&&this.bext[a]&&"timeReference"!=a){this.bext.chunkId="bext";break}if(this.bext.timeReference[0]|| | ||
this.bext.timeReference[1])this.bext.chunkId="bext"};q.prototype.getDs64Bytes_=function(){var a=[];this.ds64.chunkId&&(a=a.concat(v(this.ds64.chunkId),g(this.ds64.chunkSize,this.uInt32),g(this.ds64.riffSizeHigh,this.uInt32),g(this.ds64.riffSizeLow,this.uInt32),g(this.ds64.dataSizeHigh,this.uInt32),g(this.ds64.dataSizeLow,this.uInt32),g(this.ds64.originationTime,this.uInt32),g(this.ds64.sampleCountHigh,this.uInt32),g(this.ds64.sampleCountLow,this.uInt32)));return a};q.prototype.getCueBytes_=function(){var a= | ||
[];if(this.cue.chunkId){var b=this.getCuePointsBytes_();a=a.concat(v(this.cue.chunkId),g(b.length+4,this.uInt32),g(this.cue.dwCuePoints,this.uInt32),b)}return a};q.prototype.getCuePointsBytes_=function(){for(var a=[],b=0;b<this.cue.dwCuePoints;b++)a=a.concat(g(this.cue.points[b].dwName,this.uInt32),g(this.cue.points[b].dwPosition,this.uInt32),v(this.cue.points[b].fccChunk),g(this.cue.points[b].dwChunkStart,this.uInt32),g(this.cue.points[b].dwBlockStart,this.uInt32),g(this.cue.points[b].dwSampleOffset, | ||
this.uInt32));return a};q.prototype.getSmplBytes_=function(){var a=[];if(this.smpl.chunkId){var b=this.getSmplLoopsBytes_();a=a.concat(v(this.smpl.chunkId),g(b.length+36,this.uInt32),g(this.smpl.dwManufacturer,this.uInt32),g(this.smpl.dwProduct,this.uInt32),g(this.smpl.dwSamplePeriod,this.uInt32),g(this.smpl.dwMIDIUnityNote,this.uInt32),g(this.smpl.dwMIDIPitchFraction,this.uInt32),g(this.smpl.dwSMPTEFormat,this.uInt32),g(this.smpl.dwSMPTEOffset,this.uInt32),g(this.smpl.dwNumSampleLoops,this.uInt32), | ||
g(this.smpl.dwSamplerData,this.uInt32),b)}return a};q.prototype.getSmplLoopsBytes_=function(){for(var a=[],b=0;b<this.smpl.dwNumSampleLoops;b++)a=a.concat(g(this.smpl.loops[b].dwName,this.uInt32),g(this.smpl.loops[b].dwType,this.uInt32),g(this.smpl.loops[b].dwStart,this.uInt32),g(this.smpl.loops[b].dwEnd,this.uInt32),g(this.smpl.loops[b].dwFraction,this.uInt32),g(this.smpl.loops[b].dwPlayCount,this.uInt32));return a};q.prototype.getFactBytes_=function(){var a=[];this.fact.chunkId&&(a=a.concat(v(this.fact.chunkId), | ||
g(this.fact.chunkSize,this.uInt32),g(this.fact.dwSampleLength,this.uInt32)));return a};q.prototype.getFmtBytes_=function(){var a=[];if(this.fmt.chunkId)return a.concat(v(this.fmt.chunkId),g(this.fmt.chunkSize,this.uInt32),g(this.fmt.audioFormat,this.uInt16),g(this.fmt.numChannels,this.uInt16),g(this.fmt.sampleRate,this.uInt32),g(this.fmt.byteRate,this.uInt32),g(this.fmt.blockAlign,this.uInt16),g(this.fmt.bitsPerSample,this.uInt16),this.getFmtExtensionBytes_());throw Error('Could not find the "fmt " chunk'); | ||
};q.prototype.getFmtExtensionBytes_=function(){var a=[];16<this.fmt.chunkSize&&(a=a.concat(g(this.fmt.cbSize,this.uInt16)));18<this.fmt.chunkSize&&(a=a.concat(g(this.fmt.validBitsPerSample,this.uInt16)));20<this.fmt.chunkSize&&(a=a.concat(g(this.fmt.dwChannelMask,this.uInt32)));24<this.fmt.chunkSize&&(a=a.concat(g(this.fmt.subformat[0],this.uInt32),g(this.fmt.subformat[1],this.uInt32),g(this.fmt.subformat[2],this.uInt32),g(this.fmt.subformat[3],this.uInt32)));return a};q.prototype.getLISTBytes_=function(){for(var a= | ||
[],b=0;b<this.LIST.length;b++){var c=this.getLISTSubChunksBytes_(this.LIST[b].subChunks,this.LIST[b].format);a=a.concat(v(this.LIST[b].chunkId),g(c.length+4,this.uInt32),v(this.LIST[b].format),c)}return a};q.prototype.getLISTSubChunksBytes_=function(a,b){for(var c=[],e=0;e<a.length;e++)"INFO"==b?(c=c.concat(v(a[e].chunkId),g(a[e].value.length+1,this.uInt32),w(a[e].value,a[e].value.length)),c.push(0)):"adtl"==b&&(-1<["labl","note"].indexOf(a[e].chunkId)?(c=c.concat(v(a[e].chunkId),g(a[e].value.length+ | ||
4+1,this.uInt32),g(a[e].dwName,this.uInt32),w(a[e].value,a[e].value.length)),c.push(0)):"ltxt"==a[e].chunkId&&(c=c.concat(this.getLtxtChunkBytes_(a[e])))),c.length%2&&c.push(0);return c};q.prototype.getLtxtChunkBytes_=function(a){return[].concat(v(a.chunkId),g(a.value.length+20,this.uInt32),g(a.dwName,this.uInt32),g(a.dwSampleLength,this.uInt32),g(a.dwPurposeID,this.uInt32),g(a.dwCountry,this.uInt16),g(a.dwLanguage,this.uInt16),g(a.dwDialect,this.uInt16),g(a.dwCodePage,this.uInt16),w(a.value,a.value.length))}; | ||
q.prototype.getJunkBytes_=function(){var a=[];return this.junk.chunkId?a.concat(v(this.junk.chunkId),g(this.junk.chunkData.length,this.uInt32),this.junk.chunkData):a};var t=function(){var a=q.call(this)||this;a.bitDepth="0";a.dataType={bits:0,be:!1,signed:!1,fp:!1};a.WAV_AUDIO_FORMATS={4:17,8:1,"8a":6,"8m":7,16:1,24:1,32:1,"32f":3,64:3};return a};$jscomp.inherits(t,q);t.prototype.fromScratch=function(a,b,c,e,d){d=void 0===d?{}:d;this.clearHeaders();this.newWavFile_(a,b,c,e,d)};t.prototype.newWavFile_= | ||
function(a,b,c,e,d){d=void 0===d?{}:d;d.container||(d.container="RIFF");this.container=d.container;this.bitDepth=c;if(0<e.length&&e[0].constructor===Array){for(var f=[],g=0,k=e[0].length;g<k;g++)for(var l=0,m=e.length;l<m;l++)f.push(e[l][g]);e=f}this.updateDataType_();f=this.dataType.bits/8;this.data.samples=new Uint8Array(e.length*f);aa(e,this.dataType,this.data.samples);this.makeWavHeader_(c,a,b,f,this.data.samples.length,d);this.data.chunkId="data";this.data.chunkSize=this.data.samples.length; | ||
this.validateWavHeader_()};t.prototype.fromBuffer=function(a,b){q.prototype.fromBuffer.call(this,a,void 0===b?!0:b);this.bitDepthFromFmt_();this.updateDataType_()};t.prototype.toBuffer=function(){this.validateWavHeader_();return q.prototype.toBuffer.call(this)};t.prototype.getSample=function(a){a*=this.dataType.bits/8;if(a+this.dataType.bits/8>this.data.samples.length)throw Error("Range error");return N(this.data.samples.slice(a,a+this.dataType.bits/8),this.dataType)};t.prototype.setSample=function(a, | ||
b){a*=this.dataType.bits/8;if(a+this.dataType.bits/8>this.data.samples.length)throw Error("Range error");S(b,this.dataType,this.data.samples,a)};t.prototype.makeWavHeader_=function(a,b,c,d,f,h){"4"==a?this.createADPCMHeader_(a,b,c,d,f,h):"8a"==a||"8m"==a?this.createALawMulawHeader_(a,b,c,d,f,h):-1==Object.keys(this.WAV_AUDIO_FORMATS).indexOf(a)||2<b?this.createExtensibleHeader_(a,b,c,d,f,h):this.createPCMHeader_(a,b,c,d,f,h)};t.prototype.createPCMHeader_=function(a,b,c,d,f,h){this.container=h.container; | ||
this.chunkSize=36+f;this.format="WAVE";this.bitDepth=a;this.fmt={chunkId:"fmt ",chunkSize:16,audioFormat:this.WAV_AUDIO_FORMATS[a]||65534,numChannels:b,sampleRate:c,byteRate:b*d*c,blockAlign:b*d,bitsPerSample:parseInt(a,10),cbSize:0,validBitsPerSample:0,dwChannelMask:0,subformat:[]}};t.prototype.createADPCMHeader_=function(a,b,c,d,f,h){this.createPCMHeader_(a,b,c,d,f,h);this.chunkSize=40+f;this.fmt.chunkSize=20;this.fmt.byteRate=4055;this.fmt.blockAlign=256;this.fmt.bitsPerSample=4;this.fmt.cbSize= | ||
2;this.fmt.validBitsPerSample=505;this.fact={chunkId:"fact",chunkSize:4,dwSampleLength:2*f}};t.prototype.createExtensibleHeader_=function(a,b,c,d,f,h){this.createPCMHeader_(a,b,c,d,f,h);this.chunkSize=60+f;this.fmt.chunkSize=40;this.fmt.bitsPerSample=(parseInt(a,10)-1|7)+1;this.fmt.cbSize=22;this.fmt.validBitsPerSample=parseInt(a,10);a=this.fmt;c=0;1===b?c=4:2===b?c=3:4===b?c=51:6===b?c=63:8===b&&(c=1599);a.dwChannelMask=c;this.fmt.subformat=[1,1048576,2852126848,1905997824]};t.prototype.createALawMulawHeader_= | ||
function(a,b,c,d,f,h){this.createPCMHeader_(a,b,c,d,f,h);this.chunkSize=40+f;this.fmt.chunkSize=20;this.fmt.cbSize=2;this.fmt.validBitsPerSample=8;this.fact={chunkId:"fact",chunkSize:4,dwSampleLength:f}};t.prototype.bitDepthFromFmt_=function(){this.bitDepth=3===this.fmt.audioFormat&&32===this.fmt.bitsPerSample?"32f":6===this.fmt.audioFormat?"8a":7===this.fmt.audioFormat?"8m":this.fmt.bitsPerSample.toString()};t.prototype.validateBitDepth_=function(){if(!this.WAV_AUDIO_FORMATS[this.bitDepth]){if(8< | ||
parseInt(this.bitDepth,10)&&54>parseInt(this.bitDepth,10))return!0;throw Error("Invalid bit depth.");}return!0};t.prototype.updateDataType_=function(){this.dataType={bits:(parseInt(this.bitDepth,10)-1|7)+1,fp:"32f"==this.bitDepth||"64"==this.bitDepth,signed:"8"!=this.bitDepth,be:"RIFX"==this.container};-1<["4","8a","8m"].indexOf(this.bitDepth)&&(this.dataType.bits=8,this.dataType.signed=!1)};t.prototype.validateWavHeader_=function(){this.validateBitDepth_();var a=this.fmt.numChannels;a=1>a||65535< | ||
a*this.fmt.bitsPerSample/8?!1:!0;if(!a)throw Error("Invalid number of channels.");a=this.fmt.sampleRate;a=1>a||4294967295<this.fmt.bitsPerSample/8*this.fmt.numChannels*a?!1:!0;if(!a)throw Error("Invalid sample rate.");};var p=function(){return t.apply(this,arguments)||this};$jscomp.inherits(p,t);p.prototype.getTag=function(a){a=this.getTagIndex_(a);return null!==a.TAG?this.LIST[a.LIST].subChunks[a.TAG].value:null};p.prototype.setTag=function(a,b){var c=a;if(c.constructor!==String)throw Error("Invalid tag name."); | ||
if(4>c.length)for(var d=0,f=4-c.length;d<f;d++)c+=" ";a=c;c=this.getTagIndex_(a);null!==c.TAG?(this.LIST[c.LIST].subChunks[c.TAG].chunkSize=b.length+1,this.LIST[c.LIST].subChunks[c.TAG].value=b):null!==c.LIST?this.LIST[c.LIST].subChunks.push({chunkId:a,chunkSize:b.length+1,value:b}):(this.LIST.push({chunkId:"LIST",chunkSize:8+b.length+1,format:"INFO",subChunks:[]}),this.LIST[this.LIST.length-1].subChunks.push({chunkId:a,chunkSize:b.length+1,value:b}))};p.prototype.deleteTag=function(a){a=this.getTagIndex_(a); | ||
return null!==a.TAG?(this.LIST[a.LIST].subChunks.splice(a.TAG,1),!0):!1};p.prototype.listTags=function(){var a=this.getLISTINFOIndex_(),b={};if(null!==a)for(var c=0,d=this.LIST[a].subChunks.length;c<d;c++)b[this.LIST[a].subChunks[c].chunkId]=this.LIST[a].subChunks[c].value;return b};p.prototype.listCuePoints=function(){for(var a=this.getCuePoints_(),b=0,c=a.length;b<c;b++)a[b].milliseconds=a[b].dwPosition/this.fmt.sampleRate*1E3;return a};p.prototype.setCuePoint=function(a,b){b=void 0===b?"":b;this.cue.chunkId= | ||
"cue ";a=a*this.fmt.sampleRate/1E3;var c=this.getCuePoints_();this.clearLISTadtl_();var d=this.cue.points.length;this.cue.points=[];var f=!1;if(0===d)this.setCuePoint_(a,1,b);else{for(var h=0;h<d;h++)c[h].dwPosition>a&&!f?(this.setCuePoint_(a,h+1,b),this.setCuePoint_(c[h].dwPosition,h+2,c[h].label),f=!0):this.setCuePoint_(c[h].dwPosition,h+1,c[h].label);f||this.setCuePoint_(a,this.cue.points.length+1,b)}this.cue.dwCuePoints=this.cue.points.length};p.prototype.deleteCuePoint=function(a){this.cue.chunkId= | ||
"cue ";var b=this.getCuePoints_();this.clearLISTadtl_();var c=this.cue.points.length;this.cue.points=[];for(var d=0;d<c;d++)d+1!==a&&this.setCuePoint_(b[d].dwPosition,d+1,b[d].label);this.cue.dwCuePoints=this.cue.points.length;this.cue.dwCuePoints?this.cue.chunkId="cue ":(this.cue.chunkId="",this.clearLISTadtl_())};p.prototype.updateLabel=function(a,b){var c=this.getAdtlChunk_();if(null!==c)for(var d=0,f=this.LIST[c].subChunks.length;d<f;d++)this.LIST[c].subChunks[d].dwName==a&&(this.LIST[c].subChunks[d].value= | ||
b)};p.prototype.getCuePoints_=function(){for(var a=[],b=0,c=this.cue.points.length;b<c;b++)a.push({dwPosition:this.cue.points[b].dwPosition,label:this.getLabelForCuePoint_(this.cue.points[b].dwName)});return a};p.prototype.getLabelForCuePoint_=function(a){var b=this.getAdtlChunk_();if(null!==b)for(var c=0,d=this.LIST[b].subChunks.length;c<d;c++)if(this.LIST[b].subChunks[c].dwName==a)return this.LIST[b].subChunks[c].value;return""};p.prototype.getLISTINFOIndex_=function(){for(var a=null,b=0,c=this.LIST.length;b< | ||
c;b++)if("INFO"===this.LIST[b].format){a=b;break}return a};p.prototype.getAdtlChunk_=function(){for(var a=0,b=this.LIST.length;a<b;a++)if("adtl"==this.LIST[a].format)return a;return null};p.prototype.getTagIndex_=function(a){for(var b={LIST:null,TAG:null},c=0,d=this.LIST.length;c<d;c++)if("INFO"==this.LIST[c].format){b.LIST=c;d=0;for(var f=this.LIST[c].subChunks.length;d<f;d++)if(this.LIST[c].subChunks[d].chunkId==a){b.TAG=d;break}break}return b};p.prototype.setCuePoint_=function(a,b,c){this.cue.points.push({dwName:b, | ||
dwPosition:a,fccChunk:"data",dwChunkStart:0,dwBlockStart:0,dwSampleOffset:a});this.setLabl_(b,c)};p.prototype.clearLISTadtl_=function(){for(var a=0,b=this.LIST.length;a<b;a++)"adtl"==this.LIST[a].format&&this.LIST.splice(a)};p.prototype.setLabl_=function(a,b){var c=this.getAdtlChunk_();null===c&&(this.LIST.push({chunkId:"LIST",chunkSize:4,format:"adtl",subChunks:[]}),c=this.LIST.length-1);this.setLabelText_(null===c?0:c,a,b)};p.prototype.setLabelText_=function(a,b,c){this.LIST[a].subChunks.push({chunkId:"labl", | ||
chunkSize:c.length,dwName:b,value:c});this.LIST[a].chunkSize+=c.length+4+4+4+1};var u=function(){return p.apply(this,arguments)||this};$jscomp.inherits(u,p);u.prototype.toRIFF=function(){this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,this.bitDepth,T(this.data.samples,this.dataType))};u.prototype.toRIFX=function(){this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,this.bitDepth,T(this.data.samples,this.dataType),{container:"RIFX"})};u.prototype.toIMAADPCM=function(){if(8E3!== | ||
this.fmt.sampleRate)throw Error("Only 8000 Hz files can be compressed as IMA-ADPCM.");if(1!==this.fmt.numChannels)throw Error("Only mono files can be compressed as IMA-ADPCM.");this.assure16Bit_();var a=new Int16Array(this.outputSize_());J(this.data.samples,this.dataType,a);this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"4",ea(a),{container:this.correctContainer_()})};u.prototype.fromIMAADPCM=function(a){a=void 0===a?"16":a;this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate, | ||
"16",ha(this.data.samples,this.fmt.blockAlign),{container:this.correctContainer_()});"16"!=a&&this.toBitDepth(a)};u.prototype.toALaw=function(){this.assure16Bit_();var a=new Int16Array(this.outputSize_());J(this.data.samples,this.dataType,a);this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"8a",ia(a),{container:this.correctContainer_()})};u.prototype.fromALaw=function(a){a=void 0===a?"16":a;this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"16",ka(this.data.samples),{container:this.correctContainer_()}); | ||
"16"!=a&&this.toBitDepth(a)};u.prototype.toMuLaw=function(){this.assure16Bit_();var a=new Int16Array(this.outputSize_());J(this.data.samples,this.dataType,a);this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"8m",la(a),{container:this.correctContainer_()})};u.prototype.fromMuLaw=function(a){a=void 0===a?"16":a;this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"16",na(this.data.samples),{container:this.correctContainer_()});"16"!=a&&this.toBitDepth(a)};u.prototype.toBitDepth=function(a, | ||
b){var c=a,d=this.bitDepth;void 0===b||b||("32f"!=a&&(c=this.dataType.bits.toString()),d=""+this.dataType.bits);this.assureUncompressed_();var f=this.data.samples.length/(this.dataType.bits/8),h=new Float64Array(f);f=new Float64Array(f);J(this.data.samples,this.dataType,h);if("32f"==d||"64"==d)for(var g=0,k=h.length;g<k;g++)1<h[g]?h[g]=1:-1>h[g]&&(h[g]=-1);var l=d;d=c;V(l);V(d);g=L(l,d);k={oldMin:Math.pow(2,parseInt(l,10))/2,newMin:Math.pow(2,parseInt(d,10))/2,oldMax:Math.pow(2,parseInt(l,10))/2- | ||
1,newMax:Math.pow(2,parseInt(d,10))/2-1};c=h.length;if("8"==l)for(var m=0;m<c;m++)f[m]=h[m]-=128;if("32f"==l||"64"==l)for(l=h.length,m=0;m<l;m++)1<h[m]?h[m]=1:-1>h[m]&&(h[m]=-1);for(l=0;l<c;l++)f[l]=g(h[l],k);if("8"==d)for(h=0;h<c;h++)f[h]=f[h]+=128;this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,a,f,{container:this.correctContainer_()})};u.prototype.assure16Bit_=function(){this.assureUncompressed_();"16"!=this.bitDepth&&this.toBitDepth("16")};u.prototype.assureUncompressed_=function(){"8a"== | ||
this.bitDepth?this.fromALaw():"8m"==this.bitDepth?this.fromMuLaw():"4"==this.bitDepth&&this.fromIMAADPCM()};u.prototype.correctContainer_=function(){return"RF64"==this.container?"RIFF":this.container};u.prototype.fromExisting_=function(a,b,c,d,f){f=void 0===f?{}:f;var e=new p;Object.assign(this.fmt,e.fmt);Object.assign(this.fact,e.fact);Object.assign(this.ds64,e.ds64);Object.assign(this.data,e.data);this.newWavFile_(a,b,c,d,f)};u.prototype.outputSize_=function(){var a=this.data.samples.length/2;a% | ||
2&&a++;return a};x=function(a){a=void 0===a?null:a;var b=u.call(this)||this;a&&b.fromBuffer(a);return b};$jscomp.inherits(x,u);x.prototype.fromBase64=function(a){this.fromBuffer(new Uint8Array(k(a)))};x.prototype.toBase64=function(){var a=this.toBuffer(),b=a.length;if(null===b||void 0===b)b=a.byteLength;a=new Uint8Array(a,0,b);b=a.length;for(var c="",d=0;d<b;d+=3)c+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[a[d]>>2],c+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[d]& | ||
3)<<4|a[d+1]>>4],c+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[d+1]&15)<<2|a[d+2]>>6],c+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[a[d+2]&63];2===b%3?c=c.substring(0,c.length-1)+"=":1===b%3&&(c=c.substring(0,c.length-2)+"==");return c};x.prototype.toDataURI=function(){return"data:audio/wav;base64,"+this.toBase64()};x.prototype.fromDataURI=function(a){this.fromBase64(a.replace("data:audio/wav;base64,",""))};d.WaveFile=x;Object.defineProperty(d,"__esModule", | ||
{value:!0})}); |
@@ -554,4 +554,6 @@ /* | ||
item.dwCodePage = this.readUInt16_(buffer); | ||
item.value = ''; // kept for compatibility | ||
} else { | ||
item.value = this.readZSTR_(buffer, this.head); | ||
} | ||
item.value = this.readZSTR_(buffer, this.head); | ||
this.LIST[this.LIST.length - 1].subChunks.push(item); | ||
@@ -558,0 +560,0 @@ } |
{ | ||
"name": "wavefile", | ||
"version": "9.0.2", | ||
"version": "9.0.3", | ||
"description": "Create, read and write wav files according to the specs.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/rochars/wavefile", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
206582
3783