PageSourceSearch

https://genrova.com/themes/default/assets/js/audio/audio-worklet-processor.js

js genrova.com collected 2026-10-04 23:48:59 UTC 703 bytes, 27 lines download raw bytes

1class PCMProcessor extends AudioWorkletProcessor {
2	constructor() {
3		super();
4	}
5
6	process(inputs, outputs, parameters) {
7		const input = inputs[0];
8		if (input.length > 0) {
9			const float32Buffer = input[0];
10			const int16Buffer = this.convertFloat32ToInt16(float32Buffer);
11			this.port.postMessage(int16Buffer);
12		}
13		return true;
14	}
15
16	convertFloat32ToInt16(float32Array) {
17		const int16Array = new Int16Array(float32Array.length);
18		for (let i = 0; i < float32Array.length; i++) {
19			let val = Math.floor(float32Array[i] * 0x7fff);
20			val = Math.max(-0x8000, Math.min(0x7fff, val));
21			int16Array[i] = val;
22		}
23		return int16Array;
24	}
25}
26
27registerProcessor('audio-worklet-processor', PCMProcessor);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.