How to use the token-types.UINT24_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 / WavPackParser.ts View on Github external
private async parseMetadataSubBlock(header: IBlockHeader, remainingLength: number): Promise {
    while (remainingLength > WavPack.MetadataIdToken.len) {
      const id = await this.tokenizer.readToken(WavPack.MetadataIdToken);
      const dataSizeInWords = await this.tokenizer.readNumber(id.largeBlock ? Token.UINT24_LE : Token.UINT8);
      const data = Buffer.alloc(dataSizeInWords * 2 - (id.isOddSize ? 1 : 0));
      await this.tokenizer.readBuffer(data, 0, data.length);
      debug(`Metadata Sub-Blocks functionId=0x${id.functionId.toString(16)}, id.largeBlock=${id.largeBlock},data-size=${data.length}`);
      switch (id.functionId) {
        case 0x0: // ID_DUMMY: could be used to pad WavPack blocks
          break;

        case 0xe: // ID_DSD_BLOCK
          debug('ID_DSD_BLOCK');
          // https://github.com/dbry/WavPack/issues/71#issuecomment-483094813
          const mp = 1 << data.readUInt8(0);
          const samplingRate = header.flags.samplingRate * mp * 8; // ToDo: second factor should be read from DSD-metadata block https://github.com/dbry/WavPack/issues/71#issuecomment-483094813
          assert.ok(header.flags.isDSD, 'Only expect DSD block if DSD-flag is set');
          this.metadata.setFormat('sampleRate', samplingRate);
          this.metadata.setFormat('duration', header.totalSamples / samplingRate);
          break;
github Borewit / music-metadata / lib / wavpack / WavPackParser.ts View on Github external
break;

        case 0x26: // ID_MD5_CHECKSUM
          this.metadata.setFormat('audioMD5', data);
          break;

        case 0x2f: // ID_BLOCK_CHECKSUM
           debug(`ID_BLOCK_CHECKSUM: checksum=${data.toString('hex')}`);
           break;

        default:
          debug(`Ignore unsupported meta-sub-block-id functionId=0x${id.functionId.toString(16)}`);
          break;
      }

      remainingLength -= WavPack.MetadataIdToken.len + (id.largeBlock ? Token.UINT24_LE.len : Token.UINT8.len) + dataSizeInWords * 2;
      debug(`remainingLength=${remainingLength}`);
      if (id.isOddSize)
        this.tokenizer.ignore(1);
      }
    assert.strictEqual(remainingLength, 0, 'metadata-sub-block should fit it remaining length');
  }