web-> res/src

This commit is contained in:
Paolo 2024-12-06 16:10:50 +01:00
parent 394b7ac1d7
commit fb8a80f3e5
3 changed files with 8 additions and 6 deletions

View File

@ -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:

View File

@ -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;

View File

@ -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);
};