mirror of
https://github.com/whscullin/apple2js.git
synced 2024-01-12 14:14:38 +00:00
04ae0327c2
This adds both the recommended TypeScript checks, plus the recommended TypeScript checks that require type checking. This latter addition means that eslint essentially has to compile all of the TypeScript in the project, causing it to be slower. This isn't much of a problem in VS Code because there's a lot of caching being done, but it's clearly slower when run on the commandline. All of the errors are either fixed or suppressed. Some errors are suppressed because fixing them would be too laborious for the little value gained. The eslint config is also slightly refactored to separate the strictly TypeScript checks from the JavaScript checks.
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
declare global {
|
|
interface AudioWorkletProcessor {
|
|
readonly port: MessagePort;
|
|
process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: Map<string, Float32Array>): void;
|
|
}
|
|
|
|
const AudioWorkletProcessor: {
|
|
prototype: AudioWorkletProcessor;
|
|
new(options?: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
};
|
|
|
|
function registerProcessor(name: string, ctor :{ new(): AudioWorkletProcessor }): void;
|
|
}
|
|
|
|
export interface AppleAudioMessageEvent extends MessageEvent {
|
|
data: Float32Array;
|
|
}
|
|
|
|
export class AppleAudioProcessor extends AudioWorkletProcessor {
|
|
private samples: Float32Array[] = [];
|
|
|
|
constructor() {
|
|
super();
|
|
console.info('AppleAudioProcessor constructor');
|
|
this.port.onmessage = (ev: AppleAudioMessageEvent) => {
|
|
this.samples.push(ev.data);
|
|
if (this.samples.length > 256) {
|
|
this.samples.shift();
|
|
}
|
|
};
|
|
}
|
|
|
|
static get parameterDescriptors() {
|
|
return [];
|
|
}
|
|
|
|
process(_inputList: Float32Array[][], outputList: Float32Array[][], _parameters: Map<string, Float32Array>) {
|
|
const sample = this.samples.shift();
|
|
const output = outputList[0];
|
|
if (sample) {
|
|
for (let idx = 0; idx < sample.length; idx++) {
|
|
output[0][idx] = sample[idx];
|
|
}
|
|
}
|
|
|
|
// Keep alive indefinitely.
|
|
return true;
|
|
}
|
|
}
|
|
|
|
registerProcessor('audio_worker', AppleAudioProcessor);
|