Skip to content

Commit

Permalink
Add typing to classes and format code
Browse files Browse the repository at this point in the history
  • Loading branch information
adamscott committed May 23, 2024
1 parent 82e250f commit 2bf4713
Show file tree
Hide file tree
Showing 2 changed files with 457 additions and 146 deletions.
30 changes: 18 additions & 12 deletions platform/web/js/libs/library_godot_audio.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type PositionMode = "none" | "2D" | "3D";
export type LoopMode = "disabled" | "forward" | "backward" | "pingpong";
export type PositionMode = "none"|"2D"|"3D";
export type LoopMode = "disabled"|"forward"|"backward"|"pingpong";

interface SampleParams {
id: string
Expand Down Expand Up @@ -30,10 +30,12 @@ export declare class Sample {
loopEnd: number;

static getSample(id: string): Sample;
static getSampleOrNull(id: string): Sample | null;
static getSampleOrNull(id: string): Sample|null;
static create(params: SampleParams, options?: SampleOptions): Sample;

constructor(params: SampleParams, options?: SampleOptions);

clear(): void;
_duplicateAudioBuffer(): Sample;
}

Expand All @@ -51,6 +53,8 @@ export declare class SampleNodeBus {
get inputNode(): AudioNode;
get outputNode(): AudioNode;

static create(bus: Bus): SampleNodeBus;

constructor(bus: Bus);

setVolume(volume: Float32Array): void;
Expand All @@ -59,17 +63,17 @@ export declare class SampleNodeBus {

interface SampleNodeParams {
id: string,
streamObjectId: string,
busIndex: number,
streamObjectId: string,
busIndex: number,
}

interface SampleNodeOptions {
offset: number,
positionMode: PositionMode,
playbackRate: number,
startTime: number,
loopMode: LoopMode,
volume: Float32Array,
positionMode: PositionMode,
playbackRate: number,
startTime: number,
loopMode: LoopMode,
volume: Float32Array,
}

export declare class SampleNode {
Expand All @@ -95,9 +99,10 @@ export declare class SampleNode {
get sample(): Sample;

static getSampleNode(id: string): SampleNode;
static getSampleNodeOrNull(id: string): SampleNode | null;
static getSampleNodeOrNull(id: string): SampleNode|null;
static stopSampleNode(id: string): void;
static pauseSampleNode(id: void, enable: boolean): void;
static create(params: SampleNodeParams, options?: SampleNodeOptions): SampleNode;

constructor(params: SampleNodeParams, options?: SampleNodeOptions);

Expand All @@ -113,7 +118,7 @@ export declare class SampleNode {

export declare class Bus {
static _buses: Bus[];
static _busSolo: Bus | null;
static _busSolo: Bus|null;

_gainNode: GainNode;
_soloNode: GainNode;
Expand All @@ -134,6 +139,7 @@ export declare class Bus {
static get count(): number;
static set count(val: number);
static addAt(index: number): void;
static create(): Bus;

constructor();

Expand Down

0 comments on commit 2bf4713

Please sign in to comment.