1import{a as p,c as x}from"./chunk-53YYWXNW.js";import"./chunk-RSPMYPAI.js";import{a as b}from"./chunk-HIVTEWQ2.js";import{C as D,D as z,c as k,d as f,f as S,h as r,u,x as y}from"./chunk-IIBKUP5C.js";import{h as U,p as d}from"./chunk-YREMPQ3M.js";var _=[6e3,8e3,9600,11025,12e3,16e3,22050,24e3,32e3,44100,48e3,64e3,88200,96e3,192e3,-1],m={len:32,get:(a,e)=>{let t=r.get(a,e+24),i={BlockID:p.get(a,e),blockSize:r.get(a,e+4),version:f.get(a,e+8),totalSamples:r.get(a,e+12),blockIndex:r.get(a,e+16),blockSamples:r.get(a,e+20),flags:{bitsPerSample:(1+g(t,0,2))*8,isMono:o(t,2),isHybrid:o(t,3),isJointStereo:o(t,4),crossChannel:o(t,5),hybridNoiseShaping:o(t,6),floatingPoint:o(t,7),samplingRate:_[g(t,23,4)],isDSD:o(t,31)},crc:new u(4).get(a,e+28)};return i.flags.isDSD&&(i.totalSamples*=8),i}},h={len:1,get:(a,e)=>({functionId:g(a[e],0,6),isOptional:o(a[e],5),isOddSize:o(a[e],6),largeBlock:o(a[e],7)})};function o(a,e){return g(a,e,1)===1}function g(a,e,t){return a>>>e&4294967295>>>32-t}var w=U(y(),1);var n=(0,w.default)("music-metadata:parser:WavPack"),c=class extends D("WavPack"){},B=class extends z{constructor(){super(...arguments),this.audioDataSize=0}parse(){return d(this,null,function*(){return this.metadata.setAudioOnly(),this.audioDataSize=0,yield this.parseWavPackBlocks(),x(this.metadata,this.tokenizer,this.options)})}parseWavPackBlocks(){return d(this,null,function*(){do{if((yield this.tokenizer.peekToken(p))!=="wvpk")break;let t=yield this.tokenizer.readToken(m);if(t.BlockID!=="wvpk")throw new c("Invalid WavPack Block-ID");n(`WavPack header blockIndex=${t.blockIndex}, len=${m.len}`),t.blockIndex===0&&!this.metadata.format.container&&(this.metadata.setFormat("container","WavPack"),this.metadata.setFormat("lossless",!t.flags.isHybrid),this.metadata.setFormat("bitsPerSample",t.flags.bitsPerSample),t.flags.isDSD||(this.metadata.setFormat("sampleRate",t.flags.samplingRate),this.metadata.setFormat("duration",t.totalSamples/t.flags.samplingRate)),this.metadata.setFormat("numberOfChannels",t.flags.isMono?1:2),this.metadata.setFormat("numberOfSamples",t.totalSamples),this.metadata.setFormat("codec",t.flags.isDSD?"DSD":"PCM"));let i=t.blockSize-(m.len-8);yield t.blockIndex===0?this.parseMetadataSubBlock(t,i):this.tokenizer.ignore(i),t.blockSamples>0&&(this.audioDataSize+=t.blockSize)}while(!this.tokenizer.fileInfo.size||this.tokenizer.fileInfo.size-this.tokenizer.position>=m.len);this.metadata.format.duration&&this.metadata.setFormat("bitrate",this.audioDataSize*8/this.metadata.format.duration)})}parseMetadataSubBlock(e,t){return d(this,null,function*(){let i=t;for(;i>h.len;){let s=yield this.tokenizer.readToken(h),I=yield this.tokenizer.readNumber(s.largeBlock?S:k),l=new Uint8Array(I*2-(s.isOddSize?1:0));switch(yield this.tokenizer.readBuffer(l),n(`Metadata Sub-Blocks functionId=0x${s.functionId.toString(16)}, id.largeBlock=${s.largeBlock},data-size=${l.length}`),s.functionId){case 0:break;case 14:{n("ID_DSD_BLOCK");let F=1<<k.get(l,0),T=e.flags.samplingRate*F*8;if(!e.flags.isDSD)throw new c("Only expect DSD block if DSD-flag is set");this.metadata.setFormat("sampleRate",T),this.metadata.setFormat("duration",e.totalSamples/T);break}case 36:n("ID_ALT_TRAILER: trailer for non-wav files");break;case 38:this.metadata.setFormat("audioMD5",l);break;case 47:n(`ID_BLOCK_CHECKSUM: checksum=${b(l)}`);break;default:n(`Ignore unsupported meta-sub-block-id functionId=0x${s.functionId.toString(16)}`);break}i-=h.len+(s.largeBlock?S.len:k.len)+I*2,n(`remainingLength=${i}`),s.isOddSize&&this.tokenizer.ignore(1)}if(i!==0)throw new c("metadata-sub-block should fit it remaining length")})}};export{c as WavPackContentError,B as WavPackParser};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.