From 28d4558955c8c9d684996ef388ff21774d699899 Mon Sep 17 00:00:00 2001 From: Deanna Gelbart Date: Sun, 23 May 2021 16:24:42 -0700 Subject: [PATCH 1/2] Bugfix: allow playing two different samples which map to the same value in KeyEnum --- js/core.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/js/core.js b/js/core.js index 8e56db3..713a517 100644 --- a/js/core.js +++ b/js/core.js @@ -145,6 +145,7 @@ const LayersPerInstrumentEnum = Object.freeze({ "layer-tambourine": InstrumentEnum.TAMBOURINE, "layer-cowbell": InstrumentEnum.COWBELL }) + var pressed = []; var currentLayer; var allLayers = []; @@ -185,21 +186,22 @@ $.wait = function(callback, ms) { $.play = function(instrument, key, state) { var instrumentName = Object.keys(InstrumentEnum).find(k => InstrumentEnum[k] === instrument).toLowerCase(); var commonKey = KeyEnum[key]; + var tag = instrumentName + commonKey; var id = "#" + (instrument == InstrumentEnum.MEOW ? "mouth" : "paw-" + ((instrument == InstrumentEnum.BONGO ? commonKey : commonKey <= 5 && commonKey != 0 ? 0 : 1) == 0 ? "left" : "right")); if (state == true) { - if (jQuery.inArray(commonKey, pressed) !== -1) { + if (jQuery.inArray(tag, pressed) !== -1) { return; } - pressed.push(commonKey); + pressed.push(tag); if (instrument != InstrumentEnum.MEOW) { $(".instruments>div").each(function(index) { $(this).css("visibility", ($(this).attr("id") === instrumentName) ? "visible" : "hidden"); }); } - lowLag.play(instrumentName + commonKey); + lowLag.play(tag); $.layers(Object.keys(LayersPerInstrumentEnum).find(k => LayersPerInstrumentEnum[k] == instrument), true); } else { - pressed.remove(commonKey); + pressed.remove(tag); } $(id).css("background-position-x", (state ? "-800px" : "0")); } From e13e45a4dc8c560043d1205f7050c95a59abf9d5 Mon Sep 17 00:00:00 2001 From: Deanna Gelbart Date: Sun, 23 May 2021 16:27:27 -0700 Subject: [PATCH 2/2] Remove accidentally added newline --- js/core.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/core.js b/js/core.js index 713a517..4d923c3 100644 --- a/js/core.js +++ b/js/core.js @@ -145,7 +145,6 @@ const LayersPerInstrumentEnum = Object.freeze({ "layer-tambourine": InstrumentEnum.TAMBOURINE, "layer-cowbell": InstrumentEnum.COWBELL }) - var pressed = []; var currentLayer; var allLayers = [];