acl-js/src-js/decoder.js
// Decompressed samples will be written to the DecompressedTracks instance.
Decompressed samples will be written to the DecompressedTracks instance.
Decompressed samples will be written to the DecompressedTracks instance .
decompressTracks(compressedTracks, sampleTime, roundingPolicy, decompressedTracks) {
    if (!wasmState.module) {
      throw new Error('WASM module not ready')
    }
    if (!compressedTracks || !(compressedTracks instanceof CompressedTracks)) {
      throw new TypeError("'compressedTracks' must be a CompressedTracks instance")
    }
    if (!compressedTracks.isBound) {
      throw new Error("'compressedTracks' must be bound")
    }
    if (!Number.isFinite(sampleTime)) {
      throw new RangeError(`Invalid sample time: ${sampleTime}`)
    }
    if (!isRoundingPolicy(roundingPolicy)) {
      throw new TypeError("'roundingPolicy' must be a RoundingPolicy")
    }
    if (!decompressedTracks || !(decompressedTracks instanceof DecompressedTracks)) {
      throw new TypeError("'decompressedTracks' cannot be null and must be a DecompressedTracks instance")
    }
    const outputBufferSize = compressedTracks.outputBufferSize
    if (decompressedTracks.byteLength < outputBufferSize) {
      decompressedTracks.resize(outputBufferSize)
    }
    const compressedTracksSize = compressedTracks._mem.byteLength
    const compressedTracksBuffer = compressedTracks._mem.byteOffset
    const outputBuffer = decompressedTracks._mem.byteOffset
    const result = wasmState.instance.exports.decompress_tracks(compressedTracksBuffer, compressedTracksSize, sampleTime, roundingPolicy.value, outputBuffer, outputBufferSize)
    if (result != 0) {
      throw new Error(`Decompression failed: ${result}`)
    }
    return decompressedTracks
  }
decompressTracks ( compressedTracks , sampleTime , roundingPolicy , decompressedTracks ) { if ( ! wasmState . module ) { throw new Error ( 'WASM module not ready' ) } if ( ! compressedTracks || ! ( compressedTracks instanceof CompressedTracks ) ) { throw new TypeError ( "'compressedTracks' must be a CompressedTracks instance" ) } if ( ! compressedTracks . isBound ) { throw new Error ( "'compressedTracks' must be bound" ) } if ( ! Number . isFinite ( sampleTime ) ) { throw new RangeError ( ` ${ sampleTime } ` ) } if ( ! isRoundingPolicy ( roundingPolicy ) ) { throw new TypeError ( "'roundingPolicy' must be a RoundingPolicy" ) } if ( ! decompressedTracks || ! ( decompressedTracks instanceof DecompressedTracks ) ) { throw new TypeError ( "'decompressedTracks' cannot be null and must be a DecompressedTracks instance" ) } const outputBufferSize = compressedTracks . outputBufferSize if ( decompressedTracks . byteLength < outputBufferSize ) { decompressedTracks . resize ( outputBufferSize ) } const compressedTracksSize = compressedTracks . _mem . byteLength const compressedTracksBuffer = compressedTracks . _mem . byteOffset const outputBuffer = decompressedTracks . _mem . byteOffset const result = wasmState . instance . exports . decompress_tracks ( compressedTracksBuffer , compressedTracksSize , sampleTime , roundingPolicy . value , outputBuffer , outputBufferSize ) if ( result != 0 ) { throw new Error ( ` ${ result } ` ) } return decompressedTracks }
Decompressed samples will be written to the DecompressedTracks instance.
Decompressed samples will be written to the DecompressedTracks instance .
// Make sure we can store our result //console.log(`Decompression result: ${result}`)