Skip to main content

Module audio

Module audio 

Source
Expand description

Low-level audio output (capability voice): the bot writes the audio itself, packet by packet or sample by sample, instead of naming tracks for the player. For synthesisers, text to speech, mixers, and bots that decode formats of their own. Output only: members’ audio is never delivered to a bot.

One stream at a time, in the bot’s voice channel. Opening it pauses the player (voice); closing it resumes the player. voice-event.audio-low asks for more, so a bot can write as it plays without timers.

Structs§

PcmFormat
PCM the host encodes to Opus.
StreamOptions

Enums§

AudioFormat
How the bot’s audio is encoded.

Functions§

buffered_ms
The audio written and not yet played, in ms (0 without a stream).
clear
Drops everything buffered at once, keeping the stream open (to interrupt speech).
close
Closes the stream: once the buffer has played (drain), or at once. The player resumes. Nothing happens without a stream.
open
Opens the stream in the bot’s voice channel, pausing the player. CONFLICT when the bot is in no voice channel or a stream is open; UNSUPPORTED for a format the host cannot take; BAD_REQUEST for a rate, channel count or low-water mark out of range.
write_opus
Opus packets, for an opus stream. Returns the audio buffered, in ms; BUSY past 3 s.
write_pcm
Interleaved samples, for a pcm stream; any count (the host frames them). Returns the audio buffered, in ms; BUSY past 3 s.

Type Aliases§

HostError