How to use the token-types.UINT24_BE 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 / flac / FlacParser.ts View on Github external
return {
        // The minimum block size (in samples) used in the stream.
        minimumBlockSize: Token.UINT16_BE.get(buf, off),
        // The maximum block size (in samples) used in the stream.
        // (Minimum blocksize == maximum blocksize) implies a fixed-blocksize stream.
        maximumBlockSize: Token.UINT16_BE.get(buf, off + 2) / 1000,
        // The minimum frame size (in bytes) used in the stream.
        // May be 0 to imply the value is not known.
        minimumFrameSize: Token.UINT24_BE.get(buf, off + 4),
        // The maximum frame size (in bytes) used in the stream.
        // May be 0 to imply the value is not known.
        maximumFrameSize: Token.UINT24_BE.get(buf, off + 7),
        // Sample rate in Hz. Though 20 bits are available,
        // the maximum sample rate is limited by the structure of frame headers to 655350Hz.
        // Also, a value of 0 is invalid.
        sampleRate: Token.UINT24_BE.get(buf, off + 10) >> 4,
        // probably slower: sampleRate: common.getBitAllignedNumber(buf, off + 10, 0, 20),
        // (number of channels)-1. FLAC supports from 1 to 8 channels
        channels: common.getBitAllignedNumber(buf, off + 12, 4, 3) + 1,
        // bits per sample)-1.
        // FLAC supports from 4 to 32 bits per sample. Currently the reference encoder and decoders only support up to 24 bits per sample.
        bitsPerSample: common.getBitAllignedNumber(buf, off + 12, 7, 5) + 1,
        // Total samples in stream.
        // 'Samples' means inter-channel sample, i.e. one second of 44.1Khz audio will have 44100 samples regardless of the number of channels.
        // A value of zero here means the number of total samples is unknown.
        totalSamples: common.getBitAllignedNumber(buf, off + 13, 4, 36),
        // the MD5 hash of the file (see notes for usage... it's a littly tricky)
        fileMD5: new Token.BufferType(16).get(buf, off + 18)
      };
    }
  };
github Borewit / music-metadata / src / flac / FlacParser.ts View on Github external
get: (buf: Buffer, off: number): IBlockStreamInfo => {
      return {
        // The minimum block size (in samples) used in the stream.
        minimumBlockSize: Token.UINT16_BE.get(buf, off),
        // The maximum block size (in samples) used in the stream.
        // (Minimum blocksize == maximum blocksize) implies a fixed-blocksize stream.
        maximumBlockSize: Token.UINT16_BE.get(buf, off + 2) / 1000,
        // The minimum frame size (in bytes) used in the stream.
        // May be 0 to imply the value is not known.
        minimumFrameSize: Token.UINT24_BE.get(buf, off + 4),
        // The maximum frame size (in bytes) used in the stream.
        // May be 0 to imply the value is not known.
        maximumFrameSize: Token.UINT24_BE.get(buf, off + 7),
        // Sample rate in Hz. Though 20 bits are available,
        // the maximum sample rate is limited by the structure of frame headers to 655350Hz.
        // Also, a value of 0 is invalid.
        sampleRate: Token.UINT24_BE.get(buf, off + 10) >> 4,
        // probably slower: sampleRate: common.getBitAllignedNumber(buf, off + 10, 0, 20),
        // (number of channels)-1. FLAC supports from 1 to 8 channels
        channels: common.getBitAllignedNumber(buf, off + 12, 4, 3) + 1,
        // bits per sample)-1.
        // FLAC supports from 4 to 32 bits per sample. Currently the reference encoder and decoders only support up to 24 bits per sample.
        bitsPerSample: common.getBitAllignedNumber(buf, off + 12, 7, 5) + 1,
        // Total samples in stream.
        // 'Samples' means inter-channel sample, i.e. one second of 44.1Khz audio will have 44100 samples regardless of the number of channels.
        // A value of zero here means the number of total samples is unknown.
github Borewit / music-metadata / lib / mp4 / AtomToken.ts View on Github external
get: (buf: Buffer, off: number): IMovieHeaderAtom => {
    return {
      version: Token.UINT8.get(buf, off + 0),
      flags: Token.UINT24_BE.get(buf, off + 1),
      nextItemID: Token.UINT32_BE.get(buf, off + 4)
    };
  }
};
github Borewit / music-metadata / lib / ogg / theora / Theora.ts View on Github external
get: (buf, off): IIdentificationHeader => {
    return {
      id: new Token.StringType(7, 'ascii').get(buf, off),
      vmaj: buf.readUInt8(off + 7),
      vmin: buf.readUInt8(off + 8),
      vrev: buf.readUInt8(off + 9),
      vmbw: buf.readUInt16BE(off + 10),
      vmbh: buf.readUInt16BE(off + 17),
      nombr: Token.UINT24_BE.get(buf, off + 37),
      nqual: buf.readUInt8(off + 40)
    };
  }
};
github Borewit / music-metadata / src / flac / FlacParser.ts View on Github external
get: (buf: Buffer, off: number): IBlockHeader => {
      return {
        lastBlock: common.strtokBITSET.get(buf, off, 7),
        type: common.getBitAllignedNumber(buf, off, 1, 7),
        length: Token.UINT24_BE.get(buf, off + 1)
      };
    }
  };
github Borewit / music-metadata / lib / flac / FlacParser.ts View on Github external
get: (buf: Buffer, off: number): IBlockHeader => {
      return {
        lastBlock: common.strtokBITSET.get(buf, off, 7),
        type: common.getBitAllignedNumber(buf, off, 1, 7),
        length: Token.UINT24_BE.get(buf, off + 1)
      };
    }
  };
github Borewit / music-metadata / lib / id3v2 / ID3v2Parser.ts View on Github external
private static readFrameHeader(v, majorVer): IFrameHeader {
    let header: IFrameHeader;
    switch (majorVer) {

      case 2:
        header = {
          id: v.toString('ascii', 0, 3),
          length: Token.UINT24_BE.get(v, 3)
        };
        break;

      case 3:
        header = {
          id: v.toString('ascii', 0, 4),
          length: Token.UINT32_BE.get(v, 4),
          flags: ID3v2Parser.readFrameFlags(v.slice(8, 10))
        };
        break;

      case 4:
        header = {
          id: v.toString('ascii', 0, 4),
          length: UINT32SYNCSAFE.get(v, 4),
          flags: ID3v2Parser.readFrameFlags(v.slice(8, 10))
github Borewit / music-metadata / lib / mp4 / AtomToken.ts View on Github external
public get(buf: Buffer, off: number): INameAtom {
    return {
      version: Token.UINT8.get(buf, off),
      flags: Token.UINT24_BE.get(buf, off + 1),
      name: new Token.StringType(this.len - 4, 'utf-8').get(buf, off + 4)
    };
  }
}