import * as Token from 'token-types' ; import { IGetToken } from 'strtok3/lib/core' ; import * as util from '../../common/Util' ; /**
 * MusePack stream version 7 format specification
 * http://trac.musepack.net/musepack/wiki/SV7Specification
 */ export interface IHeader { signature : string ; streamMinorVersion : number ; streamMajorVersion : number ; frameCount : number ; intensityStereo : boolean ; midSideStereo : boolean ; maxBand : number ; profile : number ; link : number ; sampleFrequency : number ; maxLevel : number ; titleGain : number ; titlePeak : number ; albumGain : number ; albumPeak : number ; trueGapless : boolean ; lastFrameLength : number ; } /**
 * BASIC STRUCTURE
 */ export const Header = { len : 6 * 4 , get : ( buf , off ) => { const header = { signature : Buffer . from ( buf ) . toString ( 'latin1' , off , off + 3 ) , streamMinorVersion : util . getBitAllignedNumber ( buf , off + 3 , 0 , 4 ) , streamMajorVersion : util . getBitAllignedNumber ( buf , off + 3 , 4 , 4 ) , frameCount : Token . UINT32_LE . get ( buf , off + 4 ) , maxLevel : Token . UINT16_LE . get ( buf , off + 8 ) , sampleFrequency : [ 44100 , 48000 , 37800 , 32000 ] [ util . getBitAllignedNumber ( buf , off + 10 , 0 , 2 ) ] , link : util . getBitAllignedNumber ( buf , off + 10 , 2 , 2 ) , profile : util . getBitAllignedNumber ( buf , off + 10 , 4 , 4 ) , maxBand : util . getBitAllignedNumber ( buf , off + 11 , 0 , 6 ) , intensityStereo : util . isBitSet ( buf , off + 11 , 6 ) , midSideStereo : util . isBitSet ( buf , off + 11 , 7 ) , titlePeak : Token . UINT16_LE . get ( buf , off + 12 ) , titleGain : Token . UINT16_LE . get ( buf , off + 14 ) , albumPeak : Token . UINT16_LE . get ( buf , off + 16 ) , albumGain : Token . UINT16_LE . get ( buf , off + 18 ) , lastFrameLength : ( Token . UINT32_LE . get ( buf , off + 20 ) >>> 20 ) & 0x7FF , trueGapless : util . isBitSet ( buf , off + 23 , 0 ) } ; header . lastFrameLength = header . trueGapless ? ( Token . UINT32_LE . get ( buf , 20 ) >>> 20 ) & 0x7FF : 0 ; return header ; } } ;