brian.audio
- PlaybackMode
- AudioFileMetadata
- PlaybackStatus
- play_tone
- stop_tone
- play_file
- stop_playback
- get_playback_status
- wait_until_done_playing
PlaybackMode class objects
Mirrors AudioDriver::PlaybackMode (values match firmware).
IDLE
TONE
FILE_STREAM
AudioFileMetadata class objects
Read-only snapshot of file metadata (attrtuple at runtime). Use attribute access: channels, bits_per_sample, sample_rate_hz, total_samples, is_supported_format.
channels
bits_per_sample
sample_rate_hz
total_samples
is_supported_format
PlaybackStatus class objects
Read-only playback snapshot (attrtuple at runtime). Use attribute access: mode, has_ended, current_sample, metadata.
mode
has_ended
current_sample
metadata
play_tone
Play a sine tone to the audio output.
This method returns instantly and the tone is played in the background.
Arguments:
tone: Frequency in Hz to play.duration_ms: How long should the tone last
stop_tone
play_file
def play_file(path: str,
*,
skip_samples: Optional[int] = None,
adaptive_loudness: Optional[bool] = None) -> bool
Stream and play an audio file from SD card.
The file is decoded and pushed in chunks and is not loaded fully to memory.
Arguments:
path: Absolute VFS path to file (for example/recording.wav).skip_samples: IfNone, start from the beginning of the file. If set, number of source sample frames to skip before playback (per-channel frames in the WAV). Must be non-negative. Very large integers may raiseOverflowErroron the firmware port.adaptive_loudness: IfTrue, apply slow AGC, gentle compression, and limiting. IfNone, the firmware default (enabled) is used.
Returns:
True if playback request was accepted, False otherwise.
stop_playback
get_playback_status
Return a snapshot of current playback state, or None if status is unavailable.
The returned object supports attribute access like PlaybackStatus / AudioFileMetadata (implementation uses compact
read-only attrtuples).
wait_until_done_playing
Block until no tone or file stream is active, timeout_ms elapses, or the program is stopped/interrupted.
Arguments:
timeout_ms: Maximum wait in milliseconds;Nonemeans wait until idle or abort.
Returns:
True if playback became idle; False on timeout or abort.