From acffa056a518b2e05ad22eb773b8edebcabea43f Mon Sep 17 00:00:00 2001 From: Andy Sloane Date: Fri, 30 Oct 2015 22:54:19 -0700 Subject: [PATCH] *really* fix instrument triggers last commit was completely wrong. also i read somewhere that the instrument alone doesn't reset volume, which is apparently a lie. --- xm.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/xm.js b/xm.js index af7cea2..5d563dd 100644 --- a/xm.js +++ b/xm.js @@ -219,20 +219,23 @@ function next_row() { cur_row++; for (var i = 0; i < r.length; i++) { var ch = channelinfo[i]; + var inst = ch.inst; ch.update = false; var triggernote = false; // instrument trigger if (r[i][1] != -1) { - var inst = instruments[r[i][1] - 1]; + inst = instruments[r[i][1] - 1]; if (inst != undefined) { ch.inst = inst; // retrigger unless overridden below triggernote = true; - // new instrument doesn ot reset volume! + ch.pan = inst.pan; + ch.vol = inst.vol; } else { // console.log("invalid inst", r[i][1], instruments.length); } } + // note trigger if (r[i][0] != -1) { if (r[i][0] == 96) { @@ -241,14 +244,10 @@ function next_row() { } else { // assume linear frequency table (flags header & 1 == 1) // is this true in kamel.xm? - var inst = ch.inst; if (inst != undefined) { var note = r[i][0] + inst.note; ch.note = note; triggernote = true; - // if there's an instrument and a note, set the volume - ch.pan = inst.pan; - ch.vol = inst.vol; } } } @@ -320,9 +319,7 @@ function next_row() { ch.vibratopos = 0; ch.env_vol = new EnvelopeFollower(inst.env_vol); ch.env_pan = new EnvelopeFollower(inst.env_pan); - if (note) { - ch.period = PeriodForNote(ch, note); - } + ch.period = PeriodForNote(ch, ch.note); } } }