@wasm-audio-decoders/flac
Advanced tools
Comparing version 0.2.4 to 0.2.5
{ | ||
"name": "@wasm-audio-decoders/flac", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "Web Assembly streaming FLAC decoder", | ||
@@ -55,4 +55,4 @@ "type": "module", | ||
"@wasm-audio-decoders/common": "9.0.5", | ||
"codec-parser": "2.4.3" | ||
"codec-parser": "2.5.0" | ||
} | ||
} |
# `@wasm-audio-decoders/flac` | ||
`@wasm-audio-decoders/flac` is a Web Assembly FLAC / Ogg FLAC audio decoder. | ||
* 64.8 KiB minified bundle size | ||
* 65.3 KiB minified bundle size | ||
* Browser and NodeJS support | ||
@@ -6,0 +6,0 @@ * Built in Web Worker support |
import { WASMAudioDecoderCommon } from "@wasm-audio-decoders/common"; | ||
import CodecParser, { | ||
data, | ||
absoluteGranulePosition, | ||
samples, | ||
totalSamples, | ||
codecFrames, | ||
@@ -189,2 +188,3 @@ isLastPage, | ||
const init = Symbol(); | ||
const totalSamplesDecoded = Symbol(); | ||
@@ -209,4 +209,4 @@ export default class FLACDecoder { | ||
this[decodeMethod] = placeholderDecodeMethod; | ||
this[totalSamplesDecoded] = 0; | ||
this._codecParser = null; | ||
this._beginningSampleOffset = undefined; | ||
} | ||
@@ -260,25 +260,19 @@ | ||
const oggPage = oggPages[oggPages.length - 1]; | ||
if (oggPages.length && Number(oggPage[absoluteGranulePosition]) > -1) { | ||
if (this._beginningSampleOffset === undefined) { | ||
this._beginningSampleOffset = | ||
oggPage[absoluteGranulePosition] - BigInt(oggPage[samples]); | ||
} | ||
if (oggPage && oggPage[isLastPage]) { | ||
// trim any extra samples that are decoded beyond the absoluteGranulePosition, relative to where we started in the stream | ||
const samplesToTrim = this[totalSamplesDecoded] - oggPage[totalSamples]; | ||
if (oggPage[isLastPage]) { | ||
// trim any extra samples that are decoded beyond the absoluteGranulePosition, relative to where we started in the stream | ||
const samplesToTrim = | ||
decoded.samplesDecoded - Number(oggPage[absoluteGranulePosition]); | ||
if (samplesToTrim > 0) { | ||
for (let i = 0; i < decoded.channelData.length; i++) | ||
decoded.channelData[i] = decoded.channelData[i].subarray( | ||
0, | ||
decoded.samplesDecoded - samplesToTrim, | ||
); | ||
if (samplesToTrim > 0) { | ||
for (let i = 0; i < decoded.channelData.length; i++) | ||
decoded.channelData[i] = decoded.channelData[i].subarray( | ||
0, | ||
decoded.samplesDecoded - samplesToTrim, | ||
); | ||
decoded.samplesDecoded -= samplesToTrim; | ||
} | ||
decoded.samplesDecoded -= samplesToTrim; | ||
} | ||
} | ||
this[totalSamplesDecoded] += decoded.samplesDecoded; | ||
return decoded; | ||
@@ -285,0 +279,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
193347
953
+ Addedcodec-parser@2.5.0(transitive)
- Removedcodec-parser@2.4.3(transitive)
Updatedcodec-parser@2.5.0