Audio on native
This commit is contained in:
@@ -18,8 +18,10 @@ export type WindowMessage =
|
||||
surface: SurfaceHandles;
|
||||
width: number;
|
||||
height: number;
|
||||
// what the client saved, see NativePlatform's storage
|
||||
// what the client saved, see Platform.storage
|
||||
storage: Record<string, string>;
|
||||
// whether the window can play sound, see desktop/openal.ts
|
||||
audio: boolean;
|
||||
}
|
||||
// in pixels, what's drawn to is this big now
|
||||
| { type: "resize"; width: number; height: number }
|
||||
@@ -40,7 +42,9 @@ export type WindowMessage =
|
||||
| { type: "shown"; shown: boolean }
|
||||
// answers, by the id they were asked with
|
||||
| { type: "clipboard"; id: number; text: string }
|
||||
| { type: "answer"; id: number; yes: boolean };
|
||||
| { type: "answer"; id: number; yes: boolean }
|
||||
// sources that played to their end, see web_audio.ts
|
||||
| { type: "audio_ended"; sources: number[] };
|
||||
|
||||
export type ClientMessage =
|
||||
| { type: "grab"; grab: boolean }
|
||||
@@ -52,4 +56,31 @@ export type ClientMessage =
|
||||
| { type: "ask"; id: number; title: string; text: string; yes: string; no: string }
|
||||
| { type: "read_clipboard"; id: number }
|
||||
| { type: "write_clipboard"; text: string }
|
||||
| { type: "store"; key: string; value: string };
|
||||
| { type: "store"; key: string; value: string }
|
||||
| { type: "audio"; commands: AudioCommand[] };
|
||||
|
||||
// how a playing source sounds: everything between it and the speakers worked out, see web_audio.ts. gain 0 is silent
|
||||
export interface SourceSettings {
|
||||
gain: number;
|
||||
pitch: number;
|
||||
// where it is, with its distance falloff: full gain within ref_distance, fading linearly to 1 - rolloff at
|
||||
// max_distance. undefined plays it as it is, not from anywhere
|
||||
at: [number, number, number] | undefined;
|
||||
ref_distance: number;
|
||||
max_distance: number;
|
||||
rolloff: number;
|
||||
}
|
||||
|
||||
// what the client's web audio has the window's openal do. ids are the client's own
|
||||
export type AudioCommand =
|
||||
// a decoded file, one array of samples a channel
|
||||
| { op: "buffer"; id: number; channels: Float32Array[]; sample_rate: number }
|
||||
| { op: "play"; id: number; buffer: number; loop: boolean; offset: number; settings: SourceSettings }
|
||||
| { op: "set"; id: number; settings: SourceSettings }
|
||||
| { op: "stop"; id: number }
|
||||
| {
|
||||
op: "listener";
|
||||
position: [number, number, number];
|
||||
forward: [number, number, number];
|
||||
up: [number, number, number];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user