How to use the token-types.UINT16_LE function in token-types

To help you get started, we’ve selected a few token-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Borewit / music-metadata / lib / wavpack / WavPackToken.ts View on Github external
get: (buf, off) => {

      const flags = Token.UINT32_LE.get(buf, off + 24);

      const res = {
        // should equal 'wvpk'
        BlockID: FourCcToken.get(buf, off),
        //  0x402 to 0x410 are valid for decode
        blockSize: Token.UINT32_LE.get(buf, off + 4),
        //  0x402 (1026) to 0x410 are valid for decode
        version: Token.UINT16_LE.get(buf, off + 8),
        //  40-bit total samples for entire file (if block_index == 0 and a value of -1 indicates an unknown length)
        totalSamples: /* replace with bigint? (Token.UINT8.get(buf, off + 11) << 32) + */ Token.UINT32_LE.get(buf, off + 12),
        // 40-bit block_index
        blockIndex: /* replace with bigint? (Token.UINT8.get(buf, off + 10) << 32) + */ Token.UINT32_LE.get(buf, off + 16),
        // 40-bit total samples for entire file (if block_index == 0 and a value of -1 indicates an unknown length)
        blockSamples: Token.UINT32_LE.get(buf, off + 20),
        // various flags for id and decoding
        flags: {
          bitsPerSample: (1 + WavPack.getBitAllignedNumber(flags, 0, 2)) * 8,
          isMono: WavPack.isBitSet(flags, 2),
          isHybrid: WavPack.isBitSet(flags, 3),
          isJointStereo: WavPack.isBitSet(flags, 4),
          crossChannel: WavPack.isBitSet(flags, 5),
          hybridNoiseShaping: WavPack.isBitSet(flags, 6),
          floatingPoint: WavPack.isBitSet(flags, 7),
          samplingRate: SampleRates[WavPack.getBitAllignedNumber(flags, 23, 4)],
github Borewit / music-metadata / lib / apev2 / APEv2Token.ts View on Github external
get: (buf, off) => {
    return {
      // the compression level (see defines I.E. COMPRESSION_LEVEL_FAST)
      compressionLevel: Token.UINT16_LE.get(buf, off),
      // any format flags (for future use)
      formatFlags: Token.UINT16_LE.get(buf, off + 2),
      // the number of audio blocks in one frame
      blocksPerFrame: Token.UINT32_LE.get(buf, off + 4),
      // the number of audio blocks in the final frame
      finalFrameBlocks: Token.UINT32_LE.get(buf, off + 8),
      // the total number of frames
      totalFrames: Token.UINT32_LE.get(buf, off + 12),
      // the bits per sample (typically 16)
      bitsPerSample: Token.UINT16_LE.get(buf, off + 16),
      // the number of channels (1 or 2)
      channel: Token.UINT16_LE.get(buf, off + 18),
      // the sample rate (typically 44100)
      sampleRate: Token.UINT32_LE.get(buf, off + 20)
    };
  }
github Borewit / music-metadata / lib / musepack / sv7 / StreamVersion7.ts View on Github external
// word 1
      frameCount: Token.UINT32_LE.get(buf, off + 4),
      // word 2
      maxLevel:  Token.UINT16_LE.get(buf, off + 8),
      sampleFrequency:  [44100, 48000, 37800, 32000][Common.getBitAllignedNumber(buf, off + 10, 0, 2)],
      link:  Common.getBitAllignedNumber(buf, off + 10, 2, 2),
      profile:  Common.getBitAllignedNumber(buf, off + 10, 4, 4),
      maxBand: Common.getBitAllignedNumber(buf, off + 11, 0, 6),
      intensityStereo: Common.isBitSet(buf, off + 11, 6),
      midSideStereo: Common.isBitSet(buf, off + 11, 7),
      // word 3
      titlePeak: Token.UINT16_LE.get(buf, off + 12),
      titleGain: Token.UINT16_LE.get(buf, off + 14),
      // word 4
      albumPeak: Token.UINT16_LE.get(buf, off + 16),
      albumGain: Token.UINT16_LE.get(buf, off + 18),
      // word
      lastFrameLength: (Token.UINT32_LE.get(buf, off + 20) >>> 20) & 0x7FF,
      trueGapless: Common.isBitSet(buf, off + 23, 0)
    };

    header.lastFrameLength = header.trueGapless ? (Token.UINT32_LE.get(buf, 20) >>> 20) & 0x7FF : 0;

    return header;
  }
};
github Borewit / music-metadata / lib / musepack / sv7 / StreamVersion7.ts View on Github external
get: (buf, off) => {

    const header = {
      // word 0
      signature: buf.toString("binary", off, off + 3),
      // versionIndex number * 1000 (3.81 = 3810) (remember that 4-byte alignment causes this to take 4-bytes)
      streamMinorVersion:  Common.getBitAllignedNumber(buf, off + 3, 0, 4),
      streamMajorVersion: Common.getBitAllignedNumber(buf, off + 3, 4, 4),
      // word 1
      frameCount: Token.UINT32_LE.get(buf, off + 4),
      // word 2
      maxLevel:  Token.UINT16_LE.get(buf, off + 8),
      sampleFrequency:  [44100, 48000, 37800, 32000][Common.getBitAllignedNumber(buf, off + 10, 0, 2)],
      link:  Common.getBitAllignedNumber(buf, off + 10, 2, 2),
      profile:  Common.getBitAllignedNumber(buf, off + 10, 4, 4),
      maxBand: Common.getBitAllignedNumber(buf, off + 11, 0, 6),
      intensityStereo: Common.isBitSet(buf, off + 11, 6),
      midSideStereo: Common.isBitSet(buf, off + 11, 7),
      // word 3
      titlePeak: Token.UINT16_LE.get(buf, off + 12),
      titleGain: Token.UINT16_LE.get(buf, off + 14),
      // word 4
      albumPeak: Token.UINT16_LE.get(buf, off + 16),
      albumGain: Token.UINT16_LE.get(buf, off + 18),
      // word
      lastFrameLength: (Token.UINT32_LE.get(buf, off + 20) >>> 20) & 0x7FF,
      trueGapless: Common.isBitSet(buf, off + 23, 0)
    };
github Borewit / music-metadata / lib / apev2 / APEv2Token.ts View on Github external
get: (buf, off) => {
    return {
      // the compression level (see defines I.E. COMPRESSION_LEVEL_FAST)
      compressionLevel: Token.UINT16_LE.get(buf, off),
      // any format flags (for future use)
      formatFlags: Token.UINT16_LE.get(buf, off + 2),
      // the number of audio blocks in one frame
      blocksPerFrame: Token.UINT32_LE.get(buf, off + 4),
      // the number of audio blocks in the final frame
      finalFrameBlocks: Token.UINT32_LE.get(buf, off + 8),
      // the total number of frames
      totalFrames: Token.UINT32_LE.get(buf, off + 12),
      // the bits per sample (typically 16)
      bitsPerSample: Token.UINT16_LE.get(buf, off + 16),
      // the number of channels (1 or 2)
      channel: Token.UINT16_LE.get(buf, off + 18),
      // the sample rate (typically 44100)
      sampleRate: Token.UINT32_LE.get(buf, off + 20)
    };
  }
};