| 16 | |
| 17 | #if AUDIO_WORKLET_SUPPORT_AUDIO_PARAMS |
| 18 | function createWasmAudioWorkletProcessor(audioParams) { |
| 19 | #else |
| 20 | function createWasmAudioWorkletProcessor() { |
| 21 | #endif |
| 22 | class WasmAudioWorkletProcessor extends AudioWorkletProcessor { |
| 23 | constructor(args) { |
| 24 | super(); |
| 25 | |
| 26 | // Capture the Wasm function callback to invoke. |
| 27 | let opts = args.processorOptions; |
| 28 | #if ASSERTIONS |
| 29 | assert(opts.callback) |
| 30 | assert(opts.samplesPerChannel) |
| 31 | #endif |
| 32 | this.callback = {{{ makeDynCall('iipipipp', 'opts.callback') }}}; |
| 33 | this.userData = opts.userData; |
| 34 | // Then the samples per channel to process, fixed for the lifetime of the |
| 35 | // context that created this processor. Even though this 'render quantum |
| 36 | // size' is fixed at 128 samples in the 1.0 spec, it will be variable in |
| 37 | // the 1.1 spec. It's passed in now, just to prove it's settable, but will |
| 38 | // eventually be a property of the AudioWorkletGlobalScope (globalThis). |
| 39 | this.samplesPerChannel = opts.samplesPerChannel; |
| 40 | this.bytesPerChannel = this.samplesPerChannel * {{{ getNativeTypeSize('float') }}}; |
| 41 | |
| 42 | // Prepare the output views; see createOutputViews(). The 'STACK_ALIGN' |
| 43 | // deduction stops the STACK_OVERFLOW_CHECK failing (since the stack will |