import assert from 'node:assert/strict'; import test from 'node:test'; import { collectPads } from '../src/lib/parsers'; import { TarFile } from '../src/lib/untar'; function padFile(name: string, length: 26 | 27) { const data = new Uint8Array(length); return { data, file: new TarFile(name, data.length, data) }; } test('decodes optional fractional pitch arithmetically for 26- and 27-byte pad records', () => { const native = padFile('pads/a/p01', 26); native.data[17] = 0xff; const extended = padFile('pads/a/p02', 27); extended.data[17] = 0xff; extended.data[26] = 91; const pads = collectPads([native.file, extended.file], []); assert.equal(pads.a[0].pitch, -1); assert.ok(Math.abs(pads.a[1].pitch - -0.09) < 1e-12); }); test('reads trim length as unsigned 32-bit little-endian data', () => { const pad = padFile('pads/a/p01', 26); pad.data.set([0x03, 0x02, 0x01], 4); pad.data.set([0x04, 0x03, 0x02, 0x01], 8); const parsed = collectPads([pad.file], []).a[0]; assert.equal(parsed.trimLeft, 0x010203); assert.equal(parsed.trimRight, 0x010203 + 0x01020304); }); test('treats every nonzero mute byte as shared mute-group membership', () => { const member = padFile('pads/a/p01', 26); const nonmember = padFile('pads/a/p02', 26); member.data[22] = 200; const pads = collectPads([member.file, nonmember.file], []).a; assert.equal(pads[0].inChokeGroup, true); assert.equal(pads[1].inChokeGroup, false); });