import { Actionable } from "../action/actionable"; import { LogicAction } from "../game"; import { Chained, Proxied } from "../action/chain"; type ChainedSound = Proxied>; export declare enum SoundType { Voice = "voice", Bgm = "bgm", Sound = "sound" } export type VoiceIdMap = Record; export type VoiceSrcGenerator = (id: string | number) => string | Sound; export interface ISoundUserConfig { /** * Sound source should be a URL or a base64 string */ src: string; /** * Whether to loop, if sync and loop are both true, sync will be treated as **false** * @default false */ loop: boolean; /** * Initial volume, between 0 and 1 * @default 1 */ volume: number; /** * Playback rate, 0.5 to 4 * @default 1 */ rate: number; /** * Set to `true` to force HTML5 Audio. * This should be used for large audio files * so that you don't have to wait for the full file to be downloaded and decoded before playing. * @default false */ streaming: boolean; /** * Initial position in seconds * @default 0 */ seek: number; /** * The type of the sound * @default SoundType.Sound */ type: SoundType; } export declare class Sound extends Actionable { /** * Create a voice sound for dialog lines. * @param arg0 - Source or config for the voice clip. * @example * ```ts * Sound.voice({ src: "voice.mp3" }); * ``` */ static voice(arg0: Partial | string): Sound; /** * Create background music that cannot be played via `play()`. * @param arg0 - Source or config for the bgm clip. * @example * ```ts * Sound.bgm("theme.mp3"); * ``` */ static bgm(arg0: Partial | string): Sound; /** * Create a one-off sound effect. * @param arg0 - Source or config for the sound effect. */ static sound(arg0: Partial | string): Sound; constructor(config?: Partial); constructor(src?: string); constructor(arg0: Partial | string); /** * Start playing the sound and wait for it to finish. * @param duration - Optional fade duration in milliseconds. * @chainable * @example * ```ts * sound.play(1000); * ``` */ play(duration?: number): ChainedSound; /** * Stop the sound and optionally fade out. * @param duration - Fade duration in milliseconds. * @chainable */ stop(duration?: number): ChainedSound; /** * Change the sound volume gradually. * @param volume - Target volume (0-1). * @param duration - Fade duration in milliseconds. * @chainable * @example * ```ts * sound.setVolume(0.5, 500); * ``` */ setVolume(volume: number, duration?: number): ChainedSound; /** * Mute or unmute the sound. * @param muted - `true` to mute, `false` to restore volume. * @chainable */ mute(muted?: boolean): ChainedSound; /** * Alias of `mute(false)` to restore audio. * @chainable */ unmute(): ChainedSound; /** * Change the playback rate. * @param rate - Playback multiplier (1 is normal speed). * @chainable */ setRate(rate: number): ChainedSound; /** * Pause the sound, optionally fading out. * @param duration - Fade duration in milliseconds. * @chainable */ pause(duration?: number): ChainedSound; /** * Resume playback, optionally fading in. * @param duration - Fade duration in milliseconds. * @chainable */ resume(duration?: number): ChainedSound; /** * Create a sound with the same configuration */ copy(): Sound; } export {};