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:
name
str - The name identifier of the track.paused
bool - Whether the track is currently paused.muted
bool - Whether the track is currently muted.volume
float - The volume level of the track as a decimal.realtime
bool - 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) -> ndarray
Retrieves the latest audio chunk.
Arguments:
num_frames
int - 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:
name
str - Name of theTrack