Skip to content

Commit

Permalink
Embed DSP types
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Nov 16, 2024
1 parent 81c6a16 commit 95cfca9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
32 changes: 0 additions & 32 deletions src/devices/audioworklet.d.ts

This file was deleted.

34 changes: 33 additions & 1 deletion src/devices/dsp.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
/* Credit: David Konsumer */
import type { DeviceDriver, DeviceFile } from '@zenfs/core';
import './audioworklet.d.ts';

/* Types pulled from @types/audioworklet */

/* eslint-disable no-var, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars */

/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioWorkletProcessor) */
interface AudioWorkletProcessor {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioWorkletProcessor/port) */
readonly port: MessagePort;

process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: Record<string, Float32Array>): boolean;
}

declare var AudioWorkletProcessor: {
prototype: AudioWorkletProcessor;
new (): AudioWorkletProcessor;
};

interface AudioWorkletProcessorConstructor {
new (options: any): AudioWorkletProcessor;
}

/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioWorkletGlobalScope/currentFrame) */
declare var currentFrame: number;

/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioWorkletGlobalScope/currentTime) */
declare var currentTime: number;

/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioWorkletGlobalScope/sampleRate) */
declare var sampleRate: number;

/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioWorkletGlobalScope/registerProcessor) */
declare function registerProcessor(name: string, processor: AudioWorkletProcessorConstructor): void;

if ('AudioWorkletProcessor' in globalThis) {
class Dsp extends AudioWorkletProcessor {
Expand Down

0 comments on commit 95cfca9

Please sign in to comment.