Extend JamesDSP with convolution and spatial audio
This commit is contained in:
9
frontend/vendor/jamesdsp/worklet.mjs
vendored
9
frontend/vendor/jamesdsp/worklet.mjs
vendored
@@ -1,7 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// AudioWorkletGlobalScope does not support dynamic import; this immutable
|
||||
// vendor path is versioned with the upstream pin and remapped by the SW cache.
|
||||
import createJamesDSP from './dsp/jamesdsp-77be0b2.mjs';
|
||||
import createJamesDSP from './dsp/jamesdsp-a982b53.mjs';
|
||||
class JamesDSPProcessor extends AudioWorkletProcessor {
|
||||
constructor(options) {
|
||||
super(); this.closed=false;this.failed=false;
|
||||
@@ -31,7 +29,10 @@ class JamesDSPProcessor extends AudioWorkletProcessor {
|
||||
if(data.type==='param') result=this.string(data.name,p=>this.wasm._jdsp_set_param(this.handle,p,data.value));
|
||||
else if(data.type==='ir') {
|
||||
const p=this.wasm._malloc(data.pcm.byteLength);if(!p) throw new Error('IR allocation failed');
|
||||
try {this.wasm.HEAPF32.set(data.pcm,p/4);result=this.wasm._jdsp_load_ir(this.handle,p,data.frames,data.channels);} finally {this.wasm._free(p);}
|
||||
try {this.wasm.HEAPF32.set(data.pcm,p/4);result=this.wasm._jdsp_load_ir_ex(this.handle,p,data.frames,data.channels,data.sourceRate);} finally {this.wasm._free(p);}
|
||||
} else if(data.type==='info') {
|
||||
const p=this.wasm._malloc(64);if(!p)throw new Error('DSP info allocation failed');
|
||||
try {result=this.wasm._jdsp_get_info(this.handle,p);if(result===0){const bytes=this.wasm.HEAPU8.slice(p,p+64);this.port.postMessage({type:'reply',id:data.id,result:{bytes:bytes.buffer,heapBytes:this.wasm.HEAPU8.buffer.byteLength}},[bytes.buffer]);return;}} finally {this.wasm._free(p);}
|
||||
} else throw new Error('Unknown DSP message');
|
||||
if(result!==0) throw new Error(`DSP rejected ${data.name||data.effect||data.type}`);
|
||||
this.port.postMessage({type:'reply',id:data.id,result});
|
||||
|
||||
Reference in New Issue
Block a user