Add splitComputation option to node.configure()

This commit is contained in:
Geraint 2025-04-14 15:45:38 +01:00
parent 49dc7bf6b9
commit aabe5abf4c
2 changed files with 10 additions and 5 deletions

View File

@ -46,8 +46,8 @@ extern "C" {
void EMSCRIPTEN_KEEPALIVE presetCheaper(int nChannels, Sample sampleRate) { void EMSCRIPTEN_KEEPALIVE presetCheaper(int nChannels, Sample sampleRate) {
stretch.presetCheaper(nChannels, sampleRate); stretch.presetCheaper(nChannels, sampleRate);
} }
void EMSCRIPTEN_KEEPALIVE configure(int nChannels, int blockSamples, int intervalSamples) { void EMSCRIPTEN_KEEPALIVE configure(int nChannels, int blockSamples, int intervalSamples, bool splitComputation) {
stretch.configure(nChannels, blockSamples, intervalSamples); stretch.configure(nChannels, blockSamples, intervalSamples, splitComputation);
} }
void EMSCRIPTEN_KEEPALIVE setTransposeFactor(Sample multiplier, Sample tonalityLimit) { void EMSCRIPTEN_KEEPALIVE setTransposeFactor(Sample multiplier, Sample tonalityLimit) {
stretch.setTransposeFactor(multiplier, tonalityLimit); stretch.setTransposeFactor(multiplier, tonalityLimit);

View File

@ -27,9 +27,11 @@ function registerWorkletProcessor(Module, audioNodeKey) {
let remoteMethods = { let remoteMethods = {
configure: config => { configure: config => {
let blockChanged = (config.blockMs != this.config.blockMs || config.intervalMs != this.config.intervalMs);
Object.assign(this.config, config); Object.assign(this.config, config);
if (config.blockMs && blockChanged) this.configure(); this.configure();
},
latency: _ => {
return this.inputLatencySeconds + this.outputLatencySeconds;
}, },
setUpdateInterval: seconds => { setUpdateInterval: seconds => {
this.timeIntervalSamples = sampleRate*seconds; this.timeIntervalSamples = sampleRate*seconds;
@ -182,8 +184,11 @@ function registerWorkletProcessor(Module, audioNodeKey) {
if (this.config.blockMs) { if (this.config.blockMs) {
let blockSamples = Math.round(this.config.blockMs/1000*sampleRate); let blockSamples = Math.round(this.config.blockMs/1000*sampleRate);
let intervalSamples = Math.round((this.config.intervalMs || this.config.blockMs*0.25)/1000*sampleRate); let intervalSamples = Math.round((this.config.intervalMs || this.config.blockMs*0.25)/1000*sampleRate);
this.wasmModule._configure(this.channels, blockSamples, intervalSamples); let splitComputation = this.config.splitComputation;
this.wasmModule._configure(this.channels, blockSamples, intervalSamples, splitComputation);
this.wasmModule._reset(); this.wasmModule._reset();
} else if (this.config.preset == 'cheaper') {
this.wasmModule._presetCheaper(this.channels, sampleRate);
} else { } else {
this.wasmModule._presetDefault(this.channels, sampleRate); this.wasmModule._presetDefault(this.channels, sampleRate);
} }