| 43 | new Function(code)() |
| 44 | }, |
| 45 | async step(numSamples: int): Promise<Float32Array[]> { |
| 46 | const engine = state.unwrap() |
| 47 | const result: Float32Array[] = Arrays.create(() => new Float32Array(numSamples), engine.numberOfChannels) |
| 48 | const outputChannels: Float32Array[] = Arrays.create(() => new Float32Array(RenderQuantum), engine.numberOfChannels) |
| 49 | let offset = 0 | 0 |
| 50 | while (offset < numSamples) { |
| 51 | const outputs: Float32Array[][] = [outputChannels] |
| 52 | updateFrameTime(engine.totalFrames, engine.sampleRate) |
| 53 | engine.processor.process([[]], outputs) |
| 54 | engine.totalFrames += RenderQuantum |
| 55 | const needed = numSamples - offset |
| 56 | const toCopy = Math.min(needed, RenderQuantum) |
| 57 | for (let ch = 0; ch < engine.numberOfChannels; ch++) { |
| 58 | result[ch].set(outputs[0][ch].subarray(0, toCopy), offset) |
| 59 | } |
| 60 | offset += toCopy |
| 61 | } |
| 62 | return result |
| 63 | }, |
| 64 | async render(config: OfflineEngineRenderConfig) { |
| 65 | const engine = state.unwrap() |
| 66 | const {silenceThresholdDb, silenceDurationSeconds, maxDurationSeconds} = config |