From 215f72c19d7f02d249b90007ec093dbb89493384 Mon Sep 17 00:00:00 2001 From: Andy Sloane Date: Mon, 16 Nov 2015 18:47:41 -0800 Subject: [PATCH] Fix samples for instruments with >1 sample The sample offset was incorrectly computed, and was including the sample headers for all samples after the first one into the first sample's data, causing various glitches at the beginning of the sample. Fixes #10. --- xm.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xm.js b/xm.js index 00bb12b..45f6e9c 100644 --- a/xm.js +++ b/xm.js @@ -802,9 +802,9 @@ function load(arrayBuf) { var samppan = dv.getUint8(idx+15); var sampnote = dv.getInt8(idx+16); var sampname = getstring(dv, idx+18, 22); - var sampleoffset = idx + samphdrsiz + totalsamples; - console.log("sample %d: len %d name '%s' loop %d/%d vol %d", - j, samplen, sampname, samploop, samplooplen, sampvol); + var sampleoffset = idx + nsamp * samphdrsiz + totalsamples; + console.log("sample %d: len %d name '%s' loop %d/%d vol %d offset %s", + j, samplen, sampname, samploop, samplooplen, sampvol, sampleoffset.toString(16)); console.log(" type %d note %s(%d) finetune %d pan %d", samptype, prettify_note(sampnote + 12*4), sampnote, sampfinetune, samppan); console.log(" vol env", env_vol, env_vol_sustain,