From fb8a80f3e586a1ac1917b949eb3abde27b5d2ca2 Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 6 Dec 2024 16:10:50 +0100 Subject: [PATCH] web-> res/src --- templates/web-make/Makefile | 4 ++-- templates/web/src/processor.js | 6 ++++-- templates/web/tibia-index.js | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/templates/web-make/Makefile b/templates/web-make/Makefile index 067735a..3f6c152 100644 --- a/templates/web-make/Makefile +++ b/templates/web-make/Makefile @@ -89,10 +89,10 @@ build/web/$(BUNDLE_NAME).wasm: $(C_OBJS) $(CXX_OBJS) | build/web $(CXX) $^ -o $@ $(CFLAGS_ALL) $(CXXFLAGS_ALL) $(LDFLAGS_ALL) endif -build/web/$(BUNDLE_NAME)_processor.js: $(DATA_DIR)/src/processor.js | build/web +build/web/$(BUNDLE_NAME)_processor.js: $(DATA_DIR)/res/processor.js | build/web cp $^ $@ -build/web/$(BUNDLE_NAME).js: $(DATA_DIR)/src/module.js | build/web +build/web/$(BUNDLE_NAME).js: $(DATA_DIR)/res/module.js | build/web cp $^ $@ build/web build/obj: diff --git a/templates/web/src/processor.js b/templates/web/src/processor.js index d9b2778..9eb4d2e 100644 --- a/templates/web/src/processor.js +++ b/templates/web/src/processor.js @@ -30,6 +30,8 @@ var nChansOut = busesOut.reduce((a, x) => a + (x.channels == "mono" ? 1 : 2), 0 var cpu_meter = 0.0; var sampleRate = 1.0; +const now = globalThis.performance ? performance.now : Date.now; + class Processor extends AudioWorkletProcessor { constructor(options) { super(); @@ -74,7 +76,7 @@ class Processor extends AudioWorkletProcessor { } process(inputs, outputs, params) { - const processTimeStart = performance.now(); + const processTimeStart = now(); for (var i = 0; i < this.parametersIn.length; i++) { var index = this.parametersIn[i].index; @@ -158,7 +160,7 @@ class Processor extends AudioWorkletProcessor { this.parametersOut[i].value = value; } } - const processTimeEnd = performance.now(); + const processTimeEnd = now(); const processTimeMs = processTimeEnd - processTimeStart; const processTimeS = processTimeMs * 0.001; cpu_meter = cpu_meter * 0.9 + (processTimeS * sampleRate) * 0.1; diff --git a/templates/web/tibia-index.js b/templates/web/tibia-index.js index 6428f42..075a340 100644 --- a/templates/web/tibia-index.js +++ b/templates/web/tibia-index.js @@ -29,6 +29,6 @@ module.exports = function (data, api) { api.copyFile(`src${sep}new.cpp`, `src${sep}new.cpp`); api.copyFile(`src${sep}processor.c`, `src${sep}processor.c`); api.generateFileFromTemplateFile(`src${sep}data.h`, `src${sep}data.h`, data); - api.generateFileFromTemplateFile(`src${sep}processor.js`, `src${sep}processor.js`, data); - api.generateFileFromTemplateFile(`src${sep}module.js`, `src${sep}module.js`, data); + api.generateFileFromTemplateFile(`src${sep}processor.js`, `res${sep}processor.js`, data); + api.generateFileFromTemplateFile(`src${sep}module.js`, `res${sep}module.js`, data); };