From 966e3b080f039fa1c62113e75e1e1481d7e19439 Mon Sep 17 00:00:00 2001 From: julian laplace Date: Mon, 7 Jul 2025 12:13:51 +0200 Subject: trigger index --- bundle.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'bundle.js') diff --git a/bundle.js b/bundle.js index 3deb479..257fb27 100644 --- a/bundle.js +++ b/bundle.js @@ -22520,7 +22520,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;(function(root, factory){ Object.defineProperty(exports, "__esModule", { value: true }); -exports.requestAudioContext = exports.roundFreq = exports.browser = exports.mod = exports.choice = undefined; +exports.requestAudioContext = exports.frequencyInRange = exports.roundFreq = exports.browser = exports.mod = exports.choice = undefined; var _tone = __webpack_require__(0); @@ -22556,6 +22556,9 @@ function mod(n, m) { function roundFreq(freq) { return Math.round(freq * 100); } +var frequencyInRange = function frequencyInRange(freq) { + return 20 < freq && freq < 15000; +}; function requestAudioContext(fn) { if (window.location.protocol !== "https:") { @@ -22604,6 +22607,7 @@ exports.choice = choice; exports.mod = mod; exports.browser = browser; exports.roundFreq = roundFreq; +exports.frequencyInRange = frequencyInRange; exports.requestAudioContext = requestAudioContext; /***/ }), @@ -23442,10 +23446,12 @@ function rebuild() { } function log() { var seen = {}; + console.log(notes); for (var i = 0; i < 8; i++) { for (var j = 0; j < 8; j++) { - var rounded = (0, _util.roundFreq)(notes[i][j].frequency); - if (!seen[rounded] && 20 < rounded && rounded < 12000) { + var frequency = notes[i][j].frequency; + var rounded = (0, _util.roundFreq)(frequency); + if (!seen[rounded] && (0, _util.frequencyInRange)(frequency)) { seen[rounded] = notes[i][j].frequency; } } @@ -23475,13 +23481,15 @@ function play(freq) { } } function trigger(freq) { - if (20 && freq.frequency && freq.frequency < 15000) { + if ((0, _util.frequencyInRange)(freq.frequency)) { instrument.play(freq.frequency); } } function trigger_index(index) { var frequency = frequencies[index]; - instrument.play(frequency); + if (frequency) { + instrument.play(frequency); + } } function pause(freq) { _organ2.default.pause(freq.frequency); -- cgit v1.2.3-70-g09d2