Skip to content

Commit

Permalink
Fix decoding of numbers in AIFF-token
Browse files Browse the repository at this point in the history
  • Loading branch information
Borewit committed Jun 29, 2024
1 parent b2be0c6 commit 09dd444
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/aiff/AiffToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ export class Common implements IGetToken<ICommon> {
public get(buf: Buffer, off: number): ICommon {

// see: https://cycling74.com/forums/aiffs-80-bit-sample-rate-value
const shift = buf.readUInt16BE(off + 8) - 16398;
const baseSampleRate = buf.readUInt16BE(off + 8 + 2);
const shift = Token.UINT16_BE.get(buf, off + 8) - 16398;
const baseSampleRate = Token.UINT16_BE.get(buf, off + 8 + 2);

const res: ICommon = {
numChannels: buf.readUInt16BE(off),
numSampleFrames: buf.readUInt32BE(off + 2),
sampleSize: buf.readUInt16BE(off + 6),
numChannels: Token.UINT16_BE.get(buf, off),
numSampleFrames: Token.UINT32_BE.get(buf, off + 2),
sampleSize: Token.UINT16_BE.get(buf, off + 6),
sampleRate: shift < 0 ? baseSampleRate >> Math.abs(shift) : baseSampleRate << shift
};

Expand Down

0 comments on commit 09dd444

Please sign in to comment.