Track Control
minispeaker.tracks
Track
class Track()A dataclass representing an audio track with playback control functionality.
This class manages audio track state including play/pause, mute/unmute, volume control, and provides methods to retrieve audio chunks and wait for track completion.
Attributes:
namestr - The name identifier of the track.pausedbool - Whether the track is currently paused.mutedbool - Whether the track is currently muted.volumefloat - The volume level of the track as a decimal.realtimebool - Whether the track operates in realtime mode.
Track.pause
def pause()Pauses the track. Does nothing if the track is already paused.
Track.cont
def cont()Unpauses the track. Does nothing if the track is already playing.
Track.mute
def mute()Mutes the track. The audio will still be playing but it won't be heard. Does nothing if the track is already muted.
Track.unmute
def unmute()Unmutes the track. Does nothing if the track is not muted.
Track.wait
def wait() -> bool | Coroutine[Any, Any, Literal[True]]Wait until Track is finished.
Returns:
bool | Coroutine[Any, Any, Literal[True]]: Either a synchronous or asynchronous return result of Event.wait
Track.chunk
def chunk(num_frames: int) -> ndarrayRetrieves the latest audio chunk.
Arguments:
num_framesint - The number of frames per chunk.
Returns:
ndarray- A audio chunk represented as a numpy array.
TrackMapping
class TrackMapping(Dict[str, Track])Container for Track access and control.
TrackMapping.clear
def clear()Removes all current tracks. An alert is sent indicating all the tracks are finished.
TrackMapping.__delitem__
def __delitem__(name: str)Remove a Track called name. An alert is sent indicating thatTrack is finished.
Arguments:
namestr - Name of theTrack