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 9df4cf8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/aiff/AiffToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ 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
};

if (this.isAifc) {
res.compressionType = FourCcToken.get(buf, off + 18);
if (this.len > 22) {
const strLen = buf.readInt8(off + 22);
const strLen = Token.UINT8.get(buf, off + 22);
if (strLen > 0) {
const padding = (strLen + 1) % 2;
if (23 + strLen + padding === this.len) {
Expand Down

0 comments on commit 9df4cf8

Please sign in to comment.